Skip to content

Commit

Permalink
Make FracUpdatedMetricTask return None for first dataId.
Browse files Browse the repository at this point in the history
  • Loading branch information
kfindeisen committed Oct 10, 2019
1 parent df6da79 commit 5d212e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions python/lsst/ap/association/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ def makeMeasurement(self, values):
"or numUnassociatedDiaObjects") from e
else:
if nUpdated <= 0 and nUnassociated <= 0:
raise MetricComputationError(
"No pre-existing DIAObjects; can't compute updated fraction.")
return None # No pre-existing DIAObjects; no fraction to compute
else:
fraction = nUpdated / (nUpdated + nUnassociated)
return Measurement(self.getOutputMetricName(self.config),
Expand Down
6 changes: 4 additions & 2 deletions tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ def testAllUpdated(self):

def testNoObjects(self):
metadata = _makeAssociationMetadata(numUpdated=0, numUnassociated=0)
with self.assertRaises(MetricComputationError):
self.task.run(metadata)
result = self.task.run(metadata)
meas = result.measurement

self.assertIsNone(meas)

def testMissingData(self):
result = self.task.run(None)
Expand Down

0 comments on commit 5d212e4

Please sign in to comment.