3232from array_api_extra ._lib ._utils ._typing import Array , Device
3333from array_api_extra .testing import lazy_xp_function
3434
35+ from .conftest import NUMPY_VERSION
36+
3537# some xp backends are untyped
3638# mypy: disable-error-code=no-untyped-def
3739
4850lazy_xp_function (sinc , static_argnames = "xp" )
4951
5052
51- NUMPY_VERSION = tuple (int (v ) for v in np .__version__ .split ("." )[2 ])
52-
53-
5453class TestApplyWhere :
5554 @staticmethod
5655 def f1 (x : Array , y : Array | int = 10 ) -> Array :
@@ -197,7 +196,7 @@ def test_device(self, xp: ModuleType, device: Device):
197196 y = apply_where (x % 2 == 0 , x , self .f1 , fill_value = x )
198197 assert get_device (y ) == device
199198
200- @pytest .mark .xfail_xp_backend (Backend .SPARSE , reason = "no isdtype" )
199+ @pytest .mark .skip_xp_backend (Backend .SPARSE , reason = "no isdtype" )
201200 @pytest .mark .filterwarnings ("ignore::RuntimeWarning" ) # overflows, etc.
202201 @hypothesis .settings (
203202 # The xp and library fixtures are not regenerated between hypothesis iterations
@@ -223,7 +222,7 @@ def test_hypothesis( # type: ignore[explicit-any,decorated-any]
223222 library : Backend ,
224223 ):
225224 if (
226- library in (Backend .NUMPY , Backend . NUMPY_READONLY )
225+ library . like (Backend .NUMPY )
227226 and NUMPY_VERSION < (2 , 0 )
228227 and dtype is np .float32
229228 ):
@@ -843,8 +842,7 @@ def test_all_equal(self, xp: ModuleType):
843842 Backend .SPARSE , reason = "Non-compliant equal_nan=True behaviour"
844843 )
845844 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 ):
848846 pytest .xfail ("NumPy <1.24 has no equal_nan kwarg in unique" )
849847
850848 # Each NaN is counted separately
0 commit comments