Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement NumPy's __array_function__ protocol for array methods that are not in the Array API Standard #475

Open
tomwhite opened this issue Jun 5, 2024 · 1 comment · May be fixed by #643
Labels
array api xarray-integration Uses or required for cubed-xarray integration

Comments

@tomwhite
Copy link
Member

tomwhite commented Jun 5, 2024

This is to support nanmean, nansum (see #153), and pad (#461).

The previous attempt at this in #468 was reverted in #469, since it was causing problems when used with Xarray (pydata/xarray#8834 (comment)).

When Xarray is working we can re-introduce the changes here.

@tomwhite tomwhite added array api xarray-integration Uses or required for cubed-xarray integration labels Jun 5, 2024
@tomwhite
Copy link
Member Author

tomwhite commented Oct 1, 2024

The Xarray change that enables this has been merged (pydata/xarray#9530).

I've re-created the branch from #468 here: https://github.com/cubed-dev/cubed/tree/np-array-function. However, when I run the cubed-xarray tests I get some failures:

FAILED cubed_xarray/tests/test_wrapping.py::test_to_zarr[single-threaded] - TypeError: no implementation found for 'numpy.isclose' on types that implement __array_function__: [<class 'cubed.array_api.a...
FAILED cubed_xarray/tests/test_wrapping.py::test_to_zarr[processes] - TypeError: no implementation found for 'numpy.isclose' on types that implement __array_function__: [<class 'cubed.array_api.a...
FAILED cubed_xarray/tests/test_xarray.py::TestVariable::test_binary_op_bitshift - TypeError: no implementation found for 'numpy.full_like' on types that implement __array_function__: [<class 'cubed.array_api...
FAILED cubed_xarray/tests/test_xarray.py::TestVariable::test_reduce - TypeError: no implementation found for 'numpy.isclose' on types that implement __array_function__: [<class 'cubed.array_api.a...
FAILED cubed_xarray/tests/test_xarray.py::TestDataArrayAndDataset::test_lazy_array - TypeError: no implementation found for 'numpy.isclose' on types that implement __array_function__: [<class 'cubed.array_api.a...
FAILED cubed_xarray/tests/test_xarray.py::TestDataArrayAndDataset::test_dataarray_pickle - TypeError: no implementation found for 'numpy.full_like' on types that implement __array_function__: [<class 'cubed.array_api...
FAILED cubed_xarray/tests/test_xarray.py::TestDataArrayAndDataset::test_dataset_pickle - AssertionError: Left and right Dataset objects are not identical
FAILED cubed_xarray/tests/test_xarray.py::test_unify_chunks - AssertionError: Left and right Dataset objects are not identical
================================ 8 failed, 41 passed, 2 skipped, 15 xfailed, 3 warnings in 3.47s =================================

There is no isclose function in the Array API (data-apis/array-api#170), so we may need to build one (in Xarray?).

cc @keewis @TomNicholas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
array api xarray-integration Uses or required for cubed-xarray integration
Projects
None yet
1 participant