ObsLsstButlerTests¶
- class lsst.obs.lsst.testHelper.ObsLsstButlerTests(methodName='runTest')¶
Bases:
TestCase
Base class shared by all tests of the butler and mapper.
This class can not inherit from
ObsTests
since that will trigger tests in this class directly that will fail.This class defines a butler and a mapper for each test subclass. They are stored in the
_mapper
and_butler
class attributes to distinguish them from themapper
andbutler
instance attributes used byObsTests
.Attributes Summary
Name of instrument directory within data/input.
Methods Summary
__call__
(*args, **kwds)Call self as a function.
addClassCleanup
(function, /, *args, **kwargs)Same as addCleanup, except the cleanup items are called even if setUpClass fails (unlike tearDownClass).
addCleanup
(function, /, *args, **kwargs)Add a function, with arguments, to be called when the test is completed.
addTypeEqualityFunc
(typeobj, function)Add a type specific assertEqual style function to compare a type.
assertAlmostEqual
(first, second[, places, ...])Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the difference between the two objects is more than the given delta.
assertAlmostEquals
(**kwargs)assertAmplifiersEqual
(amp1, amp2)assertAnglesAlmostEqual
(ang0, ang1[, ...])Assert that two
Angle
s are almost equal, ignoring wrap differences by default.assertBoxesAlmostEqual
(box0, box1[, ...])assertCamerasEqual
(camera1, camera2, **kwds)Compare two Camers.
assertCountEqual
(first, second[, msg])Asserts that two iterables have the same elements, the same number of times, without regard to order.
assertDetectorCollectionsEqual
(collection1, ...)Compare two DetectorCollections.
assertDetectorsEqual
(detector1, detector2, *)Compare two Detectors.
assertDictContainsSubset
(subset, dictionary)Checks whether dictionary is a superset of subset.
assertDictEqual
(d1, d2[, msg])assertEqual
(first, second[, msg])Fail if the two objects are unequal as determined by the '==' operator.
assertEquals
(**kwargs)assertFalse
(expr[, msg])Check that the expression is false.
assertFloatsAlmostEqual
(lhs, rhs[, rtol, ...])Highly-configurable floating point comparisons for scalars and arrays.
assertFloatsEqual
(lhs, rhs, **kwargs)Assert that lhs == rhs (both numeric types, whether scalar or array).
assertFloatsNotEqual
(lhs, rhs, **kwds)Fail a test if the given floating point values are equal to within the given tolerances.
assertGreater
(a, b[, msg])Just like self.assertTrue(a > b), but with a nicer default message.
assertGreaterEqual
(a, b[, msg])Just like self.assertTrue(a >= b), but with a nicer default message.
assertImagesAlmostEqual
(image0, image1[, ...])!Assert that two images are almost equal, including non-finite values
assertImagesEqual
(**kwds)!Assert that two images are exactly equal, including non-finite values.
assertIn
(member, container[, msg])Just like self.assertTrue(a in b), but with a nicer default message.
assertIs
(expr1, expr2[, msg])Just like self.assertTrue(a is b), but with a nicer default message.
assertIsInstance
(obj, cls[, msg])Same as self.assertTrue(isinstance(obj, cls)), with a nicer default message.
assertIsNone
(obj[, msg])Same as self.assertTrue(obj is None), with a nicer default message.
assertIsNot
(expr1, expr2[, msg])Just like self.assertTrue(a is not b), but with a nicer default message.
assertIsNotNone
(obj[, msg])Included for symmetry with assertIsNone.
assertLess
(a, b[, msg])Just like self.assertTrue(a < b), but with a nicer default message.
assertLessEqual
(a, b[, msg])Just like self.assertTrue(a <= b), but with a nicer default message.
assertListEqual
(list1, list2[, msg])A list-specific equality assertion.
assertLogs
([logger, level])Fail unless a log message of level level or higher is emitted on logger_name or its children.
assertMaskedImagesAlmostEqual
(maskedImage0, ...)!Assert that two masked images are nearly equal, including non-finite values
assertMaskedImagesEqual
(**kwds)!Assert that two masked images are exactly equal, including non-finite values.
assertMasksEqual
(mask0, mask1[, skipMask, msg])!Assert that two masks are equal
assertMultiLineEqual
(first, second[, msg])Assert that two multi-line strings are equal.
assertNoLogs
([logger, level])Fail unless no log messages of level level or higher are emitted on logger_name or its children.
assertNotAlmostEqual
(first, second[, ...])Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the difference between the two objects is less than the given delta.
assertNotAlmostEquals
(**kwargs)assertNotEqual
(first, second[, msg])Fail if the two objects are equal as determined by the '!=' operator.
assertNotEquals
(**kwargs)assertNotIn
(member, container[, msg])Just like self.assertTrue(a not in b), but with a nicer default message.
assertNotIsInstance
(obj, cls[, msg])Included for symmetry with assertIsInstance.
assertNotRegex
(text, unexpected_regex[, msg])Fail the test if the text matches the regular expression.
assertNotRegexpMatches
(**kwargs)assertPairListsAlmostEqual
(list0, list1[, ...])Assert that two lists of Cartesian points are almost equal
assertPairsAlmostEqual
(pair0, pair1[, ...])Assert that two Cartesian points are almost equal.
assertRaises
(expected_exception, *args, **kwargs)Fail unless an exception of class expected_exception is raised by the callable when invoked with specified positional and keyword arguments.
assertRaisesRegex
(expected_exception, ...)Asserts that the message in a raised exception matches a regex.
assertRaisesRegexp
(**kwargs)assertRegex
(text, expected_regex[, msg])Fail the test unless the text matches the regular expression.
assertRegexpMatches
(**kwargs)assertSchemasEqual
(schema1, schema2[, flags])Assert that two Schemas are equal.
assertSequenceEqual
(seq1, seq2[, msg, seq_type])An equality assertion for ordered sequences (like lists and tuples).
assertSetEqual
(set1, set2[, msg])A set-specific equality assertion.
assertSpherePointListsAlmostEqual
(splist0, ...)Assert that two lists of
SpherePoint
s are almost equalassertSpherePointsAlmostEqual
(sp0, sp1[, ...])Assert that two
SpherePoint
s are almost equalassertTransformMapsEqual
(map1, map2, **kwds)Compare two TransformMaps.
assertTrue
(expr[, msg])Check that the expression is true.
assertTupleEqual
(tuple1, tuple2[, msg])A tuple-specific equality assertion.
assertWarns
(expected_warning, *args, **kwargs)Fail unless a warning of class warnClass is triggered by the callable when invoked with specified positional and keyword arguments.
assertWarnsRegex
(expected_warning, ...)Asserts that the message in a triggered warning matches a regexp.
assertWcsAlmostEqualOverBBox
(wcs0, wcs1, bbox)Assert that two
WCS
are almost equal over a grid of pixel positionsassert_
(**kwargs)compare2DFunctions
(func1, func2[, minVal, ...])Compare two Point2D(Point2D) functions by evaluating them over a range of values.
debug
()Run the test without collecting errors in a TestResult
Execute all class cleanup functions.
Execute all cleanup functions.
fail
([msg])Fail immediately, with the given message.
failIf
(**kwargs)failIfAlmostEqual
(**kwargs)failIfEqual
(**kwargs)failUnless
(**kwargs)failUnlessAlmostEqual
(**kwargs)failUnlessEqual
(**kwargs)failUnlessRaises
(**kwargs)Retrieve the
lsst.obs.base.Instrument
class for this instrument.id
()Generate a representative sample of
Endpoints
.run
([result])setUp
()Hook method for setting up the test fixture before exercising it.
Hook method for setting up class fixture before running tests in the class.
Returns a one-line description of the test, or None if no description has been provided.
skipTest
(reason)Skip this test.
subTest
([msg])Return a context manager that will return the enclosed block of code in a subtest identified by the optional message and keyword parameters.
tearDown
()Hook method for deconstructing the test fixture after testing it.
Hook method for deconstructing the class fixture after running all tests in the class.
Attributes Documentation
- instrumentDir = 'TBD'¶
Name of instrument directory within data/input.
- longMessage = True¶
- maxDiff = 640¶
Methods Documentation
- __call__(*args, **kwds)¶
Call self as a function.
- classmethod addClassCleanup(function, /, *args, **kwargs)¶
Same as addCleanup, except the cleanup items are called even if setUpClass fails (unlike tearDownClass).
- addCleanup(function, /, *args, **kwargs)¶
Add a function, with arguments, to be called when the test is completed. Functions added are called on a LIFO basis and are called after tearDown on test failure or success.
Cleanup items are called even if setUp fails (unlike tearDown).
- addTypeEqualityFunc(typeobj, function)¶
Add a type specific assertEqual style function to compare a type.
This method is for use by TestCase subclasses that need to register their own type equality functions to provide nicer error messages.
- Args:
- typeobj: The data type to call this function on when both values
are of the same type in assertEqual().
- function: The callable taking two arguments and an optional
msg= argument that raises self.failureException with a useful error message when the two arguments are not equal.
- assertAlmostEqual(first, second, places=None, msg=None, delta=None)¶
Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the difference between the two objects is more than the given delta.
Note that decimal places (from zero) are usually not the same as significant digits (measured from the most significant digit).
If the two objects compare equal then they will automatically compare almost equal.
- assertAlmostEquals(**kwargs)¶
- assertAmplifiersEqual(amp1, amp2)¶
- assertAnglesAlmostEqual(ang0, ang1, maxDiff=Angle(2.7777777777777781e-07, degrees), ignoreWrap=True, msg='Angles differ')¶
Assert that two
Angle
s are almost equal, ignoring wrap differences by default.If both arguments are NaN the assert will pass. If one of the arguments is NaN but the other is not the assert will fail.
- Parameters:
- testCase
unittest.TestCase
test case the test is part of; an object supporting one method: fail(self, msgStr)
- ang0
lsst.geom.Angle
angle 0
- ang1
lsst.geom.Angle
angle 1
- maxDiff
lsst.geom.Angle
maximum difference between the two angles
- ignoreWrap
bool
ignore 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
- msg
str
exception message prefix; details of the error are appended after “: “
- testCase
- Raises:
- AssertionError
Raised if the difference is greater than
maxDiff
- assertBoxesAlmostEqual(box0, box1, maxDiff=1e-07, msg='Boxes differ')¶
Assert that two boxes (
Box2D
orBox2I
) are almost equal- Parameters:
- testCase
unittest.TestCase
test case the test is part of; an object supporting one method: fail(self, msgStr)
- box0
lsst.geom.Box2D
orlsst.geom.Box2I
box 0
- box1
lsst.geom.Box2D
orlsst.geom.Box2I
box 1
- maxDiff
float
maximum radial separation between the min points and max points
- msg
str
exception message prefix; details of the error are appended after “: “
- testCase
- Raises:
- AssertionError
Raised if the radial difference of the min points or max points is greater than maxDiff
Notes
Warning
Does not compare types, just compares values.
- assertCamerasEqual(camera1, camera2, **kwds)¶
Compare two Camers.
- assertCountEqual(first, second, msg=None)¶
Asserts that two iterables have the same elements, the same number of times, without regard to order.
- self.assertEqual(Counter(list(first)),
Counter(list(second)))
- Example:
[0, 1, 1] and [1, 0, 1] compare equal.
[0, 0, 1] and [0, 1] compare unequal.
- assertDetectorCollectionsEqual(collection1, collection2, **kwds)¶
Compare two DetectorCollections.
- assertDetectorsEqual(detector1, detector2, *, compareTransforms=True, **kwds)¶
Compare two Detectors.
- assertDictContainsSubset(subset, dictionary, msg=None)¶
Checks whether dictionary is a superset of subset.
- assertDictEqual(d1, d2, msg=None)¶
- assertEqual(first, second, msg=None)¶
Fail if the two objects are unequal as determined by the ‘==’ operator.
- assertEquals(**kwargs)¶
- assertFalse(expr, msg=None)¶
Check that the expression is false.
- assertFloatsAlmostEqual(lhs: Union[float, ndarray], rhs: Union[float, ndarray], rtol: Optional[float] = 2.220446049250313e-16, atol: Optional[float] = 2.220446049250313e-16, relTo: Optional[float] = None, printFailures: bool = True, plotOnFailure: bool = False, plotFileName: Optional[str] = None, invert: bool = False, msg: Optional[str] = None, ignoreNaNs: bool = False) None ¶
Highly-configurable floating point comparisons for scalars and arrays.
The test assertion will fail if all elements
lhs
andrhs
are not equal to within the tolerances specified byrtol
andatol
. More precisely, the comparison is:abs(lhs - rhs) <= relTo*rtol OR abs(lhs - rhs) <= atol
If
rtol
oratol
isNone
, that term in the comparison is not performed at all.When not specified,
relTo
is the elementwise maximum of the absolute values oflhs
andrhs
. If set manually, it should usually be set to eitherlhs
orrhs
, or a scalar value typical of what is expected.- Parameters:
- testCase
unittest.TestCase
Instance the test is part of.
- lhsscalar or array-like
LHS value(s) to compare; may be a scalar or array-like of any dimension.
- rhsscalar or array-like
RHS value(s) to compare; may be a scalar or array-like of any dimension.
- rtol
float
, optional Relative tolerance for comparison; defaults to double-precision epsilon.
- atol
float
, optional Absolute tolerance for comparison; defaults to double-precision epsilon.
- relTo
float
, optional Value to which comparison with rtol is relative.
- printFailures
bool
, optional Upon failure, print all inequal elements as part of the message.
- plotOnFailure
bool
, optional Upon failure, plot the originals and their residual with matplotlib. Only 2-d arrays are supported.
- plotFileName
str
, optional Filename to save the plot to. If
None
, the plot will be displayed in a window.- invert
bool
, optional If
True
, invert the comparison and fail only if any elements are equal. Used to implementassertFloatsNotEqual
, which should generally be used instead for clarity. will returnTrue
).- msg
str
, optional String to append to the error message when assert fails.
- ignoreNaNs
bool
, optional If
True
(False
is default) mask out any NaNs from operand arrays before performing comparisons if they are in the same locations; NaNs in different locations are trigger test assertion failures, even wheninvert=True
. Scalar NaNs are treated like arrays containing only NaNs of the same shape as the other operand, and no comparisons are performed if both sides are scalar NaNs.
- testCase
- Raises:
- AssertionError
The values are not almost equal.
- assertFloatsEqual(lhs: Union[float, ndarray], rhs: Union[float, ndarray], **kwargs: Any) None ¶
Assert that lhs == rhs (both numeric types, whether scalar or array).
See
assertFloatsAlmostEqual
(called withrtol=atol=0
) for more information.- Parameters:
- testCase
unittest.TestCase
Instance the test is part of.
- lhsscalar or array-like
LHS value(s) to compare; may be a scalar or array-like of any dimension.
- rhsscalar or array-like
RHS value(s) to compare; may be a scalar or array-like of any dimension.
- testCase
- Raises:
- AssertionError
The values are not equal.
- assertFloatsNotEqual(lhs: Union[float, ndarray], rhs: Union[float, ndarray], **kwds: Any) None ¶
Fail a test if the given floating point values are equal to within the given tolerances.
See
assertFloatsAlmostEqual
(called withrtol=atol=0
) for more information.- Parameters:
- testCase
unittest.TestCase
Instance the test is part of.
- lhsscalar or array-like
LHS value(s) to compare; may be a scalar or array-like of any dimension.
- rhsscalar or array-like
RHS value(s) to compare; may be a scalar or array-like of any dimension.
- testCase
- Raises:
- AssertionError
The values are almost equal.
- assertGreater(a, b, msg=None)¶
Just like self.assertTrue(a > b), but with a nicer default message.
- assertGreaterEqual(a, b, msg=None)¶
Just like self.assertTrue(a >= b), but with a nicer default message.
- assertImagesAlmostEqual(image0, image1, skipMask=None, rtol=1e-05, atol=1e-08, msg='Images differ')¶
!Assert that two images are almost equal, including non-finite values
- @param[in] testCase unittest.TestCase instance the test is part of;
an object supporting one method: fail(self, msgStr)
- @param[in] image0 image 0, an lsst.afw.image.Image, lsst.afw.image.Mask,
or transposed numpy array (see warning)
- @param[in] image1 image 1, an lsst.afw.image.Image, lsst.afw.image.Mask,
or transposed numpy array (see warning)
- @param[in] skipMask mask of pixels to skip, or None to compare all pixels;
an lsst.afw.image.Mask, lsst.afw.image.Image, or transposed numpy array (see warning); all non-zero pixels are skipped
@param[in] rtol maximum allowed relative tolerance; more info below @param[in] atol maximum allowed absolute tolerance; more info below @param[in] msg exception message prefix; details of the error are appended after “: “
- The images are nearly equal if all pixels obey:
|val1 - val0| <= rtol*|val1| + atol
or, for float types, if nan/inf/-inf pixels match.
@warning the comparison equation is not symmetric, so in rare cases the assertion may give different results depending on which image comes first.
@warning the axes of numpy arrays are transposed with respect to Image and Mask data. Thus for example if image0 and image1 are both lsst.afw.image.ImageD with dimensions (2, 3) and skipMask is a numpy array, then skipMask must have shape (3, 2).
@throw self.failureException (usually AssertionError) if any of the following are true for un-skipped pixels: - non-finite values differ in any way (e.g. one is “nan” and another is not) - finite values differ by too much, as defined by atol and rtol
@throw TypeError if the dimensions of image0, image1 and skipMask do not match, or any are not of a numeric data type.
- assertImagesEqual(**kwds)¶
!Assert that two images are exactly equal, including non-finite values.
All arguments are forwarded to assertAnglesAlmostEqual aside from atol and rtol, which are set to zero.
- assertIn(member, container, msg=None)¶
Just like self.assertTrue(a in b), but with a nicer default message.
- assertIs(expr1, expr2, msg=None)¶
Just like self.assertTrue(a is b), but with a nicer default message.
- assertIsInstance(obj, cls, msg=None)¶
Same as self.assertTrue(isinstance(obj, cls)), with a nicer default message.
- assertIsNone(obj, msg=None)¶
Same as self.assertTrue(obj is None), with a nicer default message.
- assertIsNot(expr1, expr2, msg=None)¶
Just like self.assertTrue(a is not b), but with a nicer default message.
- assertIsNotNone(obj, msg=None)¶
Included for symmetry with assertIsNone.
- assertLess(a, b, msg=None)¶
Just like self.assertTrue(a < b), but with a nicer default message.
- assertLessEqual(a, b, msg=None)¶
Just like self.assertTrue(a <= b), but with a nicer default message.
- assertListEqual(list1, list2, msg=None)¶
A list-specific equality assertion.
- Args:
list1: The first list to compare. list2: The second list to compare. msg: Optional message to use on failure instead of a list of
differences.
- assertLogs(logger=None, level=None)¶
Fail unless a log message of level level or higher is emitted on logger_name or its children. If omitted, level defaults to INFO and logger defaults to the root logger.
This method must be used as a context manager, and will yield a recording object with two attributes:
output
andrecords
. At the end of the context manager, theoutput
attribute will be a list of the matching formatted log messages and therecords
attribute will be a list of the corresponding LogRecord objects.Example:
with self.assertLogs('foo', level='INFO') as cm: logging.getLogger('foo').info('first message') logging.getLogger('foo.bar').error('second message') self.assertEqual(cm.output, ['INFO:foo:first message', 'ERROR:foo.bar:second message'])
- assertMaskedImagesAlmostEqual(maskedImage0, maskedImage1, doImage=True, doMask=True, doVariance=True, skipMask=None, rtol=1e-05, atol=1e-08, msg='Masked images differ')¶
!Assert that two masked images are nearly equal, including non-finite values
- @param[in] testCase unittest.TestCase instance the test is part of;
an object supporting one method: fail(self, msgStr)
- @param[in] maskedImage0 masked image 0 (an lsst.afw.image.MaskedImage or
collection of three transposed numpy arrays: image, mask, variance)
- @param[in] maskedImage1 masked image 1 (an lsst.afw.image.MaskedImage or
collection of three transposed numpy arrays: image, mask, variance)
@param[in] doImage compare image planes if True @param[in] doMask compare mask planes if True @param[in] doVariance compare variance planes if True @param[in] skipMask mask of pixels to skip, or None to compare all pixels;
an lsst.afw.image.Mask, lsst.afw.image.Image, or transposed numpy array; all non-zero pixels are skipped
@param[in] rtol maximum allowed relative tolerance; more info below @param[in] atol maximum allowed absolute tolerance; more info below @param[in] msg exception message prefix; details of the error are appended after “: “
- The mask planes must match exactly. The image and variance planes are nearly equal if all pixels obey:
|val1 - val0| <= rtol*|val1| + atol
or, for float types, if nan/inf/-inf pixels match.
@warning the comparison equation is not symmetric, so in rare cases the assertion may give different results depending on which masked image comes first.
@warning the axes of numpy arrays are transposed with respect to MaskedImage data. Thus for example if maskedImage0 and maskedImage1 are both lsst.afw.image.MaskedImageD with dimensions (2, 3) and skipMask is a numpy array, then skipMask must have shape (3, 2).
@throw self.failureException (usually AssertionError) if any of the following are true for un-skipped pixels: - non-finite image or variance values differ in any way (e.g. one is “nan” and another is not) - finite values differ by too much, as defined by atol and rtol - mask pixels differ at all
@throw TypeError if the dimensions of maskedImage0, maskedImage1 and skipMask do not match, either image or variance plane is not of a numeric data type, either mask plane is not of an integer type (unsigned or signed), or skipMask is not of a numeric data type.
- assertMaskedImagesEqual(**kwds)¶
!Assert that two masked images are exactly equal, including non-finite values.
All arguments are forwarded to assertMaskedImagesAlmostEqual aside from atol and rtol, which are set to zero.
- assertMasksEqual(mask0, mask1, skipMask=None, msg='Masks differ')¶
!Assert that two masks are equal
- @param[in] testCase unittest.TestCase instance the test is part of;
an object supporting one method: fail(self, msgStr)
- @param[in] mask0 mask 0, an lsst.afw.image.Mask, lsst.afw.image.Image,
or transposed numpy array (see warning)
- @param[in] mask1 mask 1, an lsst.afw.image.Mask, lsst.afw.image.Image,
or transposed numpy array (see warning)
- @param[in] skipMask mask of pixels to skip, or None to compare all pixels;
an lsst.afw.image.Mask, lsst.afw.image.Image, or transposed numpy array (see warning); all non-zero pixels are skipped
@param[in] msg exception message prefix; details of the error are appended after “: “
@warning the axes of numpy arrays are transposed with respect to Mask and Image. Thus for example if mask0 and mask1 are both lsst.afw.image.Mask with dimensions (2, 3) and skipMask is a numpy array, then skipMask must have shape (3, 2).
@throw self.failureException (usually AssertionError) if any any un-skipped pixels differ
@throw TypeError if the dimensions of mask0, mask1 and skipMask do not match, or any are not of a numeric data type.
- assertMultiLineEqual(first, second, msg=None)¶
Assert that two multi-line strings are equal.
- assertNoLogs(logger=None, level=None)¶
Fail unless no log messages of level level or higher are emitted on logger_name or its children.
This method must be used as a context manager.
- assertNotAlmostEqual(first, second, places=None, msg=None, delta=None)¶
Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the difference between the two objects is less than the given delta.
Note that decimal places (from zero) are usually not the same as significant digits (measured from the most significant digit).
Objects that are equal automatically fail.
- assertNotAlmostEquals(**kwargs)¶
- assertNotEqual(first, second, msg=None)¶
Fail if the two objects are equal as determined by the ‘!=’ operator.
- assertNotEquals(**kwargs)¶
- assertNotIn(member, container, msg=None)¶
Just like self.assertTrue(a not in b), but with a nicer default message.
- assertNotIsInstance(obj, cls, msg=None)¶
Included for symmetry with assertIsInstance.
- assertNotRegex(text, unexpected_regex, msg=None)¶
Fail the test if the text matches the regular expression.
- assertNotRegexpMatches(**kwargs)¶
- assertPairListsAlmostEqual(list0, list1, maxDiff=1e-07, msg=None)¶
Assert that two lists of Cartesian points are almost equal
Each point can be any indexable pair of two floats, including Point2D or Extent2D, a list or a tuple.
- Parameters:
- testCase
unittest.TestCase
test case the test is part of; an object supporting one method: fail(self, msgStr)
- list0
list
of pairs offloat
list of pairs 0
- list1
list
of pairs offloat
list of pairs 1
- maxDiff
float
maximum radial separation between the two points
- msg
str
additional information for the error message; appended after “: “
- testCase
- Raises:
- AssertionError
Raised if the radial difference is greater than
maxDiff
Notes
Warning
Does not compare types, just values.
- assertPairsAlmostEqual(pair0, pair1, maxDiff=1e-07, msg='Pairs differ')¶
Assert that two Cartesian points are almost equal.
Each point can be any indexable pair of two floats, including Point2D or Extent2D, a list or a tuple.
- Parameters:
- testCase
unittest.TestCase
test case the test is part of; an object supporting one method: fail(self, msgStr)
- pair0pair of
float
pair 0
- pair1pair of
floats
pair 1
- maxDiff
float
maximum radial separation between the two points
- msg
str
exception message prefix; details of the error are appended after “: “
- testCase
- Raises:
- AssertionError
Raised if the radial difference is greater than
maxDiff
Notes
Warning
Does not compare types, just compares values.
- assertRaises(expected_exception, *args, **kwargs)¶
Fail unless an exception of class expected_exception is raised by the callable when invoked with specified positional and keyword arguments. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.
If called with the callable and arguments omitted, will return a context object used like this:
with self.assertRaises(SomeException): do_something()
An optional keyword argument ‘msg’ can be provided when assertRaises is used as a context object.
The context manager keeps a reference to the exception as the ‘exception’ attribute. This allows you to inspect the exception after the assertion:
with self.assertRaises(SomeException) as cm: do_something() the_exception = cm.exception self.assertEqual(the_exception.error_code, 3)
- assertRaisesRegex(expected_exception, expected_regex, *args, **kwargs)¶
Asserts that the message in a raised exception matches a regex.
- Args:
expected_exception: Exception class expected to be raised. expected_regex: Regex (re.Pattern object or string) expected
to be found in error message.
args: Function to be called and extra positional args. kwargs: Extra kwargs. msg: Optional message used in case of failure. Can only be used
when assertRaisesRegex is used as a context manager.
- assertRaisesRegexp(**kwargs)¶
- assertRegex(text, expected_regex, msg=None)¶
Fail the test unless the text matches the regular expression.
- assertRegexpMatches(**kwargs)¶
- assertSchemasEqual(schema1, schema2, flags=31)¶
Assert that two Schemas are equal.
Generates a message from the difference between the schemas; see
diffSchemas()
for more information.- Parameters:
- testCase
Comparison test case that should fail is schemas differ.
- schema1
lsst.afw.table.Schema
First input schema.
- schema2
lsst.afw.table.Schema
Second input schema.
- flags
int
A bitwise OR of
lsst.afw.table.Schema.ComparisonFlags
indicating which features of schema items to compare.
- assertSequenceEqual(seq1, seq2, msg=None, seq_type=None)¶
An equality assertion for ordered sequences (like lists and tuples).
For the purposes of this function, a valid ordered sequence type is one which can be indexed, has a length, and has an equality operator.
- Args:
seq1: The first sequence to compare. seq2: The second sequence to compare. seq_type: The expected datatype of the sequences, or None if no
datatype should be enforced.
- msg: Optional message to use on failure instead of a list of
differences.
- assertSetEqual(set1, set2, msg=None)¶
A set-specific equality assertion.
- Args:
set1: The first set to compare. set2: The second set to compare. msg: Optional message to use on failure instead of a list of
differences.
assertSetEqual uses ducktyping to support different types of sets, and is optimized for sets specifically (parameters must support a difference method).
- assertSpherePointListsAlmostEqual(splist0, splist1, maxSep=Angle(2.7777777777777781e-07, degrees), msg=None)¶
Assert that two lists of
SpherePoint
s are almost equal- Parameters:
- testCase
unittest.TestCase
test case the test is part of; an object supporting one method: fail(self, msgStr)
- splist0
list
oflsst.geom.SpherePoint
list of SpherePoints 0
- splist1
list
oflsst.geom.SpherePoint
list of SpherePoints 1
- maxSep
lsst.geom.Angle
maximum separation
- msg
str
exception message prefix; details of the error are appended after “: “
- testCase
- Raises:
- AssertionError
The SpherePoint lists are not equal.
- assertSpherePointsAlmostEqual(sp0, sp1, maxSep=Angle(2.7777777777777781e-07, degrees), msg='')¶
Assert that two
SpherePoint
s are almost equal- Parameters:
- testCase
unittest.TestCase
test case the test is part of; an object supporting one method: fail(self, msgStr)
- sp0
lsst.geom.SpherePoint
SpherePoint 0
- sp1
lsst.geom.SpherePoint
SpherePoint 1
- maxSep
lsst.geom.Angle
maximum separation
- msg
str
extra information to be printed with any error message
- testCase
- Raises:
- AssertionError
The SpherePoints are not equal.
- assertTransformMapsEqual(map1, map2, **kwds)¶
Compare two TransformMaps.
- assertTrue(expr, msg=None)¶
Check that the expression is true.
- assertTupleEqual(tuple1, tuple2, msg=None)¶
A tuple-specific equality assertion.
- Args:
tuple1: The first tuple to compare. tuple2: The second tuple to compare. msg: Optional message to use on failure instead of a list of
differences.
- assertWarns(expected_warning, *args, **kwargs)¶
Fail unless a warning of class warnClass is triggered by the callable when invoked with specified positional and keyword arguments. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.
If called with the callable and arguments omitted, will return a context object used like this:
with self.assertWarns(SomeWarning): do_something()
An optional keyword argument ‘msg’ can be provided when assertWarns is used as a context object.
The context manager keeps a reference to the first matching warning as the ‘warning’ attribute; similarly, the ‘filename’ and ‘lineno’ attributes give you information about the line of Python code from which the warning was triggered. This allows you to inspect the warning after the assertion:
with self.assertWarns(SomeWarning) as cm: do_something() the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147)
- assertWarnsRegex(expected_warning, expected_regex, *args, **kwargs)¶
Asserts that the message in a triggered warning matches a regexp. Basic functioning is similar to assertWarns() with the addition that only warnings whose messages also match the regular expression are considered successful matches.
- Args:
expected_warning: Warning class expected to be triggered. expected_regex: Regex (re.Pattern object or string) expected
to be found in error message.
args: Function to be called and extra positional args. kwargs: Extra kwargs. msg: Optional message used in case of failure. Can only be used
when assertWarnsRegex is used as a context manager.
- assertWcsAlmostEqualOverBBox(wcs0, wcs1, bbox, maxDiffSky=Angle(2.7777777777777779e-06, degrees), maxDiffPix=0.01, nx=5, ny=5, msg='WCSs differ')¶
Assert that two
WCS
are almost equal over a grid of pixel positionsCompare pixelToSky and skyToPixel for two WCS over a rectangular grid of pixel positions. If the WCS are too divergent at any point, call testCase.fail; the message describes the largest error measured in pixel coordinates (if sky to pixel error was excessive) and sky coordinates (if pixel to sky error was excessive) across the entire pixel grid.
- Parameters:
- testCase
unittest.TestCase
test case the test is part of; an object supporting one method: fail(self, msgStr)
- wcs0
lsst.afw.geom.SkyWcs
WCS 0
- wcs1
lsst.afw.geom.SkyWcs
WCS 1
- bbox
lsst.geom.Box2I
orlsst.geom.Box2D
boundaries of pixel grid over which to compare the WCSs
- maxDiffSky
lsst.geom.Angle
maximum separation between sky positions computed using Wcs.pixelToSky
- maxDiffPix
float
maximum separation between pixel positions computed using Wcs.skyToPixel
- nx
int
number of points in x for the grid of pixel positions
- ny
int
number of points in y for the grid of pixel positions
- msg
str
exception message prefix; details of the error are appended after “: “
- testCase
- assert_(**kwargs)¶
- compare2DFunctions(func1, func2, minVal=-10, maxVal=None, nVal=5)¶
Compare two Point2D(Point2D) functions by evaluating them over a range of values.
- countTestCases()¶
- debug()¶
Run the test without collecting errors in a TestResult
- defaultTestResult()¶
- classmethod doClassCleanups()¶
Execute all class cleanup functions. Normally called for you after tearDownClass.
- doCleanups()¶
Execute all cleanup functions. Normally called for you after tearDown.
- fail(msg=None)¶
Fail immediately, with the given message.
- failIf(**kwargs)¶
- failIfAlmostEqual(**kwargs)¶
- failIfEqual(**kwargs)¶
- failUnless(**kwargs)¶
- failUnlessAlmostEqual(**kwargs)¶
- failUnlessEqual(**kwargs)¶
- failUnlessRaises(**kwargs)¶
- abstract classmethod getInstrument()¶
Retrieve the
lsst.obs.base.Instrument
class for this instrument.- Returns:
- instrument
lsst.obs.base.Instrument
The class associated with this instrument.
- instrument
- id()¶
- makeEndpoints()¶
Generate a representative sample of
Endpoints
.- Parameters:
- testCase
unittest.TestCase
test case the test is part of; an object supporting one method: fail(self, msgStr)
- testCase
- Returns:
- endpoints
list
List of endpoints with enough diversity to exercise
Endpoint
-related code. Each invocation of this method shall return independent objects.
- endpoints
- run(result=None)¶
- setUp()¶
Hook method for setting up the test fixture before exercising it.
- classmethod setUpClass()¶
Hook method for setting up class fixture before running tests in the class.
- shortDescription()¶
Returns a one-line description of the test, or None if no description has been provided.
The default implementation of this method returns the first line of the specified test method’s docstring.
- skipTest(reason)¶
Skip this test.
- subTest(msg=<object object>, **params)¶
Return a context manager that will return the enclosed block of code in a subtest identified by the optional message and keyword parameters. A failure in the subtest marks the test case as failed but resumes execution at the end of the enclosed block, allowing further test code to be executed.
- tearDown()¶
Hook method for deconstructing the test fixture after testing it.
- classmethod tearDownClass()¶
Hook method for deconstructing the class fixture after running all tests in the class.