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

37

38

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 TestWinMap(MappingTestCase): 

 

def test_WinMap(self): 

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

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

pred_shift = [1.0, -0.5] 

pred_zoom = 2.0 

self.assertIsInstance(winmap, ast.WinMap) 

self.assertEqual(winmap.nIn, 2) 

self.assertEqual(winmap.nOut, 2) 

 

self.checkBasicSimplify(winmap) 

self.checkCopy(winmap) 

 

indata = np.array([ 

[0.0, 0.5, 1.0], 

[-3.0, 1.5, 0.13], 

], dtype=float) 

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

outdata = winmap.applyForward(indata) 

assert_allclose(outdata, pred_outdata) 

 

self.checkRoundTrip(winmap, indata) 

self.checkMappingPersistence(winmap, indata) 

 

 

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

unittest.main()