8000 Revert ndonnx device support · data-apis/array-api-compat@8434019 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8434019

Browse files
committed
Revert ndonnx device support
1 parent 8345fa1 commit 8434019

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

array_api_compat/common/_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ def device(x: Array, /) -> Device:
645645
to_device : Move array data to a different device.
646646
647647
"""
648-
if is_numpy_array(x) or is_ndonnx_array(x):
648+
if is_numpy_array(x):
649649
return "cpu"
650650
elif is_dask_array(x):
651651
# Peek at the metadata of the Dask array to determine type

tests/_helpers.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,14 @@ def import_(library, wrapper=False):
2121
library = 'array_api_compat.' + library
2222

2323
return import_module(library)
24+
25+
26+
def xfail(request: pytest.FixtureRequest, reason: str) -> None:
27+
"""
28+
XFAIL the currently running test.
29+
30+
Unlike ``pytest.xfail``, allow rest of test to execute instead of immediately
31+
halting it, so that it may result in a XPASS.
32+
xref https://github.com/pandas-dev/pandas/issues/38902
33+
"""
34+
request.node.add_marker(pytest.mark.xfail(reason=reason))

tests/test_common.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
from array_api_compat import (
1818
device, is_array_api_obj, is_lazy_array, is_writeable_array, size, to_device
1919
)
20-
from ._helpers import import_, wrapped_libraries, all_libraries
20+
from ._helpers import all_libraries, import_, wrapped_libraries, xfail
21+
2122

2223
is_array_functions = {
2324
'numpy': 'is_numpy_array',
@@ -188,7 +189,10 @@ class C:
188189

189190

190191
@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+
192196
xp = import_(library, wrapper=True)
193197

194198
# We can't test much for device() and to_device() other than that
@@ -226,24 +230,19 @@ def test_to_device_host(library):
226230
@pytest.mark.parametrize("target_library", is_array_functions.keys())
227231
@pytest.mark.parametrize("source_library", is_array_functions.keys())
228232
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-
234233
if source_library == "dask.array" and target_library == "torch":
235234
# TODO: remove xfail once
236235
# 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")
238237
elif (
239238
source_library == "ndonnx"
240239
and target_library not in ("array_api_strict", "ndonnx", "numpy")
241240
):
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")
243242
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")
245244
elif source_library == "jax.numpy" and target_library == "torch":
246-
_xfail(reason="casts int to float")
245+
xfail(request, reason="casts int to float")
247246
elif source_library == "cupy" and target_library != "cupy":
248247
# cupy explicitly disallows implicit conversions to CPU
249248
pytest.skip(reason="cupy does not support implicit conversion to CPU")

0 commit comments

Comments
 (0)
0