Skip to content

Uxarray types dropped during ufuncs #1685

Description

@Sevans711

I expected uxarray to fully support ufuncs without losing object types. For example, np.log10(uxarr) should return a UxDataArray but it returns an xr.DataArray instead.

Here's a decent example to show the bug:

import uxarray as ux
ds = ux.tutorial.open_dataset('quad-hexagon')
arr = ds['t2m']   # arr is a UxDataArray
result0 = np.sqrt(arr)
result0.uxgrid   # crashes because result0 is an xr.DataArray
result1 = np.cos(ds)
result1.uxgrid   # crashes because result1 is an xr.Dataset

I believe the fix would just involve overriding __apply_ufunc__ appropriately, for UxDataArray and UxDataset.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status
    📝 To-Do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions