Hide keyboard shortcuts

Hot-keys 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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

from __future__ import absolute_import, division, print_function 

import unittest 

 

import numpy as np 

from numpy.testing import assert_allclose 

 

import astshim as ast 

from astshim.test import MappingTestCase 

 

 

class TestShiftMap(MappingTestCase): 

 

def test_ShiftMapBasics(self): 

offset = np.array([1.1, -2.2, 3.3]) 

shiftmap = ast.ShiftMap(offset) 

self.assertEqual(shiftmap.className, "ShiftMap") 

self.assertEqual(shiftmap.nIn, 3) 

self.assertEqual(shiftmap.nOut, 3) 

 

self.checkBasicSimplify(shiftmap) 

self.checkCopy(shiftmap) 

 

indata = np.array([ 

[1.1, -43.5], 

[2.2, 1309.31], 

[3.3, 0.005], 

]) 

outdata = shiftmap.applyForward(indata) 

pred_outdata = (indata.T + offset).T 

assert_allclose(outdata, pred_outdata) 

self.checkRoundTrip(shiftmap, indata) 

self.checkMappingPersistence(shiftmap, indata) 

 

 

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

unittest.main()