Skip to content

Commit e06d63e

Browse files
committed
TEST: Test deprecation, ornt_transform error condition
1 parent 559f93e commit e06d63e

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

nibabel/tests/test_orientations.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99
''' Testing for orientations module '''
1010

1111
import numpy as np
12+
import warnings
1213

1314
from nose.tools import assert_true, assert_equal, assert_raises
1415

1516
from numpy.testing import assert_array_equal
1617

1718
from ..orientations import (io_orientation, ornt_transform, inv_ornt_aff,
1819
flip_axis, apply_orientation, OrientationError,
19-
ornt2axcodes, axcodes2ornt, aff2axcodes)
20+
ornt2axcodes, axcodes2ornt, aff2axcodes,
21+
orientation_affine)
2022

2123
from ..affines import from_matvec, to_matvec
2224

@@ -245,6 +247,12 @@ def test_ornt_transform():
245247
[[0, 1, 1], [1, 1, 1]],
246248
[[0, 1, 1], [1, 1, 1]])
247249

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+
248256

249257
def test_ornt2axcodes():
250258
# Recoding orientation to axis codes
@@ -347,3 +355,13 @@ def test_inv_ornt_aff():
347355
# io_orientations test)
348356
assert_raises(OrientationError, inv_ornt_aff,
349357
[[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

Comments
 (0)