pydata / xarray

N-D labeled arrays and datasets in Python
https://xarray.dev
Apache License 2.0
3.63k stars 1.09k forks source link

Namespace-aware `xarray.ufuncs` #9776

Closed slevang closed 3 days ago

slevang commented 1 week ago

Re-implement the old xarray.ufuncs module to allow generic ufunc handling for array types that don't implement __array_ufunc__:

import jax.numpy as jnp
import numpy as np
import xarray as xr
import xarray.ufuncs as xu

x = xr.DataArray(jnp.asarray([1, 2, 3]))
print(type(xu.sin(x).data))
print(type(np.sin(x).data))

# <class 'jaxlib.xla_extension.ArrayImpl'>
# <class 'numpy.ndarray'>
shoyer commented 4 days ago

This looks great! Could you please also add a brief note to whats-new.rst?

slevang commented 4 days ago

This looks great! Could you please also add a brief note to whats-new.rst?

Yes will do. Shall we add these back to the main api docs as well, same as before minus the deprecation notice?

shoyer commented 4 days ago

Yes, please!

On Sun, Nov 17, 2024 at 1:22 PM Sam Levang @.***> wrote:

This looks great! Could you please also add a brief note to whats-new.rst?

Yes will do. Shall we add these back to the main api docs as well, same as before https://github.com/pydata/xarray/pull/6491/files#diff-9ceb22fb61ab27613e143e733f0d2ef128c1f72125ae3c6324465955bd093f93 minus the deprecation notice?

— Reply to this email directly, view it on GitHub https://github.com/pydata/xarray/pull/9776#issuecomment-2481582943, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJJFVVI36XVHPN3ZAPCCSL2BECIVAVCNFSM6AAAAABRVS4J72VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOBRGU4DEOJUGM . You are receiving this because you were mentioned.Message ID: @.***>