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"]
31 import lsst.utils.tests
35 @lsst.utils.tests.inTestCase
37 """!Assert that two coords represent almost the same point on the sky
39 @warning the coordinate systems are not compared; instead both angles are converted to ICRS
40 and the angular separation measured.
42 @param[in] testCase unittest.TestCase instance the test is part of;
43 an object supporting one method: fail(self, msgStr)
44 @param[in] coord0 coord 0 (an lsst.afw.geom.Coord)
45 @param[in] coord1 coord 1 (an lsst.afw.geom.Coord)
46 @param[in] maxDiff maximum angular separation between the two coords (an lsst.afw.geom.Angle)
47 @param[in] msg exception message prefix; details of the error are appended after ": "
49 @throw AssertionError if the unwrapped difference is greater than maxDiff
51 measDiff = coord0.toIcrs().angularSeparation(coord1.toIcrs())
52 if measDiff > maxDiff:
53 testCase.fail(
"%s: measured angular separation %s arcsec > max allowed %s arcsec" %
54 (msg, measDiff.asArcseconds(), maxDiff.asArcseconds()))
57 @lsst.utils.tests.inTestCase
59 warnings.warn(
"Deprecated. Use assertCoordsAlmostEqual",
def assertCoordsNearlyEqual
def assertCoordsAlmostEqual
Assert that two coords represent almost the same point on the sky.