Skip to content

Commit

Permalink
Add test for NaN when comparing angles
Browse files Browse the repository at this point in the history
Otherwise Angle(NaN) was comparing favorably with any non-NaN
angle.
  • Loading branch information
timj committed Oct 3, 2018
1 parent 017a494 commit ce41766
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/lsst/geom/testUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ def assertAnglesAlmostEqual(testCase, ang0, ang1, maxDiff=0.001*arcseconds,
AssertionError
Raised if the difference is greater than ``maxDiff``
"""
if math.isnan(ang0.asRadians()):
testCase.fail("ang0 is NaN")
if math.isnan(ang1.asRadians()):
testCase.fail("ang1 is NaN")
measDiff = ang1 - ang0
if ignoreWrap:
measDiff = measDiff.wrapCtr()
Expand Down
6 changes: 6 additions & 0 deletions tests/test_testUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ def testAssertAnglesAlmostEqual(self):
maxDiff=0.009999*lsst.geom.arcseconds,
)

# Compare with NaN
ang0 = float("NaN")*lsst.geom.degrees
ang1 = 1.*lsst.geom.degrees
with self.assertRaises(AssertionError):
self.assertAnglesAlmostEqual(ang0, ang1)

def testAssertBoxesAlmostEqual(self):
"""Test assertBoxesAlmostEqual"""
for min0 in ((0, 0), (-1000.5, 5000.1)):
Expand Down

0 comments on commit ce41766

Please sign in to comment.