|
9 | 9 | from nose.tools import assert_equal, assert_raises
|
10 | 10 | import numpy.testing as np_test
|
11 | 11 | from numpy.testing import assert_almost_equal, assert_array_equal
|
| 12 | +from numpy.testing import assert_array_almost_equal |
12 | 13 | from matplotlib.transforms import Affine2D, BlendedGenericTransform, Bbox
|
13 | 14 | from matplotlib.path import Path
|
14 | 15 | from matplotlib.scale import LogScale
|
@@ -535,6 +536,22 @@ def test_nan_overlap():
|
535 | 536 | assert not a.overlaps(b)
|
536 | 537 |
|
537 | 538 |
|
| 539 | +def test_transform_angles(): |
| 540 | + t = mtrans.Affine2D() # Identity transform |
| 541 | + angles = np.array([20, 45, 60]) |
| 542 | + points = np.array([[0, 0], [1, 1], [2, 2]]) |
| 543 | + |
| 544 | + # Identity transform does not change angles |
| 545 | + new_angles = t.transform_angles(angles, points) |
| 546 | + assert_array_almost_equal(angles, new_angles) |
| 547 | + |
| 548 | + # points missing a 2nd dimension |
| 549 | + assert_raises(ValueError, t.transform_angles, angles, points[0:2, 0:1]) |
| 550 | + |
| 551 | + # Number of angles != Number of points |
| 552 | + assert_raises(ValueError, t.transform_angles, angles, points[0:2, :]) |
| 553 | + |
| 554 | + |
538 | 555 | if __name__ == '__main__':
|
539 | 556 | import nose
|
540 | 557 | nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
|
0 commit comments