-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Missing array-api support for some stats functions? #8834
Comments
Thanks for opening your first issue here at xarray! Be sure to follow the issue template! |
thanks for the report, and we'd definitely like to be able to use reductions while ignoring Note that you can opt out of the |
If you do have a |
Okay, that makes sense. And it looks like that's working now, thanks! However, doing the same thing for
It looks like this is because the array api std calls it
There isn't currently, but I'm thinking that will be a good solution for now (at least until something link nanmean and friends get added to the array api). |
okay, that's good to know, thank you! |
According to @tomwhite in cubed-dev/cubed#469 (comment) it's not quite as simple as this:
Switching the order seems okay to me... It should only matter for types that implement both. And if a type supports One question is whether there are any types of array indexing operations that xarray supports via |
the array API adapter doesn't support vectorized indexing yet (#8667) but we can add a fallback with |
Agreed. NumPy 2 supports both but should not be affected since NumPy is special-cased earlier in the function. |
What happened?
When creating a DataArray using an (array-api compliant) Arkouda Array, some numpy operations are not being directed to their array-api counterparts. For example, calling
mean
on the DataArray produces an error indicating thatnumpy.nanmean
could not be called on the array object, but callingsum
on the DataArray successfully calls arkouda's array-api implementation ofsum
.As a temporary workaround, I've made a shim for
mean
that matches numpy's interface and calls the array-api compliantmean
, annotating it with animplements
decorator as described in this section of numpy's documentation:*full code here
What did you expect to happen?
My expectation was that XArray would call the array-api version of
mean
, as it does withsum
for example. Note that I've run into a similar error with some other stats functions (likevar
), but haven't yet tested a wide selection of XArray's API to se what is/isn't working.It's also very possible that the Arkouda implementation is missing something that would allow those calls to be properly redirected to arkouda's array-api, or that I've misunderstood XArrays requirements for array-api support, but I'm not sure what that would be.
Any help with getting to the bottom of what's going wrong here would be much appreciated!
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
The arkouda array-api implementation is still under development (I'm the main person working on it atm), so unfortunately the example I've provided is not easily reproducible, but I'd be happy to run any tests/experiments on my local environment where I have it set up.
Environment
INSTALLED VERSIONS
commit: None
python: 3.11.7 (main, Dec 4 2023, 18:10:11) [Clang 15.0.0 (clang-1500.1.0.2.5)]
python-bits: 64
OS: Darwin
OS-release: 22.6.0
machine: arm64
processor: arm
byteorder: little
LC_ALL: None
LANG: None
LOCALE: (None, 'UTF-8')
libhdf5: 1.12.2
libnetcdf: None
xarray: 2024.2.0
pandas: 2.2.1
numpy: 1.26.4
scipy: 1.12.0
netCDF4: None
pydap: None
h5netcdf: None
h5py: 3.10.0
Nio: None
zarr: None
cftime: None
nc_time_axis: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: 3.8.3
cartopy: None
seaborn: None
numbagg: None
fsspec: 2024.2.0
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 69.0.2
pip: 24.0
conda: None
pytest: None
mypy: None
IPython: 8.22.2
sphinx: None
The text was updated successfully, but these errors were encountered: