LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Functions | Variables
lsst.afw.geom.utils Namespace Reference

Functions

def assertAnglesNearlyEqual
 Assert that two angles are nearly equal, ignoring wrap differences by default. More...
 
def assertPairsNearlyEqual
 Assert that two planar pairs (e.g. More...
 
def assertBoxesNearlyEqual
 Assert that two boxes (Box2D or Box2I) are nearly equal. More...
 

Variables

list __all__ = ["assertAnglesNearlyEqual", "assertPairsNearlyEqual", "assertBoxesNearlyEqual"]
 

Function Documentation

def lsst.afw.geom.utils.assertAnglesNearlyEqual (   testCase,
  ang0,
  ang1,
  maxDiff = 0.001*geomLib.arcseconds,
  ignoreWrap = True,
  msg = "Angles differ" 
)

Assert that two angles are nearly equal, ignoring wrap differences by default.

Parameters
[in]testCaseunittest.TestCase instance the test is part of; an object supporting one method: fail(self, msgStr)
[in]ang0angle 0 (an lsst.afw.geom.Angle)
[in]ang1angle 1 (an lsst.afw.geom.Angle)
[in]maxDiffmaximum difference between the two angles (an lsst.afw.geom.Angle)
[in]ignoreWrapignore wrap when comparing the angles?
  • if True then wrap is ignored, e.g. 0 and 360 degrees are considered equal
  • if False then wrap matters, e.g. 0 and 360 degrees are considered different
[in]msgexception message prefix; details of the error are appended after ": "
Exceptions
AssertionErrorif the difference is greater than maxDiff

Definition at line 36 of file utils.py.

36 
37  ignoreWrap=True, msg="Angles differ"):
38  """!Assert that two angles are nearly equal, ignoring wrap differences by default
39 
40  @param[in] testCase unittest.TestCase instance the test is part of;
41  an object supporting one method: fail(self, msgStr)
42  @param[in] ang0 angle 0 (an lsst.afw.geom.Angle)
43  @param[in] ang1 angle 1 (an lsst.afw.geom.Angle)
44  @param[in] maxDiff maximum difference between the two angles (an lsst.afw.geom.Angle)
45  @param[in] ignoreWrap ignore wrap when comparing the angles?
46  - if True then wrap is ignored, e.g. 0 and 360 degrees are considered equal
47  - if False then wrap matters, e.g. 0 and 360 degrees are considered different
48  @param[in] msg exception message prefix; details of the error are appended after ": "
49 
50  @throw AssertionError if the difference is greater than maxDiff
51  """
52  measDiff = ang1 - ang0
53  if ignoreWrap:
54  measDiff.wrapCtr()
55  if abs(measDiff) > maxDiff:
56  testCase.fail("%s: measured difference %s arcsec > max allowed %s arcsec" %
57  (msg, measDiff.asArcseconds(), maxDiff.asArcseconds()))
58 
@lsst.utils.tests.inTestCase
def lsst.afw.geom.utils.assertBoxesNearlyEqual (   testCase,
  box0,
  box1,
  maxDiff = 1e-7,
  msg = "Boxes differ" 
)

Assert that two boxes (Box2D or Box2I) are nearly equal.

Warning
Does not compare types, just compares values.
Parameters
[in]testCaseunittest.TestCase instance the test is part of; an object supporting one method: fail(self, msgStr)
[in]box0box 0
[in]box1box 1
[in]maxDiffmaximum radial separation between the min points and max points
[in]msgexception message prefix; details of the error are appended after ": "
Exceptions
AssertionErrorif the radial difference of the min points or max points is greater than maxDiff

Definition at line 84 of file utils.py.

84 
85 def assertBoxesNearlyEqual(testCase, box0, box1, maxDiff=1e-7, msg="Boxes differ"):
86  """!Assert that two boxes (Box2D or Box2I) are nearly equal
87 
88  @warning Does not compare types, just compares values.
89 
90  @param[in] testCase unittest.TestCase instance the test is part of;
91  an object supporting one method: fail(self, msgStr)
92  @param[in] box0 box 0
93  @param[in] box1 box 1
94  @param[in] maxDiff maximum radial separation between the min points and max points
95  @param[in] msg exception message prefix; details of the error are appended after ": "
96 
97  @throw AssertionError if the radial difference of the min points or max points is greater than maxDiff
98  """
99  assertPairsNearlyEqual(testCase, box0.getMin(), box1.getMin(), maxDiff=maxDiff, msg=msg + ": min")
100  assertPairsNearlyEqual(testCase, box0.getMax(), box1.getMax(), maxDiff=maxDiff, msg=msg + ": max")
def assertPairsNearlyEqual
Assert that two planar pairs (e.g.
Definition: utils.py:59
def assertBoxesNearlyEqual
Assert that two boxes (Box2D or Box2I) are nearly equal.
Definition: utils.py:84
def lsst.afw.geom.utils.assertPairsNearlyEqual (   testCase,
  pair0,
  pair1,
  maxDiff = 1e-7,
  msg = "Pairs differ" 
)

Assert that two planar pairs (e.g.

Point2D or Extent2D) are nearly equal

Warning
Does not compare types, just compares values.
Parameters
[in]testCaseunittest.TestCase instance the test is part of; an object supporting one method: fail(self, msgStr)
[in]pair0pair 0 (a pair of floats)
[in]pair1pair 1 (a pair of floats)
[in]maxDiffmaximum radial separation between the two points
[in]msgexception message prefix; details of the error are appended after ": "
Exceptions
AssertionErrorif the radial difference is greater than maxDiff

Definition at line 59 of file utils.py.

59 
60 def assertPairsNearlyEqual(testCase, pair0, pair1, maxDiff=1e-7, msg="Pairs differ"):
61  """!Assert that two planar pairs (e.g. Point2D or Extent2D) are nearly equal
62 
63  @warning Does not compare types, just compares values.
64 
65  @param[in] testCase unittest.TestCase instance the test is part of;
66  an object supporting one method: fail(self, msgStr)
67  @param[in] pair0 pair 0 (a pair of floats)
68  @param[in] pair1 pair 1 (a pair of floats)
69  @param[in] maxDiff maximum radial separation between the two points
70  @param[in] msg exception message prefix; details of the error are appended after ": "
71 
72  @throw AssertionError if the radial difference is greater than maxDiff
73  """
74  if len(pair0) != 2:
75  raise RuntimeError("len(pair0)=%s != 2" % (len(pair0),))
76  if len(pair1) != 2:
77  raise RuntimeError("len(pair1)=%s != 2" % (len(pair1),))
78 
79  pairDiff = [float(pair1[i] - pair0[i]) for i in range(2)]
80  measDiff = math.hypot(*pairDiff)
81  if measDiff > maxDiff:
82  testCase.fail("%s: measured radial distance = %s > maxDiff = %s" % (msg, measDiff, maxDiff))
83 
@lsst.utils.tests.inTestCase
def assertPairsNearlyEqual
Assert that two planar pairs (e.g.
Definition: utils.py:59

Variable Documentation

list lsst.afw.geom.utils.__all__ = ["assertAnglesNearlyEqual", "assertPairsNearlyEqual", "assertBoxesNearlyEqual"]

Definition at line 32 of file utils.py.