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

boundary options for rolling.construct #3587

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

fujiisoup
Copy link
Member

@fujiisoup fujiisoup commented Dec 2, 2019

Added some boundary options for rolling.construct.
Currently, the option names are inherited from np.pad, ['edge' | 'reflect' | 'symmetric' | 'wrap'].
Do we want a more intuitive name, such as periodic?

@pep8speaks
Copy link

pep8speaks commented Dec 2, 2019

Hello @fujiisoup! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-12-03 05:17:40 UTC

@@ -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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the default should be constant, which would match np.pad?

@@ -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
Copy link
Member

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 this pad_mode or boundary_mode?

Copy link
Contributor

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 have da.pad(mode="constant").

if version.LooseVersion(dask.__version__) < "1.7":
if mode is not None:
raise NotImplementedError(
"dask >= 1.7 is required for mode={}.".format(mode)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the right version number for dask? I can't find a 1.7 release.

Also note that we only need to support versions of dask < 6 months old, per http://xarray.pydata.org/en/stable/installing.html. If we can just delete the old code entirely, that might be cleaner.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dask API page says it came at the version 1.7, but I just noticed this doc is just copied from numpy...
I'll fix it.

@dcherian dcherian mentioned this pull request Dec 3, 2019
@mathause
Copy link
Collaborator

mathause commented Dec 4, 2019

Thanks for picking this up - excited to get this in! Are you able to get it to work with dask arrays? (That was the stopper in my PR.) Or maybe you can require that dask arrays are not chunked along the rolling dimension?

@mathause
Copy link
Collaborator

@fujiisoup I would eventually like to pick this one up. Can you remember what was missing? Mostly the tests?

@fujiisoup
Copy link
Member Author

I was thinking to wait for the pad method implemented but forgot until now.
I am not sure this is easily merginable, as the rolling.py has been updated for a while...

The first motivation was to implement the rolling operation for the periodic coordinate, but it is not yet implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rolling: allow control over padding
5 participants