Skip to content

Commit

Permalink
NumPy changed what exception is raised for ufunc-call with wrong numb…
Browse files Browse the repository at this point in the history
…er of arguments.

The ODL tests checked against the previously raised `ValueError`, but in newer
versions `TypeError` is raised instead, which these tests could not handle.
  • Loading branch information
leftaroundabout committed Aug 29, 2024
1 parent 3528685 commit d664f5f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions odl/test/discr/discr_space_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,9 @@ def test_ufunc_corner_cases(odl_tspace_impl):

# --- UFuncs with nin = 1, nout = 1 --- #

with pytest.raises(ValueError):
wrong_argcount_error = ValueError if np.__version__<"1.21" else TypeError

with pytest.raises(wrong_argcount_error):
# Too many arguments
x.__array_ufunc__(np.sin, '__call__', x, np.ones((2, 3)))

Expand Down Expand Up @@ -938,7 +940,7 @@ def test_ufunc_corner_cases(odl_tspace_impl):

# --- UFuncs with nin = 2, nout = 1 --- #

with pytest.raises(ValueError):
with pytest.raises(wrong_argcount_error):
# Too few arguments
x.__array_ufunc__(np.add, '__call__', x)

Expand Down
6 changes: 4 additions & 2 deletions odl/test/space/tensors_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,9 @@ def test_ufunc_corner_cases(odl_tspace_impl):

# --- Ufuncs with nin = 1, nout = 1 --- #

with pytest.raises(ValueError):
wrong_argcount_error = ValueError if np.__version__<"1.21" else TypeError

with pytest.raises(wrong_argcount_error):
# Too many arguments
x.__array_ufunc__(np.sin, '__call__', x, np.ones((2, 3)))

Expand Down Expand Up @@ -1573,7 +1575,7 @@ def test_ufunc_corner_cases(odl_tspace_impl):

# --- Ufuncs with nin = 2, nout = 1 --- #

with pytest.raises(ValueError):
with pytest.raises(wrong_argcount_error):
# Too few arguments
x.__array_ufunc__(np.add, '__call__', x)

Expand Down

0 comments on commit d664f5f

Please sign in to comment.