Skip to content

Commit da44997

Browse files
committed
tst: add one more test
1 parent 39ce629 commit da44997

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

nitransforms/linear.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ def __init__(self, matrix=None, reference=None):
6666
raise TypeError('Matrix is not square.')
6767
self._matrix = matrix
6868

69+
if np.any(self._matrix[3, :] != (0, 0, 0, 1)):
70+
raise ValueError("Matrix does not represent a valid transform.")
71+
6972
def __eq__(self, other):
7073
"""
7174
Overload equals operator.

nitransforms/tests/test_linear.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ def test_linear_typeerrors2(data_path):
4848
ntl.Affine.from_filename(data_path / 'itktflist.tfm', fmt='itk')
4949

5050

51+
def test_linear_valueerror():
52+
"""Exercise errors in Affine creation."""
53+
with pytest.raises(ValueError):
54+
ntl.Affine(np.ones((4, 4)))
55+
56+
5157
def test_loadsave_itk(tmp_path, data_path):
5258
"""Test idempotency."""
5359
ref_file = data_path / 'someones_anatomy.nii.gz'

0 commit comments

Comments
 (0)