|
9 | 9 | ''' Testing for orientations module '''
|
10 | 10 |
|
11 | 11 | import numpy as np
|
| 12 | +import warnings |
12 | 13 |
|
13 | 14 | from nose.tools import assert_true, assert_equal, assert_raises
|
14 | 15 |
|
15 | 16 | from numpy.testing import assert_array_equal
|
16 | 17 |
|
17 | 18 | from ..orientations import (io_orientation, ornt_transform, inv_ornt_aff,
|
18 | 19 | flip_axis, apply_orientation, OrientationError,
|
19 |
| - ornt2axcodes, axcodes2ornt, aff2axcodes) |
| 20 | + ornt2axcodes, axcodes2ornt, aff2axcodes, |
| 21 | + orientation_affine) |
20 | 22 |
|
21 | 23 | from ..affines import from_matvec, to_matvec
|
22 | 24 |
|
@@ -245,6 +247,12 @@ def test_ornt_transform():
|
245 | 247 | [[0, 1, 1], [1, 1, 1]],
|
246 | 248 | [[0, 1, 1], [1, 1, 1]])
|
247 | 249 |
|
| 250 | + # Target axes must exist in source |
| 251 | + assert_raises(ValueError, |
| 252 | + ornt_transform, |
| 253 | + [[0, 1], [1, 1], [1, 1]], |
| 254 | + [[0, 1], [1, 1], [2, 1]]) |
| 255 | + |
248 | 256 |
|
249 | 257 | def test_ornt2axcodes():
|
250 | 258 | # Recoding orientation to axis codes
|
@@ -347,3 +355,13 @@ def test_inv_ornt_aff():
|
347 | 355 | # io_orientations test)
|
348 | 356 | assert_raises(OrientationError, inv_ornt_aff,
|
349 | 357 | [[0, 1], [1, -1], [np.nan, np.nan]], (3, 4, 5))
|
| 358 | + |
| 359 | + |
| 360 | +def test_orientation_affine_deprecation(): |
| 361 | + aff1 = inv_ornt_aff([[0, 1], [1, -1], [2, 1]], (3, 4, 5)) |
| 362 | + with warnings.catch_warnings(record=True) as warns: |
| 363 | + warnings.simplefilter('always') |
| 364 | + aff2 = orientation_affine([[0, 1], [1, -1], [2, 1]], (3, 4, 5)) |
| 365 | + assert_equal(len(warns), 1) |
| 366 | + assert_equal(warns[0].category, DeprecationWarning) |
| 367 | + assert_array_equal(aff1, aff2) |
0 commit comments