Coverage for tests/test_transforms.py: 48%

34 statements  

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

1# 

2# Developed for the LSST Data Management System. 

3# This product includes software developed by the LSST Project 

4# (https://www.lsst.org). 

5# See the COPYRIGHT file at the top-level directory of this distribution 

6# for details of code ownership. 

7# 

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

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

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

11# (at your option) any later version. 

12# 

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

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

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

16# GNU General Public License for more details. 

17# 

18# You should have received a copy of the GNU General Public License 

19# along with this program. If not, see <https://www.gnu.org/licenses/>. 

20# 

21 

22import unittest 

23 

24import numpy as np 

25 

26import lsst.utils.tests 

27from lsst.geom import LinearTransform, AffineTransform, Point2D, Extent2D 

28 

29 

30class TransformTests: 

31 

32 def testVectorization(self): 

33 x1 = np.random.randn(4, 3) 

34 y1 = np.random.randn(4, 3) 

35 x2, y2 = self.transform(x1, y1) 

36 self.assertEqual(x1.shape, x2.shape) 

37 self.assertEqual(x2.shape, y2.shape) 

38 for i in range(4): 

39 for j in range(3): 

40 x3, y3 = self.transform(Point2D(x1[i, j], y1[i, j])) 

41 self.assertAlmostEqual(x3, x2[i, j], 15) 

42 self.assertAlmostEqual(y3, y2[i, j], 15) 

43 

44 

45class LinearTransformTestCase(lsst.utils.tests.TestCase, TransformTests): 

46 

47 def setUp(self): 

48 np.random.seed(5) 

49 matrix = np.random.randn(2, 2) 

50 self.transform = LinearTransform(matrix) 

51 

52 

53class AffineTransformTestCase(lsst.utils.tests.TestCase, TransformTests): 

54 

55 def setUp(self): 

56 np.random.seed(6) 

57 matrix = np.random.randn(2, 2) 

58 vector = np.random.randn(2) 

59 self.transform = AffineTransform(LinearTransform(matrix), Extent2D(vector)) 

60 

61 

62class MemoryTester(lsst.utils.tests.MemoryTestCase): 

63 pass 

64 

65 

66def setup_module(module): 

67 lsst.utils.tests.init() 

68 

69 

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

71 lsst.utils.tests.init() 

72 unittest.main()