diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 753586c32c2..8c6b3a099c2 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -49,6 +49,9 @@ Bug fixes By `Michael Niklas `_. - Dark themes are now properly detected for ``html[data-theme=dark]``-tags (:pull:`9200`). By `Dieter Werthmüller `_. +- Reductions no longer fail for ``np.complex_`` dtype arrays when numbagg is + installed. + By `Maximilian Roos `_ Documentation ~~~~~~~~~~~~~ diff --git a/xarray/core/nputils.py b/xarray/core/nputils.py index 6970d37402f..1d30fe9db9e 100644 --- a/xarray/core/nputils.py +++ b/xarray/core/nputils.py @@ -191,7 +191,7 @@ def f(values, axis=None, **kwargs): or kwargs.get("ddof", 0) == 1 ) # TODO: bool? - and values.dtype.kind in "uifc" + and values.dtype.kind in "uif" # and values.dtype.isnative and (dtype is None or np.dtype(dtype) == values.dtype) # numbagg.nanquantile only available after 0.8.0 and with linear method diff --git a/xarray/tests/test_computation.py b/xarray/tests/test_computation.py index 080447cede0..4b9b95b27bb 100644 --- a/xarray/tests/test_computation.py +++ b/xarray/tests/test_computation.py @@ -2598,3 +2598,11 @@ def test_cross(a, b, ae, be, dim: str, axis: int, use_dask: bool) -> None: actual = xr.cross(a, b, dim=dim) xr.testing.assert_duckarray_allclose(expected, actual) + + +@pytest.mark.parametrize("compute_backend", ["numbagg"], indirect=True) +def test_complex_number_reduce(compute_backend): + da = xr.DataArray(np.ones((2,), dtype=np.complex_), dims=["x"]) + # Check that xarray doesn't call into numbagg, which doesn't compile for complex + # numbers at the moment (but will when numba supports dynamic compilation) + da.min()