-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add chunks='auto' support for cftime datasets #10527
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
Open
charles-turner-1
wants to merge
36
commits into
pydata:main
Choose a base branch
from
charles-turner-1:autochunk-cftime
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
36 commits
Select commit
Hold shift + click to select a range
eb1a967
All works, just need to satisfy mypy and whatnot now
charles-turner-1 852476d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] c921c59
Merge branch 'main' into autochunk-cftime
charles-turner-1 1aba531
Fix moving import to be optional
charles-turner-1 9429c3d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 3c9d27e
Make mypy happy
charles-turner-1 5153d2d
Add some clarifying comments about what we need to do to optimise this
charles-turner-1 62e71e6
Merge branch 'autochunk-cftime' of https://github.com/charles-turner-…
charles-turner-1 cfdc31b
@dcherian's suggestions. Just need to update chunking strategy to res…
charles-turner-1 2f16bc7
Merge branch 'main' of https://github.com/charles-turner-1/xarray
charles-turner-1 ce720fa
Merge branch 'main' into autochunk-cftime
charles-turner-1 4fa58c1
Merge branch 'main' into autochunk-cftime
charles-turner-1 e58d6d7
Can now load cftime arrays with auto-chunking. Implementation still k…
charles-turner-1 590e503
Merge branch 'autochunk-cftime' of https://github.com/charles-turner-…
charles-turner-1 f953976
Test for autochunking when reading from disk
charles-turner-1 6706524
replace `build_chunkspec` with faking the dtype of a cftime array & a…
charles-turner-1 4e56acd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 0d008cd
Merge branch 'autochunk-cftime' of https://github.com/charles-turner-…
charles-turner-1 49c4e9c
Merge branch 'main' into autochunk-cftime
charles-turner-1 4594099
Merge branch 'autochunk-cftime' of https://github.com/charles-turner-…
charles-turner-1 5d00b0a
Remove redundant comments, rename things to make them clearer, add mo…
charles-turner-1 80421ef
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] d1f7ad3
Refactor to move most of the changes into the DaskManager
charles-turner-1 1b7de62
Merge branch 'autochunk-cftime' of https://github.com/charles-turner-…
charles-turner-1 4407185
bare-min tests should pass now?
charles-turner-1 d8f45b2
Deepak's suggestions (think mypy is still going to be angry for now)
charles-turner-1 20226c1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 11ac9f0
Merge branch 'autochunk-cftime' of https://github.com/charles-turner-…
charles-turner-1 8485df5
Fix errant line
charles-turner-1 2c27877
Clean up `DaskManager.rechunk` a bit - maybe possible to remove more …
charles-turner-1 0983261
Remove unused import
charles-turner-1 c4ec31f
Merge branch 'main' into autochunk-cftime
charles-turner-1 adbf5b2
Merge branch 'autochunk-cftime' of https://github.com/charles-turner-…
charles-turner-1 6c93bc4
Fix a couple of type errors
charles-turner-1 74bc0ea
Mypy & tests passing locally
charles-turner-1 0b9bbd0
Merge branch 'main' into autochunk-cftime
charles-turner-1 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
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
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -5742,6 +5742,34 @@ def test_open_multi_dataset(self) -> None: | |||||||
) as actual: | ||||||||
assert_identical(expected, actual) | ||||||||
|
||||||||
@requires_cftime | ||||||||
def test_open_dataset_cftime_autochunk(self) -> None: | ||||||||
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 will fix our min-deps tests
Suggested change
|
||||||||
"""Create a dataset with cftime datetime objects and | ||||||||
ensure that auto-chunking works correctly.""" | ||||||||
import cftime | ||||||||
|
||||||||
from xarray.core.common import _contains_cftime_datetimes | ||||||||
|
||||||||
original = xr.Dataset( | ||||||||
{ | ||||||||
"foo": ("time", [0.0]), | ||||||||
"time_bnds": ( | ||||||||
("time", "bnds"), | ||||||||
[ | ||||||||
[ | ||||||||
cftime.Datetime360Day(2005, 12, 1, 0, 0, 0, 0), | ||||||||
cftime.Datetime360Day(2005, 12, 2, 0, 0, 0, 0), | ||||||||
] | ||||||||
], | ||||||||
), | ||||||||
}, | ||||||||
{"time": [cftime.Datetime360Day(2005, 12, 1, 12, 0, 0, 0)]}, | ||||||||
) | ||||||||
with self.roundtrip(original, open_kwargs={"chunks": "auto"}) as actual: | ||||||||
assert isinstance(actual.time_bnds.variable.data, da.Array) | ||||||||
assert _contains_cftime_datetimes(actual.time) | ||||||||
assert_identical(original, actual) | ||||||||
|
||||||||
# Flaky test. Very open to contributions on fixing this | ||||||||
@pytest.mark.flaky | ||||||||
def test_dask_roundtrip(self) -> None: | ||||||||
|
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.
I guess this can be deleted
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.
Had a play and I don't think I can fully get rid of it, I've reused as much of the abstracted logic as possible though.