Skip to content

__array_ufunc__ for xarray #1617

Closed

Description

@shoyer

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.

Activity

  1. shoyer commented on Oct 29, 2017

    @shoyer
    MemberAuthor

    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).

  2. shoyer commented on Mar 5, 2018

    @shoyer
    MemberAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions