Skip to content

Commit a72a1b6

Browse files
committed
TEST: Suppress new numpy warning on nan-to-int cast
1 parent f469c68 commit a72a1b6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

nibabel/tests/test_volumeutils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,11 @@ def test_a2f_nan2zero_range():
692692
write_return(arr_no_nan, fobj, np.int8, intercept=129)
693693
# OK with nan2zero false, but we get whatever nan casts to
694694
with pytest.warns(warn_type) if warn_type else error_warnings():
695-
nan_cast = np.array(np.nan, dtype=dt).astype(np.int8)
695+
# XXX NP1.24
696+
# Casting nan to int will produce a RuntimeWarning in numpy 1.24
697+
# Change to expecting this warning when this becomes our minimum
698+
with np.errstate(invalid='ignore'):
699+
nan_cast = np.array(np.nan, dtype=dt).astype(np.int8)
696700
with pytest.warns(warn_type) if warn_type else error_warnings():
697701
back_arr = write_return(arr, fobj, np.int8, intercept=129, nan2zero=False)
698702
assert_array_equal([-128, -128, -128, nan_cast], back_arr)

0 commit comments

Comments
 (0)