Coverage for tests/test_measurementFramework.py: 48%

34 statements  

« prev     ^ index     » next       coverage.py v6.4.1, created at 2022-06-17 02:25 -0700

1# 

2# LSST Data Management System 

3# 

4# Copyright 2008-2017 AURA/LSST. 

5# 

6# This product includes software developed by the 

7# LSST Project (http://www.lsst.org/). 

8# 

9# This program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the LSST License Statement and 

20# the GNU General Public License along with this program. If not, 

21# see <https://www.lsstcorp.org/LegalNotices/>. 

22# 

23import unittest 

24 

25import lsst.geom 

26import lsst.afw.geom 

27import lsst.utils.tests 

28import lsst.meas.base.tests 

29from lsst.meas.base.tests import AlgorithmTestCase 

30from lsst.meas.extensions.simpleShape import SimpleShapeResultKey 

31 

32 

33class SimpleShapeMFTestCase(AlgorithmTestCase, lsst.utils.tests.TestCase): 

34 

35 def setUp(self): 

36 self.bbox = lsst.geom.Box2I(lsst.geom.Point2I(-20, -30), 

37 lsst.geom.Extent2I(240, 160)) 

38 self.dataset = lsst.meas.base.tests.TestDataset(self.bbox) 

39 self.dataset.addSource(100000.0, lsst.geom.Point2D(149.9, 50.3), 

40 lsst.afw.geom.ellipses.Quadrupole(8, 9, 3)) 

41 

42 self.expectedKeySet = set(['ext_simpleShape_SimpleShape_IxErr', 

43 'ext_simpleShape_SimpleShape_Ix_Iy_Cov', 

44 'ext_simpleShape_SimpleShape_IxxErr', 

45 'ext_simpleShape_SimpleShape_Ixx_Ix_Cov', 

46 'ext_simpleShape_SimpleShape_Ixx_Ixy_Cov', 

47 'ext_simpleShape_SimpleShape_Ixx_Iy_Cov', 

48 'ext_simpleShape_SimpleShape_Ixx_Iyy_Cov', 

49 'ext_simpleShape_SimpleShape_IxyErr', 

50 'ext_simpleShape_SimpleShape_Ixy_Ix_Cov', 

51 'ext_simpleShape_SimpleShape_Ixy_Iy_Cov', 

52 'ext_simpleShape_SimpleShape_IyErr', 

53 'ext_simpleShape_SimpleShape_IyyErr', 

54 'ext_simpleShape_SimpleShape_Iyy_Ix_Cov', 

55 'ext_simpleShape_SimpleShape_Iyy_Ixy_Cov', 

56 'ext_simpleShape_SimpleShape_Iyy_Iy_Cov', 

57 'ext_simpleShape_SimpleShape_flag', 

58 'ext_simpleShape_SimpleShape_x', 

59 'ext_simpleShape_SimpleShape_xx', 

60 'ext_simpleShape_SimpleShape_xy', 

61 'ext_simpleShape_SimpleShape_y', 

62 'ext_simpleShape_SimpleShape_yy']) 

63 

64 def tearDown(self): 

65 del self.bbox 

66 del self.dataset 

67 

68 def testKeys(self): 

69 """ 

70 Test that Simple shape will run as a plugin, a functor key can be 

71 created, and result object can be created. Testing of the algorithm 

72 is left to testSimpleShape.py 

73 """ 

74 

75 task = self.makeSingleFrameMeasurementTask("ext_simpleShape_SimpleShape") 

76 exposure, catalog = self.dataset.realize(10.0, task.schema, randomSeed=0) 

77 # Check the keys are in the schema 

78 foundKeySet = set(catalog.schema.getNames()) & self.expectedKeySet 

79 missingKeySet = self.expectedKeySet - foundKeySet 

80 self.assertEqual(missingKeySet, set()) 

81 

82 # check that SimpleShapeResultKey can be created and that it returns a results object 

83 key = SimpleShapeResultKey(catalog.schema["ext_simpleShape_SimpleShape"]) 

84 task.run(catalog, exposure) 

85 

86 result = catalog[0].get(key) 

87 for attr in ("center", "ellipse", "covariance", "getFlag"): 

88 self.assertTrue(hasattr(result, attr), "Result Object missing {}".format(attr)) 

89 

90 

91class TestMemory(lsst.utils.tests.MemoryTestCase): 

92 pass 

93 

94 

95def setup_module(module): 

96 lsst.utils.tests.init() 

97 

98 

99if __name__ == "__main__": 99 ↛ 100line 99 didn't jump to line 100, because the condition on line 99 was never true

100 lsst.utils.tests.init() 

101 unittest.main()