-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
boundary options for rolling.construct #3587
Open
fujiisoup
wants to merge
8
commits into
pydata:main
Choose a base branch
from
fujiisoup:periodic_rolling
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0cdcc88
added boundary options for rolling
fujiisoup b895c0f
Merge branch 'master' into periodic_rolling
fujiisoup 730be82
Minor doc fixes
fujiisoup 4b3c6db
support old dask
fujiisoup e40d78d
black
fujiisoup c134e78
remove the old dask support. Bump up the minimum dask version
fujiisoup dfabeda
Try with dask2.0
fujiisoup 5676037
dask 1.2.2, distributed 1.28
fujiisoup File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,7 +193,7 @@ def __iter__(self): | |
|
||
yield (label, window) | ||
|
||
def construct(self, window_dim, stride=1, fill_value=dtypes.NA): | ||
def construct(self, window_dim, stride=1, fill_value=dtypes.NA, mode=None): | ||
""" | ||
Convert this rolling object to xr.DataArray, | ||
where the window dimension is stacked as a new dimension | ||
|
@@ -206,6 +206,11 @@ def construct(self, window_dim, stride=1, fill_value=dtypes.NA): | |
Size of stride for the rolling window. | ||
fill_value: optional. Default dtypes.NA | ||
Filling value to match the dimension size. | ||
mode: optional. Default None | ||
One of None | 'edge' | 'reflect' | 'symmetric' | 'wrap' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe the default should be |
||
For the details of the mode, see | ||
https://docs.scipy.org/doc/numpy/reference/generated/numpy.pad.html | ||
If it is not None, fill_value is ignored. | ||
|
||
Returns | ||
------- | ||
|
@@ -234,7 +239,12 @@ def construct(self, window_dim, stride=1, fill_value=dtypes.NA): | |
from .dataarray import DataArray | ||
|
||
window = self.obj.variable.rolling_window( | ||
self.dim, self.window, window_dim, self.center, fill_value=fill_value | ||
self.dim, | ||
self.window, | ||
window_dim, | ||
self.center, | ||
fill_value=fill_value, | ||
mode=mode, | ||
) | ||
result = DataArray( | ||
window, dims=self.obj.dims + (window_dim,), coords=self.obj.coords | ||
|
@@ -466,7 +476,7 @@ def _numpy_or_bottleneck_reduce( | |
**kwargs, | ||
) | ||
|
||
def construct(self, window_dim, stride=1, fill_value=dtypes.NA): | ||
def construct(self, window_dim, stride=1, fill_value=dtypes.NA, mode=None): | ||
""" | ||
Convert this rolling object to xr.Dataset, | ||
where the window dimension is stacked as a new dimension | ||
|
@@ -479,6 +489,10 @@ def construct(self, window_dim, stride=1, fill_value=dtypes.NA): | |
size of stride for the rolling window. | ||
fill_value: optional. Default dtypes.NA | ||
Filling value to match the dimension size. | ||
mode: optional. Default None | ||
One of None | 'edge' | 'reflect' | 'symmetric' | 'wrap' | ||
For the details of the mode, see | ||
https://docs.scipy.org/doc/numpy/reference/generated/numpy.pad.html | ||
|
||
Returns | ||
------- | ||
|
@@ -491,7 +505,7 @@ def construct(self, window_dim, stride=1, fill_value=dtypes.NA): | |
for key, da in self.obj.data_vars.items(): | ||
if self.dim in da.dims: | ||
dataset[key] = self.rollings[key].construct( | ||
window_dim, fill_value=fill_value | ||
window_dim, fill_value=fill_value, mode=mode | ||
) | ||
else: | ||
dataset[key] = da | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mode
seems a little vague here in the context of constructing a rolling window. Maybe we could call thispad_mode
orboundary_mode
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pad_mode
seems better since we should eventually haveda.pad(mode="constant")
.