-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
support dask arrays in rolling computations using bottleneck functions #1568
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9b1b16d
support dask arrays in rolling computations using bottleneck functions
2147ffc
add dask_array_ops.py and fixes for dask/rolling
cee71ff
skip dask rolling tests when dask is not installed
efe37c6
minimum bottleneck version ==> 1.1
f1819db
cleanup
7bbbbf4
better error/warning messages when unsupported version of bottleneck …
d532a1f
simplier checking of bottleneck version
5945572
stop checking bottleneck version
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 hidden or 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 |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ dependencies: | |
| - seaborn | ||
| - toolz | ||
| - rasterio | ||
| - bottleneck | ||
| - pip: | ||
| - coveralls | ||
| - pytest-cov | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| """Define core operations for xarray objects. | ||
| """ | ||
| import numpy as np | ||
|
|
||
| try: | ||
| import dask.array as da | ||
| except ImportError: | ||
| pass | ||
|
|
||
|
|
||
| def dask_rolling_wrapper(moving_func, a, window, min_count=None, axis=-1): | ||
| '''wrapper to apply bottleneck moving window funcs on dask arrays''' | ||
| # inputs for ghost | ||
| if axis < 0: | ||
| axis = a.ndim + axis | ||
| depth = {d: 0 for d in range(a.ndim)} | ||
| depth[axis] = window - 1 | ||
| boundary = {d: np.nan for d in range(a.ndim)} | ||
| # create ghosted arrays | ||
| ag = da.ghost.ghost(a, depth=depth, boundary=boundary) | ||
| # apply rolling func | ||
| out = ag.map_blocks(moving_func, window, min_count=min_count, | ||
| axis=axis, dtype=a.dtype) | ||
| # trim array | ||
| result = da.ghost.trim_internal(out, depth) | ||
| return result |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
Can we trigger this warning lazily (e.g., when calling actually resample)? If we do this at import time we are going to get a lot of complaints from users using bottleneck < 1.1 about irrelevant warnings.