Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable .rolling_exp to work on dask arrays #8284

Merged
merged 4 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ New Features
- :py:meth:`DataArray.sortby` & :py:meth:`Dataset.sortby` accept a callable for
the ``variables`` parameter, passing the object as the only argument.
By `Maximilian Roos <https://github.com/max-sixty>`_.
- ``.rolling_exp`` functions can now operate on dask-backed arrays, assuming the
core dim has exactly one chunk. (:pull:`8284`).
By `Maximilian Roos <https://github.com/max-sixty>`_.

Breaking changes
~~~~~~~~~~~~~~~~
Expand Down
4 changes: 2 additions & 2 deletions xarray/core/rolling_exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ def mean(self, keep_attrs: bool | None = None) -> T_DataWithCoords:
input_core_dims=[[self.dim]],
kwargs=dict(alpha=self.alpha, axis=-1),
output_core_dims=[[self.dim]],
exclude_dims={self.dim},
keep_attrs=keep_attrs,
on_missing_core_dim="copy",
dask="parallelized",
max-sixty marked this conversation as resolved.
Show resolved Hide resolved
).transpose(*dim_order)

def sum(self, keep_attrs: bool | None = None) -> T_DataWithCoords:
Expand Down Expand Up @@ -183,7 +183,7 @@ def sum(self, keep_attrs: bool | None = None) -> T_DataWithCoords:
input_core_dims=[[self.dim]],
kwargs=dict(alpha=self.alpha, axis=-1),
output_core_dims=[[self.dim]],
exclude_dims={self.dim},
keep_attrs=keep_attrs,
on_missing_core_dim="copy",
dask="parallelized",
).transpose(*dim_order)
2 changes: 1 addition & 1 deletion xarray/tests/test_rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ def test_raise_no_warning_dask_rolling_assert_close(self, ds, name) -> None:

@requires_numbagg
class TestDatasetRollingExp:
@pytest.mark.parametrize("backend", ["numpy"], indirect=True)
@pytest.mark.parametrize("backend", ["numpy", "dask"], indirect=True)
max-sixty marked this conversation as resolved.
Show resolved Hide resolved
def test_rolling_exp(self, ds) -> None:
result = ds.rolling_exp(time=10, window_type="span").mean()
assert isinstance(result, Dataset)
Expand Down
Loading