File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -159,10 +159,15 @@ def test_as_int():
159
159
ctx = pytest .raises (OverflowError )
160
160
else :
161
161
ctx = nullcontext ()
162
+ out_val = None
162
163
with ctx :
163
- as_int (val )
164
+ out_val = as_int (val )
165
+ if out_val is not None :
166
+ assert out_val == val
164
167
with ctx :
165
- as_int (- val )
168
+ out_val = as_int (- val )
169
+ if out_val is not None :
170
+ assert out_val == - val
166
171
167
172
168
173
def test_int_to_float ():
Original file line number Diff line number Diff line change 68
68
NUMERIC_TYPES = CFLOAT_TYPES + IUINT_TYPES
69
69
70
70
FP_RUNTIME_WARN = Version (np .__version__ ) >= Version ('1.24.0.dev0+239' )
71
+ NP_2 = Version (np .__version__ ) >= Version ('2.0.0.dev0' )
71
72
72
73
try :
73
74
from numpy .exceptions import ComplexWarning
@@ -743,9 +744,13 @@ def test_apply_scaling():
743
744
i16_arr = np .zeros ((1 ,), dtype = np .int16 )
744
745
# Check float upcast (not the normal numpy scalar rule)
745
746
# This is the normal rule - no upcast from Python scalar
746
- # (on NumPy 2.0 it *will* upcast from a np.float64 scalar!)
747
747
assert (f32_arr * 1.0 ).dtype == np .float32
748
748
assert (f32_arr + 1.0 ).dtype == np .float32
749
+ # This is the normal rule - no upcast from scalar
750
+ # before NumPy 2.0, after 2.0, it upcasts
751
+ want_dtype = np .float64 if NP_2 else np .float32
752
+ assert (f32_arr * f64 (1 )).dtype == want_dtype
753
+ assert (f32_arr + f64 (1 )).dtype == want_dtype
749
754
# The function does upcast though
750
755
ret = apply_read_scaling (np .float32 (0 ), np .float64 (2 ))
751
756
assert ret .dtype == np .float64
You can’t perform that action at this time.
0 commit comments