pydata / xarray

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

Some complex aggregations broken with `numbagg` installed #9209

Closed slevang closed 1 day ago

slevang commented 3 days ago

What happened?

Some common aggregations (at least min, max, var, std) are broken with complex dtypes if numbagg is installed with the default skipna=True. Looks like this is the case since #8624.

What did you expect to happen?

We either route to bottleneck or numpy here if these aggregation aren't supported in numbagg, or get them working with numbagg.

Minimal Complete Verifiable Example

import xarray as xr
import numpy as np
da = xr.DataArray(np.ones((2,), dtype=np.complex_), dims=["x"])
da.min(skipna=False) # works
da.min() # fails

MVCE confirmation

Relevant log output

TypeError: ufunc '__numbagg_transformed_func' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Anything else we need to know?

cc @max-sixty

Environment

xarray==2024.1.1 numbagg==0.8.1
max-sixty commented 1 day ago

Thanks @slevang ! This should be fixed now. When numba allows for dynamic compilation then it'll be free for numbagg to support these...