Skip to content

Allow no padding for rolling windows #5603

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

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
039a9bf
Allow padding to be turned off for rolling windows
kmsquire Jul 9, 2021
90228b0
Fix iteration on rolling windows to handle no padding
kmsquire Jul 14, 2021
c43db78
Add tests for rolling(..., pad=False)
kmsquire Jul 15, 2021
30a0b47
Update xarray/core/rolling.py
kmsquire Jul 19, 2021
0314d2f
Update xarray/core/rolling.py
kmsquire Jul 19, 2021
18562b8
Rename _get_rolling_dim_coords -> _get_output_coords
kmsquire Jul 19, 2021
90ae11d
Add comment better explaining _get_output_coords
kmsquire Jul 19, 2021
33ccbf6
Simplify _get_output_coords
kmsquire Jul 19, 2021
5df7b12
Remove utils.get_slice_offsets (unused)
kmsquire Jul 19, 2021
174750a
Simplify get_pads
kmsquire Jul 20, 2021
564833a
Fix rolling object construction in _count
kmsquire Jul 20, 2021
68b112a
Skip padding in variable.rolling if not required
kmsquire Jul 20, 2021
ea332a6
Fix rolling on DataArrays with nonunique dimension coordinates
kmsquire Jul 20, 2021
ef0ac63
Rename expand_args_to_num_dims -> expand_args_to_dims
kmsquire Jul 20, 2021
cdadc60
Update expand_args_to_dims
kmsquire Jul 20, 2021
a2b235c
Update get_pads() types, comments
kmsquire Jul 20, 2021
b98ab3a
Use "length" instead of "count" to refer to the length of a coordinate
kmsquire Jul 20, 2021
b36a049
Update type of _get_output_dim_selector
kmsquire Jul 20, 2021
61428ed
Merge remote-tracking branch 'upstream/main' into feature/rolling-pad
dcherian Aug 11, 2021
923a598
fixes.
dcherian Aug 11, 2021
fea9baf
Add whats-new
dcherian Aug 11, 2021
2084c08
minor test cleanup
dcherian Aug 11, 2021
c29d1fb
consolidate bottleneck dataarray test
dcherian Aug 11, 2021
b509ebf
consolidate bottleneck dataset tests
dcherian Aug 11, 2021
5a2eadc
more test cleanup
dcherian Aug 11, 2021
28a4ad2
Merge remote-tracking branch 'upstream/main' into feature/rolling-pad
dcherian Mar 27, 2023
b963b29
merge tests
dcherian Mar 28, 2023
d02d2fd
Merge remote-tracking branch 'upstream/main' into feature/rolling-pad
dcherian Mar 29, 2023
072e87c
Merge remote-tracking branch 'upstream/main' into feature/rolling-pad
dcherian Mar 21, 2024
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
2 changes: 2 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ v2024.03.0 (unreleased)
New Features
~~~~~~~~~~~~

- Allow control over padding in rolling. (:issue:`2007`, :pr:`5603`).
By `Kevin Squire <https://github.com/kmsquire>`_.
- Do not broadcast in arithmetic operations when global option ``arithmetic_broadcast=False``
(:issue:`6806`, :pull:`8784`).
By `Etienne Schalk <https://github.com/etienneschalk>`_ and `Deepak Cherian <https://github.com/dcherian>`_.
Expand Down
5 changes: 4 additions & 1 deletion xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -6852,6 +6852,7 @@ def rolling(
dim: Mapping[Any, int] | None = None,
min_periods: int | None = None,
center: bool | Mapping[Any, bool] = False,
pad: bool = True,
**window_kwargs: int,
) -> DataArrayRolling:
"""
Expand Down Expand Up @@ -6919,7 +6920,9 @@ def rolling(
from xarray.core.rolling import DataArrayRolling

dim = either_dict_or_kwargs(dim, window_kwargs, "rolling")
return DataArrayRolling(self, dim, min_periods=min_periods, center=center)
return DataArrayRolling(
self, dim, min_periods=min_periods, center=center, pad=pad
)

def cumulative(
self,
Expand Down
5 changes: 4 additions & 1 deletion xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -10329,6 +10329,7 @@ def rolling(
dim: Mapping[Any, int] | None = None,
min_periods: int | None = None,
center: bool | Mapping[Any, bool] = False,
pad: bool = True,
**window_kwargs: int,
) -> DatasetRolling:
"""
Expand Down Expand Up @@ -10362,7 +10363,9 @@ def rolling(
from xarray.core.rolling import DatasetRolling

dim = either_dict_or_kwargs(dim, window_kwargs, "rolling")
return DatasetRolling(self, dim, min_periods=min_periods, center=center)
return DatasetRolling(
self, dim, min_periods=min_periods, center=center, pad=pad
)

def cumulative(
self,
Expand Down
Loading