-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sliding_window_view: add new
automatic_rechunk
kwarg
- Loading branch information
Showing
7 changed files
with
141 additions
and
23 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from xarray.namedarray.utils import module_available | ||
|
||
|
||
def sliding_window_view( | ||
x, window_shape, axis=None, *, automatic_rechunk=True, **kwargs | ||
): | ||
# Backcompat for handling `automatic_rechunk`, delete when dask>=2024.11.0 | ||
# subok, writeable are unsupported by dask | ||
from dask.array.lib.stride_tricks import sliding_window_view | ||
|
||
if module_available("dask", "2024.11.0"): | ||
return sliding_window_view( | ||
x, window_shape=window_shape, axis=axis, automatic_rechunk=automatic_rechunk | ||
) | ||
else: | ||
# automatic_rechunk is not supported | ||
return sliding_window_view(x, window_shape=window_shape, axis=axis) |
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
Oops, something went wrong.