Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-10096 Add unit test asserts for SpherePoint, SpherePointList and PointList #111

Merged
merged 4 commits into from
Apr 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ bin/mergeCoaddDetections.py
bin/mergeCoaddMeasurements.py
bin/processCcd.py
bin/processCoadd.py
bin/processDonut.py
bin/reportImagesInPatch.py
bin/reportImagesToCoadd.py
bin/reportPatches.py
Expand Down
10 changes: 5 additions & 5 deletions tests/testCoaddInputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ def tearDown(self):
del self.coadd
del self.exposures

def assertPsfsNearlyEqual(self, psf1, psf2):
def assertPsfsAlmostEqual(self, psf1, psf2):
im1 = psf1.computeImage()
im2 = psf2.computeImage()
self.assertImagesNearlyEqual(im1, im2)
self.assertImagesAlmostEqual(im1, im2)

def getCoaddPath(self, version):
return os.path.join(self.dataDir,
Expand Down Expand Up @@ -235,9 +235,9 @@ def assertCoaddInputsOk(self, coaddInputs, version):
expInfo = exp.getInfo()
self.assertEqual(expRec.getId(), i)
self.assertEqual(expRec.getBBox(), exp.getBBox())
self.assertWcsNearlyEqualOverBBox(expRec.getWcs(), expInfo.getWcs(), expRec.getBBox())
self.assertPsfsNearlyEqual(expRec.getPsf(), exp.getPsf())
self.assertPairsNearlyEqual(expRec.getCalib().getFluxMag0(), (1.1e12, 2.2e10))
self.assertWcsAlmostEqualOverBBox(expRec.getWcs(), expInfo.getWcs(), expRec.getBBox())
self.assertPsfsAlmostEqual(expRec.getPsf(), exp.getPsf())
self.assertPairsAlmostEqual(expRec.getCalib().getFluxMag0(), (1.1e12, 2.2e10))
self.assertEqual(len(expRec.getApCorrMap()), 3)
self.assertEqual(set(expRec.getApCorrMap().keys()), set(expInfo.getApCorrMap().keys()))
self.assertFloatsAlmostEqual(np.array(expRec.getValidPolygon().getVertices()),
Expand Down
11 changes: 7 additions & 4 deletions tests/testCoadds.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
#
# LSST Data Management System
# Copyright 2008-2015 AURA/LSST.
# Copyright 2008-2017 AURA/LSST.
#
# This product includes software developed by the
# LSST Project (http://www.lsst.org/).
Expand Down Expand Up @@ -372,7 +372,7 @@ def testCoaddPsf(self, tract=0):
residuals = lsst.afw.image.ImageD(starImage, True)
residuals -= psfImage

self.assertClose(starImage.getArray(), psfImage.getArray(), rtol=1E-3, atol=1E-2)
self.assertFloatsAlmostEqual(starImage.getArray(), psfImage.getArray(), rtol=1E-3, atol=1E-2)
nTested += 1
if nTested == 0:
print("WARNING: CoaddPsf test inconclusive (this can occur randomly, but very rarely; "
Expand Down Expand Up @@ -418,8 +418,11 @@ def testAlgMetadataOutput(self):
# to the algorithm metadata object. Depending on how many times a measurement task is run,
# a metadata entry may be a single value or multiple values, this test ensures that in either
# case the value can properly be extracted and compared.
ensureIterable = lambda x: x if isinstance(
x, Iterable) and not isinstance(x, basestring) else [x]

def ensureIterable(x):
if isinstance(x, Iterable) and not isinstance(x, basestring):
return x
return [x]
for nOffset in ensureIterable(meta.get('NOISE_OFFSET')):
self.assertIsInstance(nOffset, numbers.Number)
for noiseSrc in ensureIterable(meta.get('NOISE_SOURCE')):
Expand Down
5 changes: 3 additions & 2 deletions tests/testSnapCombine.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def testAddition(self):

predExp = simpleAdd(snap0, snap1, badPixelMask)
predMi = predExp.getMaskedImage()
self.assertMaskedImagesNearlyEqual(resMi, predMi)
self.assertMaskedImagesAlmostEqual(resMi, predMi)

def testAdditionAllGood(self):
"""Test the case where all pixels are valid
Expand All @@ -120,7 +120,7 @@ def testAdditionAllGood(self):

predMi = snap0.getMaskedImage().Factory(snap0.getMaskedImage(), True)
predMi += snap1.getMaskedImage()
self.assertMaskedImagesNearlyEqual(resMi, predMi)
self.assertMaskedImagesAlmostEqual(resMi, predMi)

def testMetadata(self):
"""Test more advanced metadata handling
Expand Down Expand Up @@ -184,6 +184,7 @@ class MyMemoryTestCase(lsst.utils.tests.MemoryTestCase):
def setup_module(module):
lsst.utils.tests.init()


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

squash the two pep8 commits together

if __name__ == "__main__":
lsst.utils.tests.init()
unittest.main()