Coverage for tests/test_winMap.py: 36%

23 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-21 03:01 -0700

1import unittest 

2 

3import numpy as np 

4from numpy.testing import assert_allclose 

5 

6import astshim as ast 

7from astshim.test import MappingTestCase 

8 

9 

10class TestWinMap(MappingTestCase): 

11 

12 def test_WinMap(self): 

13 # a map describing a shift of [1.0, -0.5] followed by a zoom of 2 

14 winmap = ast.WinMap([0, 0], [1, 1], [1, -0.5], [3, 1.5]) 

15 pred_shift = [1.0, -0.5] 

16 pred_zoom = 2.0 

17 self.assertIsInstance(winmap, ast.WinMap) 

18 self.assertEqual(winmap.nIn, 2) 

19 self.assertEqual(winmap.nOut, 2) 

20 

21 self.checkBasicSimplify(winmap) 

22 self.checkCopy(winmap) 

23 

24 indata = np.array([ 

25 [0.0, 0.5, 1.0], 

26 [-3.0, 1.5, 0.13], 

27 ], dtype=float) 

28 pred_outdata = (indata.T * pred_zoom + pred_shift).T 

29 outdata = winmap.applyForward(indata) 

30 assert_allclose(outdata, pred_outdata) 

31 

32 self.checkRoundTrip(winmap, indata) 

33 self.checkMappingPersistence(winmap, indata) 

34 

35 

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

37 unittest.main()