@@ -544,7 +544,8 @@ def test_a2f_scaled_unscaled():
544
544
):
545
545
mn_in , mx_in = _dt_min_max (in_dtype )
546
546
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 )
548
549
mn_out , mx_out = _dt_min_max (out_dtype )
549
550
# 0 when scaled to output will also be the output value for NaN
550
551
nan_fill = - intercept / divslope
@@ -738,9 +739,10 @@ def test_apply_scaling():
738
739
f32_arr = np .zeros ((1 ,), dtype = f32 )
739
740
i16_arr = np .zeros ((1 ,), dtype = np .int16 )
740
741
# 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
744
746
# The function does upcast though
745
747
ret = apply_read_scaling (np .float32 (0 ), np .float64 (2 ))
746
748
assert ret .dtype == np .float64
0 commit comments