-
-
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
apply to dataset #4863
Open
keewis
wants to merge
36
commits into
pydata:main
Choose a base branch
from
keewis:apply-to-dataset
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
apply to dataset #4863
Changes from 25 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
5655571
add a apply_to_dataset method
keewis 90f8d55
write a test for apply_to_dataset on a DataArray
keewis fd2c897
also add a test for dataset
keewis 857c783
convert apply_to_dataset to a top-level function
keewis 57e94b6
update whats-new.rst
keewis cdb0f3d
add the new function to api.rst [skip-ci]
keewis 1d81a49
rephrase the note [skip-ci]
keewis 88fe863
add a see also section [skip-ci]
keewis 0daf42d
add examples [skip-ci]
keewis ef3f791
Merge branch 'master' into apply-to-dataset
keewis 638d61c
Merge branch 'master' into apply-to-dataset
keewis 559d8ef
rename to call_on_dataset
keewis 0c424bf
preserve the name as much as possible
keewis 8db9e7e
update api.rst
keewis c902dfe
Merge branch 'master' into apply-to-dataset
keewis 43bf70d
update whats-new.rst
keewis 31645e5
remove the notes
keewis 293d9c1
remove the no-op
keewis d0de1ca
don't rename to None
keewis a822232
rename to "<this-array>"
keewis d278919
rewrite [skip-ci]
keewis 0669da9
Merge branch 'master' into apply-to-dataset
keewis 97d4338
rename back to None
keewis 48109db
Merge branch 'master' into apply-to-dataset
keewis b15d45e
Merge branch 'master' into apply-to-dataset
keewis 371f509
introduce a mandatory name parameter to use as a name for the data va…
keewis 8f37872
Merge branch 'master' into apply-to-dataset
keewis c9459f7
move to the new section in whats-new.rst
keewis 021ad36
fix the tests
keewis dcb747b
Merge branch 'master' into apply-to-dataset
keewis 7081e15
update the input and expected values
keewis 52a39f3
add the missing name for the dataset call
keewis fcfaaa5
use DataArray.to_dataset instead
keewis f2d2880
only convert if the result is a Dataset
keewis b59dd1e
Merge branch 'master' into apply-to-dataset
dcherian 12400cb
Merge branch 'main' into apply-to-dataset
keewis 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ Top-level functions | |
apply_ufunc | ||
align | ||
broadcast | ||
call_on_dataset | ||
concat | ||
merge | ||
combine_by_coords | ||
|
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
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.
another option would be to use
backends.core.api.DATAARRAY_VARIABLE
which is used when writing a DataArray to netcdf (I think). I don't feel strongly about this.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.
yeah, I don't know which name would be better, either.
THIS_ARRAY
is not part of the public API so we can't use it, andNone
obviously doesn't work, either. Using a string seems like a good choice but the exact value will almost always be arbitrary. The advantage of"<this-array>"
is that it is the string representation ofTHIS_ARRAY
, but that's the only reason I chose that.DATAARRAY_VARIABLE
orDATAARRAY_NAME
have the valuef"__xarray_dataarray_{type}__"
, but neither of them are actually part of the public API (I think?), which means they have the same issue asTHIS_ARRAY
(not sure if that's actually a problem, though: the simply reference a string).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 thought @keewis 's idea of
self
was good from #5493 (comment), to the extent that could apply hereEdit: but then @dcherian pointed out this will fail if there's a dim called
self
!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 used this in xarray-contrib/pint-xarray#110, and for that at least it's actually an advantage that I have to pass the name. Not sure if that's the same for every other use case though (but defining the name explicitly is not much overhead so it should be fine)