-
-
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
Switch to T_DataArray and T_Dataset in concat #6784
Merged
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
19ec0fe
Switch to T_DataArray in concat
Illviljan 7e239ca
Switch tp T_Dataset in concat
Illviljan 55963e8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 216cb99
Update concat.py
Illviljan c190b36
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 8abb7b0
cast types
Illviljan 52b60ba
Merge branch 't_dataarray_concat' of https://github.com/Illviljan/xar…
Illviljan 66aa837
Merge branch 'main' into t_dataarray_concat
Illviljan 55e1b4d
Update concat.py
Illviljan c979a57
Update concat.py
Illviljan cce3eab
Merge branch 'main' into t_dataarray_concat
Illviljan 63e0f1d
Update concat.py
Illviljan 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
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.
Here the actual result value is hardcoded to be of type
Dataset
which would not matchT_Dataset
ifdatasets
contains some subclass ofxarray.Dataset
.Suggestion to try (which may not need the cast):
result = type(datasets[0])(result_vars, attrs=result_attrs)
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.
Nice find! I do wonder if we have this issue in more places?
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.
Yes this is quite endemic to hardcode Dataset / DataArray, rather than use the class of the argument.
We would need to make some widespread changes for this to work correctly — I think that would be welcome. We'd probably need to find a good way to test this across methods too (though maybe mypy could help there?).
And we might need a property of
Dataset
for what to class to use when returning aDataArray
, which becomes more complicated.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.
Looks like this broke somebody's subclass that doesn't support the
attrs
argument: #6827