diff --git a/nitransforms/linear.py b/nitransforms/linear.py index 72a6f85e..63103227 100644 --- a/nitransforms/linear.py +++ b/nitransforms/linear.py @@ -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) diff --git a/nitransforms/nonlinear.py b/nitransforms/nonlinear.py index d2315775..c436e8e4 100644 --- a/nitransforms/nonlinear.py +++ b/nitransforms/nonlinear.py @@ -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)) diff --git a/nitransforms/tests/test_linear.py b/nitransforms/tests/test_linear.py index 4eaf673d..8028bb0a 100644 --- a/nitransforms/tests/test_linear.py +++ b/nitransforms/tests/test_linear.py @@ -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))) diff --git a/nitransforms/tests/test_nonlinear.py b/nitransforms/tests/test_nonlinear.py index 048aedac..0d3b3aeb 100644 --- a/nitransforms/tests/test_nonlinear.py +++ b/nitransforms/tests/test_nonlinear.py @@ -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))