Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Amend some error types #63

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nitransforms/linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def from_filename(cls, filename, fmt='X5',
matrix = struct.to_ras(reference=reference, moving=moving)
if cls == Affine:
if np.shape(matrix)[0] != 1:
raise TypeError(
raise ValueError(
'Cannot load transform array "%s"' % filename)
matrix = matrix[0]
return cls(matrix, reference=reference)
Expand Down
2 changes: 1 addition & 1 deletion nitransforms/nonlinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, field, reference=None):

ndim = self._field.ndim - 1
if self._field.shape[-1] != ndim:
raise ValueError(
raise TypeError(
'The number of components of the displacements (%d) does not '
'the number of dimensions (%d)' % (self._field.shape[-1], ndim))

Expand Down
6 changes: 3 additions & 3 deletions nitransforms/tests/test_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ def test_linear_typeerrors1(matrix):
ntl.Affine(matrix)


def test_linear_typeerrors2(data_path):
def test_linear_valueerror0(data_path):
"""Exercise errors in Affine creation."""
with pytest.raises(TypeError):
with pytest.raises(ValueError):
ntl.Affine.from_filename(data_path / 'itktflist.tfm', fmt='itk')


def test_linear_valueerror():
def test_linear_valueerror1():
"""Exercise errors in Affine creation."""
with pytest.raises(ValueError):
ntl.Affine(np.ones((4, 4)))
Expand Down
2 changes: 1 addition & 1 deletion nitransforms/tests/test_nonlinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_itk_disp_load(size):
@pytest.mark.parametrize('size', [(20, 20, 20), (20, 20, 20, 1, 3)])
def test_displacements_bad_sizes(size):
"""Checks field sizes."""
with pytest.raises(ValueError):
with pytest.raises(TypeError):
DisplacementsFieldTransform(
nb.Nifti1Image(np.zeros(size), None, None))

Expand Down