1 from __future__
import absolute_import, division, print_function
23 """Utilities that should be imported into the lsst.afw.coord namespace when lsst.afw.coord is used 25 In the case of the assert functions, importing them makes them available in lsst.utils.tests.TestCase 27 __all__ = [
"assertCoordsAlmostEqual",
"assertCoordsNearlyEqual"]
37 @lsst.utils.tests.inTestCase
39 """!Assert that two coords represent almost the same point on the sky 41 @warning the coordinate systems are not compared; instead both angles are converted to ICRS 42 and the angular separation measured. 44 @param[in] testCase unittest.TestCase instance the test is part of; 45 an object supporting one method: fail(self, msgStr) 46 @param[in] coord0 coord 0 (an lsst.afw.geom.Coord) 47 @param[in] coord1 coord 1 (an lsst.afw.geom.Coord) 48 @param[in] maxDiff maximum angular separation between the two coords (an lsst.afw.geom.Angle) 49 @param[in] msg exception message prefix; details of the error are appended after ": " 51 @throw AssertionError if the unwrapped difference is greater than maxDiff 53 measDiff = coord0.toIcrs().angularSeparation(coord1.toIcrs())
54 if measDiff > maxDiff:
55 testCase.fail(
"%s: measured angular separation %s arcsec > max allowed %s arcsec" %
56 (msg, measDiff.asArcseconds(), maxDiff.asArcseconds()))
59 @lsst.utils.tests.inTestCase
61 """!Assert that two lists of IcrsCoords represent almost the same point on the sky 63 @warning the coordinate systems are not compared; instead both sets of angles are converted to ICRS 64 and the angular separation measured. 66 @param[in] testCase unittest.TestCase instance the test is part of; 67 an object supporting one method: fail(self, msgStr) 68 @param[in] coordlist0 list of IcrsCoords 0 69 @param[in] coordlist1 list of IcrsCoords 1 70 @param[in] maxDiff maximum angular separation, an lsst.afw.geom.Angle 71 @param[in] msg exception message prefix; details of the error are appended after ": " 73 testCase.assertEqual(len(coordlist0), len(coordlist1), msg=msg)
74 sepArr = np.array([sp0.toIcrs().angularSeparation(sp1.toIcrs())
75 for sp0, sp1
in zip(coordlist0, coordlist1)])
76 badArr = sepArr > maxDiff
78 maxInd = np.argmax(sepArr)
79 testCase.fail(
"%s: IcrsCoordLists differ in %s places; max separation is at %s: %s\" > %s\"%s" %
80 (msg, np.sum(badArr), maxInd, sepArr[maxInd].asArcseconds(),
81 maxDiff.asArcseconds()))
84 @lsst.utils.tests.inTestCase
86 warnings.warn(
"Deprecated. Use assertCoordsAlmostEqual",
87 DeprecationWarning, 2)
def assertCoordListsAlmostEqual(testCase, coordlist0, coordlist1, maxDiff=0.001 *afwGeom.arcseconds, msg=None)
Assert that two lists of IcrsCoords represent almost the same point on the sky.
def assertCoordsAlmostEqual(testCase, coord0, coord1, maxDiff=0.001 *afwGeom.arcseconds, msg="Coords differ")
Assert that two coords represent almost the same point on the sky.
def assertCoordsNearlyEqual(args, kwargs)