Skip to content

array api - Add tests for aggregations #7424

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

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

Illviljan
Copy link
Contributor

@Illviljan Illviljan commented Jan 6, 2023

@github-actions github-actions bot added the topic-arrays related to flexible array support label Jan 6, 2023
@Illviljan
Copy link
Contributor Author

Illviljan commented Jan 6, 2023

The array api standard doesn't define any nan*-functions.
xarray pretty much always defaults to using nan*-function. :(

So any time an array has a __array_namespace__ we have to use our own nan-solution, like for .sum:

def sum_where(data, axis=None, dtype=None, where=None):
xp = get_array_namespace(data)
if where is not None:
a = where_method(xp.zeros_like(data), where, data)
else:
a = data
result = xp.sum(a, axis=axis, dtype=dtype)
return result

Any thoughts? Are there any clever ways to handle the aggregations with NaNs in a generic way?

edit: numpy implementations:
https://github.com/numpy/numpy/blob/main/numpy/lib/nanfunctions.py

@tomwhite
Copy link
Contributor

I was hoping https://github.com/data-apis/array-api-compat might help with this, but I'm not sure it does...

@tomwhite
Copy link
Contributor

Related issue: data-apis/array-api#621

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-arrays related to flexible array support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some aggregate operations using the array API fail
2 participants