Coverage for tests/test_transform.py: 34%
47 statements
« prev ^ index » next coverage.py v6.4.4, created at 2022-08-30 02:37 -0700
« prev ^ index » next coverage.py v6.4.4, created at 2022-08-30 02:37 -0700
1"""
2LSST Data Management System
3See COPYRIGHT file at the top of the source tree.
5This product includes software developed by the
6LSST Project (http://www.lsst.org/).
8This program is free software: you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation, either version 3 of the License, or
11(at your option) any later version.
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
18You should have received a copy of the LSST License Statement and
19the GNU General Public License along with this program. If not,
20see <http://www.lsstcorp.org/LegalNotices/>.
21"""
22import unittest
24from numpy.testing import assert_allclose
25import astshim as ast
26from astshim.test import makeForwardPolyMap
28import lsst.utils.tests
29import lsst.afw.geom as afwGeom
30from lsst.afw.geom.testUtils import TransformTestBaseClass
33class TransformTestCase(TransformTestBaseClass):
35 def testTransforms(self):
36 for fromName in self.endpointPrefixes:
37 for toName in self.endpointPrefixes:
38 self.checkTransformFromMapping(fromName, toName)
39 self.checkTransformFromFrameSet(fromName, toName)
40 self.checkInverted(fromName, toName)
41 self.checkGetJacobian(fromName, toName)
42 for midName in self.endpointPrefixes:
43 self.checkThen(fromName, midName, toName)
45 def testMappingIndependence(self):
46 """Test that the mapping returned by getMapping is independent of the contained mapping
47 """
48 initialMapping = ast.ZoomMap(2, 1.5)
49 initialIdent = "Initial Ident"
50 initialMapping.ident = initialIdent
51 transform = afwGeom.TransformGenericToGeneric(initialMapping)
52 extractedMapping = transform.getMapping()
53 extractedMapping.ident = "Extracted Ident"
54 self.assertEqual(initialIdent, transform.getMapping().ident)
56 def testThen(self):
57 """Test that Transform.then behaves as expected
58 """
59 transform1 = afwGeom.TransformGenericToGeneric(
60 makeForwardPolyMap(2, 3))
61 transform2 = afwGeom.TransformGenericToGeneric(
62 makeForwardPolyMap(3, 4))
64 for simplify in (False, True):
65 merged = transform1.then(transform2, simplify=simplify)
67 inPoint = self.makeRawPointData(2)
68 assert_allclose(merged.applyForward(inPoint),
69 transform2.applyForward(transform1.applyForward(inPoint)))
71 def testThenChaining(self):
72 """Test that the order of chaining Transform.then does not matter
74 Test that A.then(B.then(C)) gives the same transformation as
75 (A.then(B)).then(C)
76 Internal details may differ, but the mathematical result of the two
77 transforms should be the same.
78 """
79 transform1 = afwGeom.TransformGenericToGeneric(
80 makeForwardPolyMap(2, 3))
81 transform2 = afwGeom.TransformGenericToGeneric(
82 makeForwardPolyMap(3, 4))
83 transform3 = afwGeom.TransformGenericToGeneric(
84 makeForwardPolyMap(4, 1))
86 merged1 = transform1.then(transform2.then(transform3))
87 merged2 = transform1.then(transform2).then(transform3)
89 inPoint = self.makeRawPointData(2)
90 assert_allclose(merged1.applyForward(inPoint),
91 merged2.applyForward(inPoint))
94class MemoryTester(lsst.utils.tests.MemoryTestCase):
95 pass
98def setup_module(module):
99 lsst.utils.tests.init()
102if __name__ == "__main__": 102 ↛ 103line 102 didn't jump to line 103, because the condition on line 102 was never true
103 lsst.utils.tests.init()
104 unittest.main()