32
32
get_integer_dtypes ,
33
33
has_support_aspect16 ,
34
34
has_support_aspect64 ,
35
+ numpy_version ,
35
36
)
36
37
from .test_umath import (
37
38
_get_numpy_arrays_1in_1out ,
@@ -1408,7 +1409,7 @@ class TestLdexp:
1408
1409
@pytest .mark .parametrize ("exp_dt" , get_integer_dtypes ())
1409
1410
def test_basic (self , mant_dt , exp_dt ):
1410
1411
if (
1411
- numpy . lib . NumpyVersion ( numpy . __version__ ) < "2.0.0"
1412
+ numpy_version ( ) < "2.0.0"
1412
1413
and exp_dt == numpy .int64
1413
1414
and numpy .dtype ("l" ) != numpy .int64
1414
1415
):
@@ -1421,9 +1422,7 @@ def test_basic(self, mant_dt, exp_dt):
1421
1422
if dpnp .issubdtype (exp_dt , dpnp .uint64 ):
1422
1423
assert_raises (ValueError , dpnp .ldexp , imant , iexp )
1423
1424
assert_raises (TypeError , numpy .ldexp , mant , exp )
1424
- elif numpy .lib .NumpyVersion (
1425
- numpy .__version__
1426
- ) < "2.0.0" and dpnp .issubdtype (exp_dt , dpnp .uint32 ):
1425
+ elif numpy_version () < "2.0.0" and dpnp .issubdtype (exp_dt , dpnp .uint32 ):
1427
1426
# For this special case, NumPy < "2.0.0" raises an error on Windows
1428
1427
result = dpnp .ldexp (imant , iexp )
1429
1428
expected = numpy .ldexp (mant , exp .astype (numpy .int32 ))
@@ -2130,7 +2129,7 @@ def test_zeros(self, dt):
2130
2129
2131
2130
result = dpnp .spacing (ia )
2132
2131
expected = numpy .spacing (a )
2133
- if numpy . lib . NumpyVersion ( numpy . __version__ ) < "2.0.0" :
2132
+ if numpy_version ( ) < "2.0.0" :
2134
2133
assert_equal (result , expected )
2135
2134
else :
2136
2135
# numpy.spacing(-0.0) == numpy.spacing(0.0), i.e. NumPy returns
@@ -2193,7 +2192,7 @@ def test_complex(self, xp):
2193
2192
2194
2193
class TestTrapezoid :
2195
2194
def get_numpy_func (self ):
2196
- if numpy . lib . NumpyVersion ( numpy . __version__ ) < "2.0.0" :
2195
+ if numpy_version ( ) < "2.0.0" :
2197
2196
# `trapz` is deprecated in NumPy 2.0
2198
2197
return numpy .trapz
2199
2198
return numpy .trapezoid
@@ -2753,10 +2752,7 @@ def test_out(self, func_params, dtype):
2753
2752
# NumPy < 2.0.0 while output has the dtype of input for NumPy >= 2.0.0
2754
2753
# (dpnp follows the latter behavior except for boolean dtype where it
2755
2754
# returns int8)
2756
- if (
2757
- numpy .lib .NumpyVersion (numpy .__version__ ) < "2.0.0"
2758
- or dtype == numpy .bool
2759
- ):
2755
+ if numpy_version () < "2.0.0" or dtype == numpy .bool :
2760
2756
check_type = False
2761
2757
else :
2762
2758
check_type = True
0 commit comments