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
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
1import sys
2import unittest
4from numpy.testing import assert_allclose
6import astshim as ast
7from astshim.test import MappingTestCase
10class TestLutMap(MappingTestCase):
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)
19 self.checkBasicSimplify(lutmap)
20 self.checkCopy(lutmap)
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)
33 self.assertEqual(lutmap.lutInterp, 0)
34 self.assertAlmostEqual(lutmap.lutEpsilon,
35 sys.float_info.epsilon, delta=1e-18)
37 self.checkMappingPersistence(lutmap, indata)
40if __name__ == "__main__": 40 ↛ 41line 40 didn't jump to line 41, because the condition on line 40 was never true
41 unittest.main()