Skip to content

Commit c32b0d2

Browse files
committed
FIX: One more
1 parent cd362aa commit c32b0d2

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

nibabel/tests/test_floating.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ def test_as_int():
154154
with np.errstate(over='ignore'):
155155
val = np.longdouble(2**nexp64) * 2 # outside float64 range
156156
assert val > np.finfo('float64').max
157+
# TODO: Should this actually still overflow? Does it matter?
157158
if FP_OVERFLOW_WARN:
158159
ctx = pytest.raises(OverflowError)
159160
else:

nibabel/tests/test_volumeutils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,8 @@ def test_a2f_scaled_unscaled():
544544
):
545545
mn_in, mx_in = _dt_min_max(in_dtype)
546546
nan_val = np.nan if in_dtype in CFLOAT_TYPES else 10
547-
arr = np.array([mn_in, -1, 0, 1, mx_in, nan_val], dtype=in_dtype)
547+
mn = 0 if np.dtype(in_dtype).kind == "u" else 1
548+
arr = np.array([mn_in, mn, 0, 1, mx_in, nan_val], dtype=in_dtype)
548549
mn_out, mx_out = _dt_min_max(out_dtype)
549550
# 0 when scaled to output will also be the output value for NaN
550551
nan_fill = -intercept / divslope
@@ -738,9 +739,10 @@ def test_apply_scaling():
738739
f32_arr = np.zeros((1,), dtype=f32)
739740
i16_arr = np.zeros((1,), dtype=np.int16)
740741
# Check float upcast (not the normal numpy scalar rule)
741-
# This is the normal rule - no upcast from scalar
742-
assert (f32_arr * f64(1)).dtype == np.float32
743-
assert (f32_arr + f64(1)).dtype == np.float32
742+
# This is the normal rule - no upcast from Python scalar
743+
# (on NumPy 2.0 it *will* upcast from a np.float64 scalar!)
744+
assert (f32_arr * 1.).dtype == np.float32
745+
assert (f32_arr + 1.).dtype == np.float32
744746
# The function does upcast though
745747
ret = apply_read_scaling(np.float32(0), np.float64(2))
746748
assert ret.dtype == np.float64

0 commit comments

Comments
 (0)