Coverage for tests/test_imageArithmetic.py: 12%

66 statements  

« prev     ^ index     » next       coverage.py v7.5.1, created at 2024-05-16 03:19 -0700

1# LSST Data Management System 

2# Copyright 2019 LSST Corporation. 

3# 

4# This product includes software developed by the 

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

6# 

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

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

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

10# (at your option) any later version. 

11# 

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

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

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

15# GNU General Public License for more details. 

16# 

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

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

19# see <http://www.lsstcorp.org/LegalNotices/>. 

20 

21import unittest 

22 

23import lsst.utils.tests 

24from lsst.geom import Box2I, Point2I, Extent2I 

25import lsst.afw.image 

26 

27 

28class ImageArithmeticTestCase(lsst.utils.tests.TestCase): 

29 def setUp(self): 

30 self.bbox = Box2I(Point2I(12345, 56789), Extent2I(12, 34)) 

31 

32 def tearDown(self): 

33 del self.bbox 

34 

35 def testImage(self): 

36 for cls in (lsst.afw.image.ImageI, 

37 lsst.afw.image.ImageL, 

38 lsst.afw.image.ImageU, 

39 lsst.afw.image.ImageF, 

40 lsst.afw.image.ImageD, 

41 lsst.afw.image.DecoratedImageI, 

42 lsst.afw.image.DecoratedImageL, 

43 lsst.afw.image.DecoratedImageU, 

44 lsst.afw.image.DecoratedImageF, 

45 lsst.afw.image.DecoratedImageD, 

46 lsst.afw.image.MaskedImageI, 

47 lsst.afw.image.MaskedImageL, 

48 lsst.afw.image.MaskedImageU, 

49 lsst.afw.image.MaskedImageF, 

50 lsst.afw.image.MaskedImageD, 

51 lsst.afw.image.ExposureI, 

52 lsst.afw.image.ExposureL, 

53 lsst.afw.image.ExposureU, 

54 lsst.afw.image.ExposureF, 

55 lsst.afw.image.ExposureD, 

56 ): 

57 im1 = cls(self.bbox) 

58 im2 = cls(self.bbox) 

59 

60 # Image and image 

61 with self.assertRaises(NotImplementedError): 

62 im1 + im2 

63 with self.assertRaises(NotImplementedError): 

64 im1 - im2 

65 with self.assertRaises(NotImplementedError): 

66 im1 * im2 

67 with self.assertRaises(NotImplementedError): 

68 im1 / im2 

69 

70 # Image and scalar 

71 with self.assertRaises(NotImplementedError): 

72 im1 + 12345 

73 with self.assertRaises(NotImplementedError): 

74 im1 - 12345 

75 with self.assertRaises(NotImplementedError): 

76 im1 * 12345 

77 with self.assertRaises(NotImplementedError): 

78 im1 / 12345 

79 

80 # Scalar and image 

81 with self.assertRaises(NotImplementedError): 

82 54321 + im2 

83 with self.assertRaises(NotImplementedError): 

84 54321 - im2 

85 with self.assertRaises(NotImplementedError): 

86 54321 * im2 

87 with self.assertRaises(NotImplementedError): 

88 54321 / im2 

89 

90 def testMask(self): 

91 for cls in (lsst.afw.image.MaskX, 

92 ): 

93 im1 = cls(self.bbox) 

94 im2 = cls(self.bbox) 

95 

96 # Image and image 

97 with self.assertRaises(NotImplementedError): 

98 im1 | im2 

99 with self.assertRaises(NotImplementedError): 

100 im1 & im2 

101 with self.assertRaises(NotImplementedError): 

102 im1 ^ im2 

103 

104 # Image and scalar 

105 with self.assertRaises(NotImplementedError): 

106 im1 | 12345 

107 with self.assertRaises(NotImplementedError): 

108 im1 & 12345 

109 with self.assertRaises(NotImplementedError): 

110 im1 ^ 12345 

111 

112 # Scalar and image 

113 with self.assertRaises(NotImplementedError): 

114 54321 | im2 

115 with self.assertRaises(NotImplementedError): 

116 54321 & im2 

117 with self.assertRaises(NotImplementedError): 

118 54321 ^ im2 

119 

120 

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

122 pass 

123 

124 

125def setup_module(module): 

126 lsst.utils.tests.init() 

127 

128 

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

130 lsst.utils.tests.init() 

131 unittest.main()