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

__array_ufunc__ for xarray #1617

Closed
shoyer opened this issue Oct 10, 2017 · 2 comments · Fixed by #1962
Closed

__array_ufunc__ for xarray #1617

shoyer opened this issue Oct 10, 2017 · 2 comments · Fixed by #1962

Comments

@shoyer
Copy link
Member

shoyer commented Oct 10, 2017

Now that __array_ufunc__ has appeared in NumPy 1.13, we should be able to resolve a long-standing annoyance with xarray: the inability to use NumPy ufuncs like np.sin() directly on all xarray objects, such as xarray.Dataset.

I believe this could be straightforwardly accomplished by wrapping xarray.core.computation.apply_ufunc.

Some care should be taken to ensure that properly defer to other array types, as suggested in the NEP. This also could be a good time to resolve some of the xarray's broader consistency issues when interacting with and wrapping other array-like types.

@shoyer
Copy link
Member Author

shoyer commented Oct 29, 2017

A related task would be finishing up this PR:

Ultimately, it would be nice to have some sort of registration system, especially for objects that aren't ndarray subclasses, that indicates that a class can safely be wrapped by xarray.

I'm thinking something like xarray.register_data_type(ArrayWithUnits) which indicates that .data for xarray objects can now be an ArrayWithUnits object. This would also possibly require passing a reference to a set of function to use on data containing these objects (e.g., for stacking or concatenating).

@shoyer
Copy link
Member Author

shoyer commented Mar 5, 2018

I'm starting to work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant