|
| 1 | +from nose.tools import assert_equal |
| 2 | +from numpy.testing import assert_almost_equal |
| 3 | +from matplotlib.transforms import Affine2D |
| 4 | +import numpy as np |
| 5 | + |
| 6 | +def test_Affine2D_from_values(): |
| 7 | + points = [ [0,0], |
| 8 | + [10,20], |
| 9 | + [-1,0], |
| 10 | + ] |
| 11 | + |
| 12 | + t = Affine2D.from_values(1,0,0,0,0,0) |
| 13 | + actual = t.transform(points) |
| 14 | + expected = np.array( [[0,0],[10,0],[-1,0]] ) |
| 15 | + assert_almost_equal(actual,expected) |
| 16 | + |
| 17 | + t = Affine2D.from_values(0,2,0,0,0,0) |
| 18 | + actual = t.transform(points) |
| 19 | + expected = np.array( [[0,0],[0,20],[0,-2]] ) |
| 20 | + assert_almost_equal(actual,expected) |
| 21 | + |
| 22 | + t = Affine2D.from_values(0,0,3,0,0,0) |
| 23 | + actual = t.transform(points) |
| 24 | + expected = np.array( [[0,0],[60,0],[0,0]] ) |
| 25 | + assert_almost_equal(actual,expected) |
| 26 | + |
| 27 | + t = Affine2D.from_values(0,0,0,4,0,0) |
| 28 | + actual = t.transform(points) |
| 29 | + expected = np.array( [[0,0],[0,80],[0,0]] ) |
| 30 | + assert_almost_equal(actual,expected) |
| 31 | + |
| 32 | + t = Affine2D.from_values(0,0,0,0,5,0) |
| 33 | + actual = t.transform(points) |
| 34 | + expected = np.array( [[5,0],[5,0],[5,0]] ) |
| 35 | + assert_almost_equal(actual,expected) |
| 36 | + |
| 37 | + t = Affine2D.from_values(0,0,0,0,0,6) |
| 38 | + actual = t.transform(points) |
| 39 | + expected = np.array( [[0,6],[0,6],[0,6]] ) |
| 40 | + assert_almost_equal(actual,expected) |
0 commit comments