|
17 | 17 | from array_api_compat import ( |
18 | 18 | device, is_array_api_obj, is_lazy_array, is_writeable_array, size, to_device |
19 | 19 | ) |
20 | | -from ._helpers import import_, wrapped_libraries, all_libraries |
| 20 | +from ._helpers import all_libraries, import_, wrapped_libraries, xfail |
| 21 | + |
21 | 22 |
|
22 | 23 | is_array_functions = { |
23 | 24 | 'numpy': 'is_numpy_array', |
@@ -188,7 +189,10 @@ class C: |
188 | 189 |
|
189 | 190 |
|
190 | 191 | @pytest.mark.parametrize("library", all_libraries) |
191 | | -def test_device(library): |
| 192 | +def test_device(library, request): |
| 193 | + if library == "ndonnx": |
| 194 | + xfail(request, reason="Needs ndonnx >=0.9.4") |
| 195 | + |
192 | 196 | xp = import_(library, wrapper=True) |
193 | 197 |
|
194 | 198 | # We can't test much for device() and to_device() other than that |
@@ -226,24 +230,19 @@ def test_to_device_host(library): |
226 | 230 | @pytest.mark.parametrize("target_library", is_array_functions.keys()) |
227 | 231 | @pytest.mark.parametrize("source_library", is_array_functions.keys()) |
228 | 232 | def test_asarray_cross_library(source_library, target_library, request): |
229 | | - def _xfail(reason: str) -> None: |
230 | | - # Allow rest of test to execute instead of immediately xfailing |
231 | | - # xref https://github.com/pandas-dev/pandas/issues/38902 |
232 | | - request.node.add_marker(pytest.mark.xfail(reason=reason)) |
233 | | - |
234 | 233 | if source_library == "dask.array" and target_library == "torch": |
235 | 234 | # TODO: remove xfail once |
236 | 235 | # https://github.com/dask/dask/issues/8260 is resolved |
237 | | - _xfail(reason="Bug in dask raising error on conversion") |
| 236 | + xfail(request, reason="Bug in dask raising error on conversion") |
238 | 237 | elif ( |
239 | 238 | source_library == "ndonnx" |
240 | 239 | and target_library not in ("array_api_strict", "ndonnx", "numpy") |
241 | 240 | ): |
242 | | - _xfail(reason="The truth value of lazy Array Array(dtype=Boolean) is unknown") |
| 241 | + xfail(request, reason="The truth value of lazy Array Array(dtype=Boolean) is unknown") |
243 | 242 | elif source_library == "ndonnx" and target_library == "numpy": |
244 | | - _xfail(reason="produces numpy array of ndonnx scalar arrays") |
| 243 | + xfail(request, reason="produces numpy array of ndonnx scalar arrays") |
245 | 244 | elif source_library == "jax.numpy" and target_library == "torch": |
246 | | - _xfail(reason="casts int to float") |
| 245 | + xfail(request, reason="casts int to float") |
247 | 246 | elif source_library == "cupy" and target_library != "cupy": |
248 | 247 | # cupy explicitly disallows implicit conversions to CPU |
249 | 248 | pytest.skip(reason="cupy does not support implicit conversion to CPU") |
|
0 commit comments