-
-
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
nd-rolling #4219
Merged
Merged
nd-rolling #4219
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
1dd6b35
nd-rolling
fujiisoup 6285476
remove unnecessary print
fujiisoup dc113dc
black
fujiisoup 9a45fc7
finding a bug...
fujiisoup f74b2e8
make tests for ndrolling pass
fujiisoup d4990d7
make center and window_dim a dict
fujiisoup 531b0ec
A cleanup.
fujiisoup b6cf250
Revert test_units
fujiisoup 425ed45
make test pass
fujiisoup 54d84e5
More tests.
fujiisoup f7c4911
more docs
fujiisoup 2d82e68
Merge branch 'master' into nd_rolling
fujiisoup 2e8a76f
mypy
fujiisoup 31243b1
improve whatsnew
fujiisoup 22ba8b9
Improve doc
fujiisoup 620aca3
Merge branch 'master' into nd_rolling
fujiisoup 7404266
Merge branch 'master' into nd_rolling
fujiisoup 4b4e64a
Support nd-rolling in dask correctly
fujiisoup 43acf73
Merge branch 'master' into nd_rolling
fujiisoup 398638c
Cleanup according to max's comment
fujiisoup c4fd353
flake8
fujiisoup 28816f6
black
fujiisoup 404e78f
stop using either_dict_or_kwargs
fujiisoup 4cac857
Better tests.
fujiisoup 4bb7804
typo
fujiisoup 9703e11
mypy
fujiisoup f44dd5d
typo2
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 |
---|---|---|
|
@@ -135,14 +135,22 @@ def __setitem__(self, key, value): | |
def rolling_window(a, axis, window, center, fill_value): | ||
""" rolling window with padding. """ | ||
pads = [(0, 0) for s in a.shape] | ||
if center: | ||
start = int(window / 2) # 10 -> 5, 9 -> 4 | ||
end = window - 1 - start | ||
pads[axis] = (start, end) | ||
else: | ||
pads[axis] = (window - 1, 0) | ||
if not hasattr(axis, "__len__"): | ||
axis = [axis] | ||
window = [window] | ||
center = [center] | ||
|
||
for ax, win, cent in zip(axis, window, center): | ||
if cent: | ||
start = int(win / 2) # 10 -> 5, 9 -> 4 | ||
end = win - 1 - start | ||
pads[ax] = (start, end) | ||
else: | ||
pads[ax] = (win - 1, 0) | ||
a = np.pad(a, pads, mode="constant", constant_values=fill_value) | ||
return _rolling_window(a, window, axis) | ||
for ax, win in zip(axis, window): | ||
a = _rolling_window(a, win, ax) | ||
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. This is very clever! I spent a while trying to figure out how it works... |
||
return a | ||
|
||
|
||
def _rolling_window(a, window, axis=-1): | ||
|
Oops, something went wrong.
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.
Types on the signature should change too (indeed, I'm surprised mypy doesn't fail)