Coverage for tests/test_lutMap.py: 41%

Shortcuts on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

23 statements  

1import sys 

2import unittest 

3 

4from numpy.testing import assert_allclose 

5 

6import astshim as ast 

7from astshim.test import MappingTestCase 

8 

9 

10class TestLutMap(MappingTestCase): 

11 

12 def test_LutMap(self): 

13 offset = 1.0 

14 divisor = 0.5 

15 lutmap = ast.LutMap([1, 2, 4, 8], offset, divisor) 

16 self.assertEqual(lutmap.className, "LutMap") 

17 self.assertEqual(lutmap.nOut, 1) 

18 

19 self.checkBasicSimplify(lutmap) 

20 self.checkCopy(lutmap) 

21 

22 indata, pred_outdata = zip(*[ 

23 (1.0, 1.0), # (1 - 1)/0.5 = 0 -> 1 

24 (1.25, 1.5), # (1.25 - 1)/0.5 = 0.5 -> 1.5 by interpolation 

25 (1.5, 2.0), # (1.5 - 1)/0.5 = 1 -> 2 

26 (2.0, 4.0), # (2 - 1)/0.5 = 2 -> 4 

27 (2.5, 8.0), # (2.5 - 1)/0.5 = 3 -> 8 

28 ]) 

29 outdata = lutmap.applyForward(indata) 

30 assert_allclose(outdata, pred_outdata) 

31 self.checkRoundTrip(lutmap, indata) 

32 

33 self.assertEqual(lutmap.lutInterp, 0) 

34 self.assertAlmostEqual(lutmap.lutEpsilon, 

35 sys.float_info.epsilon, delta=1e-18) 

36 

37 self.checkMappingPersistence(lutmap, indata) 

38 

39 

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

41 unittest.main()