diff --git a/flox/xarray.py b/flox/xarray.py index 0a299d6d..11cf706d 100644 --- a/flox/xarray.py +++ b/flox/xarray.py @@ -312,6 +312,7 @@ def xarray_reduce( # skipna is not supported for all reductions # https://github.com/pydata/xarray/issues/8819 kwargs = {"skipna": skipna} if skipna is not None else {} + kwargs.update(finalize_kwargs) result = getattr(ds_broad, func)(dim=dim_tuple, **kwargs) if isinstance(obj, xr.DataArray): return obj._from_temp_dataset(result) diff --git a/tests/test_xarray.py b/tests/test_xarray.py index 97b5674b..ecd63bbf 100644 --- a/tests/test_xarray.py +++ b/tests/test_xarray.py @@ -736,7 +736,7 @@ def test_direct_reduction(func): data = xr.DataArray(rand, dims=("x", "y"), coords={"x": [10, 20], "y": [0, 1, 2]}) with xr.set_options(use_flox=True): - actual = getattr(data.groupby("x", squeeze=False), func)(**kwargs) + actual = xarray_reduce(data, "x", func=func, **kwargs) with xr.set_options(use_flox=False): expected = getattr(data.groupby("x", squeeze=False), func)(**kwargs) xr.testing.assert_identical(expected, actual)