Skip to content

Commit 8c92cbd

Browse files
committed
tweak sparse skip
1 parent 4efce58 commit 8c92cbd

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

tests/test_funcs.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
lazy_xp_function(sinc, static_argnames="xp")
4949

5050

51+
@pytest.mark.skip_xp_backend(
52+
Backend.SPARSE, reason="read-only backend without .at support"
53+
)
5154
class TestApplyWhere:
5255
@staticmethod
5356
def f1(x: Array, y: Array | int = 10) -> Array:
@@ -57,15 +60,13 @@ def f1(x: Array, y: Array | int = 10) -> Array:
5760
def f2(x: Array, y: Array | int = 10) -> Array:
5861
return x - y
5962

60-
@pytest.mark.xfail_xp_backend(Backend.SPARSE, reason="read-only without .at")
6163
def test_f1_f2(self, xp: ModuleType):
6264
x = xp.asarray([1, 2, 3, 4])
6365
cond = x % 2 == 0
6466
actual = apply_where(cond, x, self.f1, self.f2)
6567
expect = xp.where(cond, self.f1(x), self.f2(x))
6668
xp_assert_equal(actual, expect)
6769

68-
@pytest.mark.xfail_xp_backend(Backend.SPARSE, reason="read-only without .at")
6970
def test_fill_value(self, xp: ModuleType):
7071
x = xp.asarray([1, 2, 3, 4])
7172
cond = x % 2 == 0
@@ -76,7 +77,6 @@ def test_fill_value(self, xp: ModuleType):
7677
actual = apply_where(x % 2 == 0, x, self.f1, fill_value=xp.asarray(0))
7778
xp_assert_equal(actual, expect)
7879

79-
@pytest.mark.xfail_xp_backend(Backend.SPARSE, reason="read-only without .at")
8080
def test_args_tuple(self, xp: ModuleType):
8181
x = xp.asarray([1, 2, 3, 4])
8282
y = xp.asarray([10, 20, 30, 40])
@@ -85,7 +85,6 @@ def test_args_tuple(self, xp: ModuleType):
8585
expect = xp.where(cond, self.f1(x, y), self.f2(x, y))
8686
xp_assert_equal(actual, expect)
8787

88-
@pytest.mark.xfail_xp_backend(Backend.SPARSE, reason="read-only without .at")
8988
def test_broadcast(self, xp: ModuleType):
9089
x = xp.asarray([1, 2])
9190
y = xp.asarray([[10], [20], [30]])
@@ -109,7 +108,6 @@ def test_broadcast(self, xp: ModuleType):
109108
expect = xp.where(cond, self.f1(x), y)
110109
xp_assert_equal(actual, expect)
111110

112-
@pytest.mark.xfail_xp_backend(Backend.SPARSE, reason="read-only without .at")
113111
def test_dtype_propagation(self, xp: ModuleType, library: Backend):
114112
x = xp.asarray([1, 2], dtype=xp.int8)
115113
y = xp.asarray([3, 4], dtype=xp.int16)
@@ -127,7 +125,6 @@ def test_dtype_propagation(self, xp: ModuleType, library: Backend):
127125
actual = apply_where(cond, y, self.f1, fill_value=5)
128126
assert actual.dtype == xp.int16
129127

130-
@pytest.mark.xfail_xp_backend(Backend.SPARSE, reason="read-only without .at")
131128
@pytest.mark.parametrize("fill_value_raw", [3, [3, 4]])
132129
@pytest.mark.parametrize(
133130
("fill_value_dtype", "expect_dtype"), [("int32", "int32"), ("int8", "int16")]
@@ -146,15 +143,13 @@ def test_dtype_propagation_fill_value(
146143
actual = apply_where(cond, x, self.f1, fill_value=fill_value)
147144
assert actual.dtype == getattr(xp, expect_dtype)
148145

149-
@pytest.mark.xfail_xp_backend(Backend.SPARSE, reason="read-only without .at")
150146
def test_dont_overwrite_fill_value(self, xp: ModuleType):
151147
x = xp.asarray([1, 2])
152148
fill_value = xp.asarray([100, 200])
153149
actual = apply_where(x % 2 == 0, x, self.f1, fill_value=fill_value)
154150
xp_assert_equal(actual, xp.asarray([100, 12]))
155151
xp_assert_equal(fill_value, xp.asarray([100, 200]))
156152

157-
@pytest.mark.xfail_xp_backend(Backend.SPARSE, reason="read-only without .at")
158153
def test_dont_run_on_false(self, xp: ModuleType):
159154
x = xp.asarray([1.0, 2.0, 0.0])
160155
y = xp.asarray([0.0, 3.0, 4.0])
@@ -178,15 +173,13 @@ def test_bad_args(self, xp: ModuleType):
178173
apply_where(cond, x, self.f1, self.f2, fill_value=0) # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
179174

180175
@pytest.mark.skip_xp_backend(Backend.NUMPY_READONLY, reason="xp=xp")
181-
@pytest.mark.xfail_xp_backend(Backend.SPARSE, reason="read-only without .at")
182176
def test_xp(self, xp: ModuleType):
183177
x = xp.asarray([1, 2, 3, 4])
184178
cond = x % 2 == 0
185179
actual = apply_where(cond, x, self.f1, self.f2, xp=xp)
186180
expect = xp.where(cond, self.f1(x), self.f2(x))
187181
xp_assert_equal(actual, expect)
188182

189-
@pytest.mark.xfail_xp_backend(Backend.SPARSE, reason="read-only without .at")
190183
def test_device(self, xp: ModuleType, device: Device):
191184
x = xp.asarray([1, 2, 3, 4], device=device)
192185
y = apply_where(x % 2 == 0, x, self.f1, self.f2)
@@ -196,8 +189,6 @@ def test_device(self, xp: ModuleType, device: Device):
196189
y = apply_where(x % 2 == 0, x, self.f1, fill_value=x)
197190
assert get_device(y) == device
198191

199-
# skip instead of xfail in order not to waste time
200-
@pytest.mark.skip_xp_backend(Backend.SPARSE, reason="read-only without .at")
201192
@pytest.mark.filterwarnings("ignore::RuntimeWarning") # overflows, etc.
202193
@hypothesis.settings( # pyright: ignore[reportArgumentType]
203194
# The xp and library fixtures are not regenerated between hypothesis iterations

0 commit comments

Comments
 (0)