Skip to content

Commit

Permalink
TEST: Suppress new numpy warning on nan-to-int cast
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Jun 18, 2022
1 parent f469c68 commit a72a1b6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nibabel/tests/test_volumeutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,11 @@ def test_a2f_nan2zero_range():
write_return(arr_no_nan, fobj, np.int8, intercept=129)
# OK with nan2zero false, but we get whatever nan casts to
with pytest.warns(warn_type) if warn_type else error_warnings():
nan_cast = np.array(np.nan, dtype=dt).astype(np.int8)
# XXX NP1.24
# Casting nan to int will produce a RuntimeWarning in numpy 1.24
# Change to expecting this warning when this becomes our minimum
with np.errstate(invalid='ignore'):
nan_cast = np.array(np.nan, dtype=dt).astype(np.int8)
with pytest.warns(warn_type) if warn_type else error_warnings():
back_arr = write_return(arr, fobj, np.int8, intercept=129, nan2zero=False)
assert_array_equal([-128, -128, -128, nan_cast], back_arr)
Expand Down

0 comments on commit a72a1b6

Please sign in to comment.