Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions xarray/computation/apply_ufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@
from xarray.core.formatting import limit_lines
from xarray.core.indexes import Index, filter_indexes_from_coords
from xarray.core.options import _get_keep_attrs
from xarray.core.utils import (
is_dict_like,
result_name,
)
from xarray.core.utils import is_dict_like, result_name
from xarray.core.variable import Variable
from xarray.namedarray.parallelcompat import get_chunked_array_type
from xarray.namedarray.pycompat import is_chunked_array
Expand Down Expand Up @@ -1212,6 +1209,8 @@ def apply_ufunc(
dask_gufunc_kwargs.setdefault("output_sizes", output_sizes)

if kwargs:
if "where" in kwargs and isinstance(kwargs["where"], DataArray):
kwargs["where"] = kwargs["where"].data
func = functools.partial(func, **kwargs)

if keep_attrs is None:
Expand Down
11 changes: 11 additions & 0 deletions xarray/tests/test_computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2627,3 +2627,14 @@ def test_complex_number_reduce(compute_backend):
# 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()


def test_fix() -> None:
val = 3.0
val_fixed = np.fix(val)

da = xr.DataArray([val])
expected = xr.DataArray([val_fixed])

actual = np.fix(da)
xr.testing.assert_duckarray_allclose(expected, actual)
Loading