Skip to content

Commit 438e066

Browse files
committed
Add a unit test for inputs with NaN
This unit test mimics a condition that triggered DM-49820.
1 parent c7462fc commit 438e066

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/test_getTemplate.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,29 @@ def testMissingPatches(self):
267267
self.assertTrue(np.isfinite(result.template.variance.array).all())
268268
self.assertEqual(no_data.sum(), 20990)
269269

270+
@lsst.utils.tests.methodParameters(
271+
box=[
272+
lsst.geom.Box2I(lsst.geom.Point2I(0, 0), lsst.geom.Point2I(180, 180)),
273+
lsst.geom.Box2I(lsst.geom.Point2I(200, 200), lsst.geom.Point2I(600, 600)),
274+
],
275+
nInput=[8, 16],
276+
)
277+
def testNanInputs(self, box=None, nInput=None):
278+
"""Test that the template has finite values when some of the input pixels have NaN as variance."""
279+
for tract, patchCoadds in self.patches.items():
280+
for patchCoadd in patchCoadds:
281+
bbox = lsst.geom.Box2I()
282+
bbox.include(lsst.geom.Point2I(patchCoadd.getBBox().getCenter()))
283+
bbox.grow(3)
284+
patchCoadd.variance[bbox].array *= np.nan
285+
286+
box = lsst.geom.Box2I(lsst.geom.Point2I(200, 200), lsst.geom.Point2I(600, 600))
287+
task = lsst.ip.diffim.GetTemplateTask()
288+
result = task.run(self.patches, lsst.geom.Box2I(box), self.exposure.wcs, self.dataIds, "a_test")
289+
self._checkMetadata(result.template, task.config, box, self.exposure.wcs, 16)
290+
# We just check that the pixel values are all finite. We cannot check that pixel values
291+
# in the template are closer to the original anymore.
292+
self.assertTrue(np.isfinite(result.template.image.array).all())
270293

271294
def setup_module(module):
272295
lsst.utils.tests.init()

0 commit comments

Comments
 (0)