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():
159159 ctx = pytest .raises (OverflowError )
160160 else :
161161 ctx = nullcontext ()
162+ out_val = None
162163 with ctx :
163- as_int (val )
164+ out_val = as_int (val )
165+ if out_val is not None :
166+ assert out_val == val
164167 with ctx :
165- as_int (- val )
168+ out_val = as_int (- val )
169+ if out_val is not None :
170+ assert out_val == - val
166171
167172
168173def test_int_to_float ():
Original file line number Diff line number Diff line change 6868NUMERIC_TYPES = CFLOAT_TYPES + IUINT_TYPES
6969
7070FP_RUNTIME_WARN = Version (np .__version__ ) >= Version ('1.24.0.dev0+239' )
71+ NP_2 = Version (np .__version__ ) >= Version ('2.0.0.dev0' )
7172
7273try :
7374 from numpy .exceptions import ComplexWarning
@@ -743,9 +744,13 @@ def test_apply_scaling():
743744 i16_arr = np .zeros ((1 ,), dtype = np .int16 )
744745 # Check float upcast (not the normal numpy scalar rule)
745746 # This is the normal rule - no upcast from Python scalar
746- # (on NumPy 2.0 it *will* upcast from a np.float64 scalar!)
747747 assert (f32_arr * 1.0 ).dtype == np .float32
748748 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
749754 # The function does upcast though
750755 ret = apply_read_scaling (np .float32 (0 ), np .float64 (2 ))
751756 assert ret .dtype == np .float64
You can’t perform that action at this time.
0 commit comments