-
-
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
Add support for Array API in NamedArray #8344
base: main
Are you sure you want to change the base?
Conversation
xarray/namedarray/_array_api.py
Outdated
@@ -144,3 +146,79 @@ def real( | |||
xp = _get_data_namespace(x) | |||
out = x._new(data=xp.real(x._data)) | |||
return out | |||
|
|||
|
|||
# %% Statistical Functions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Illviljan, i'm curious to hear your thoughts on adopting a similar structure/organization as that used in Numpy so as to it easier to incorporate new array API compliant functionality in the future. the new structure would group functionality under /namedarray/_array_api/*.py
instead of of putting everything in _array_api.py
.
e.g.
├── _creation_functions.py
├── _data_type_functions.py
├── _dtypes.py
├── _elementwise_functions.py
├── _indexing_functions.py
├── _manipulation_functions.py
├── _searching_functions.py
├── _set_functions.py
├── _sorting_functions.py
├── _statistical_functions.py
├── linalg.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! I just thought it was too few functions to bother with it right now.
Cubed has similar structure too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perfect! i intend to add a few more functions to the array_api
and i'm happy to put this structure in place
@Illviljan can you comment on why this approach is useful if we can't advertise array_api compliance based on upstream input? |
I notice sklearn for example is slowly getting array api support and I think it would be a great win to get these kind of packages to just work out of the box. There's two distinct programming styles between array api vs. xarray:
Due to this, I'm not yet convinced it is impossible for us to not support both. Most stuff xarray do is simply an extension of the narrow array api. Internally we have to deal with array apis and the namedarray imports
|
This particular PR has simply grown because of the lack of typing in |
Sure, but the way to proceed would be to build consensus around this in an issue discussion or at the bi-weekly meeting.
For example, this assertion has had very little support within the core team in discussions. |
It's hard to change peoples mind sometimes, so I like to have some working examples for discussion.
Still, there is It is the only way to be compliant to both ways and xarray in general seem to enjoy the method-chaining style more. So adding array_api compatible equivalents wont change current workflows much but will however allow considerable more workflows automatically. Being able to pass around attrs and dims might be enough for users. |
Don't you have enough already?
These ops are applied to the wrapped array not to an xarray object. |
Yes, but it doesn't look insurmountable to me for Thank you for the input @dcherian. I won't merge this without approval. |
generally expanding |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
whats-new.rst
api.rst