32
32
from array_api_extra ._lib ._utils ._typing import Array , Device
33
33
from array_api_extra .testing import lazy_xp_function
34
34
35
+ from .conftest import NUMPY_VERSION
36
+
35
37
# some xp backends are untyped
36
38
# mypy: disable-error-code=no-untyped-def
37
39
48
50
lazy_xp_function (sinc , static_argnames = "xp" )
49
51
50
52
51
- NUMPY_VERSION = tuple (int (v ) for v in np .__version__ .split ("." )[2 ])
52
-
53
-
54
53
class TestApplyWhere :
55
54
@staticmethod
56
55
def f1 (x : Array , y : Array | int = 10 ) -> Array :
@@ -197,7 +196,7 @@ def test_device(self, xp: ModuleType, device: Device):
197
196
y = apply_where (x % 2 == 0 , x , self .f1 , fill_value = x )
198
197
assert get_device (y ) == device
199
198
200
- @pytest .mark .xfail_xp_backend (Backend .SPARSE , reason = "no isdtype" )
199
+ @pytest .mark .skip_xp_backend (Backend .SPARSE , reason = "no isdtype" )
201
200
@pytest .mark .filterwarnings ("ignore::RuntimeWarning" ) # overflows, etc.
202
201
@hypothesis .settings (
203
202
# The xp and library fixtures are not regenerated between hypothesis iterations
@@ -223,7 +222,7 @@ def test_hypothesis( # type: ignore[explicit-any,decorated-any]
223
222
library : Backend ,
224
223
):
225
224
if (
226
- library in (Backend .NUMPY , Backend . NUMPY_READONLY )
225
+ library . like (Backend .NUMPY )
227
226
and NUMPY_VERSION < (2 , 0 )
228
227
and dtype is np .float32
229
228
):
@@ -843,8 +842,7 @@ def test_all_equal(self, xp: ModuleType):
843
842
Backend .SPARSE , reason = "Non-compliant equal_nan=True behaviour"
844
843
)
845
844
def test_nan (self , xp : ModuleType , library : Backend ):
846
- is_numpy = library in (Backend .NUMPY , Backend .NUMPY_READONLY )
847
- if is_numpy and NUMPY_VERSION < (1 , 24 ):
845
+ if library .like (Backend .NUMPY ) and NUMPY_VERSION < (1 , 24 ):
848
846
pytest .xfail ("NumPy <1.24 has no equal_nan kwarg in unique" )
849
847
850
848
# Each NaN is counted separately
0 commit comments