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.
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
Fix
DataTree.coords.__setitem__
by addingDataTreeCoordinates
class #9451Fix
DataTree.coords.__setitem__
by addingDataTreeCoordinates
class #9451Changes from 5 commits
704db79
417e3e9
9562e92
0e7de82
839858f
9370b9b
9b50567
c466f8d
0397eca
85bb221
7802c63
1bf5082
e8620cf
1108504
0a7201b
51e11bc
7ecdd16
dfcdb6d
3278153
f672c5e
7fb1622
897b7c4
b5a56f4
fdae5bc
9dc845a
6595fe9
ed87554
c155bc1
217cb84
540bb0f
7126efa
8486227
12f24df
8f09c93
d23105f
978e05e
bd47575
8ef94df
10b8a78
b9ede22
540a825
b30d5e0
639ad07
0a9a328
80bc0bd
a366bf6
4d352bd
4626fa8
ea8a195
af94af4
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 can't see an easy way to make assignment of coordinates to parent nodes work. I think it would be better just to have
dt.coords
constructed from inherited coords, but not allow setting coordinates further up the tree. I believe that's consistent with the behaviour we currently have fordt.__setitem__
anyway.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.
Agreed!
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.
Inheriting from
Coordinates
and usingDataTree
instead ofDataWithCoords
here both expose a few legitimate typing issues. Particularly:DataTree
doesn't directly inherit fromDataWithCoords
, though maybe it could inherit from a future version of it (see Refactor Dataset internals to store data variables and coordinate variables as separate dicts #9203 (comment))Hashable
vsstr
annoyances (DataTree should support Hashable names. #8836)Mostly we have got away with these discrepancies so far but inheritance here is probably going to mean I need to either
ignore
orcast
all over the place?cc @headtr1ck
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.
actually this wasn't very difficult to work around, it mostly just required adding a
type: ignore[assignment]
here :)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 think this should be fine. Dimensions on
DatasetCoordinates
also include dimensions that are only present on data variables.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.
Really? This (on
main
) looks wrong to me:I mean the fact no-one has raised this before means it probably isn't of much consequence, but it does seem incorrect / misleading.
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.
Raised #9466 to track 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.
I think it is OK for this to be an error. The user can replace those coordinates on the parent nodes.
Check failure on line 611 in xarray/tests/test_datatree.py
GitHub Actions / ubuntu-latest py3.10 bare-minimum
Check failure on line 611 in xarray/tests/test_datatree.py
GitHub Actions / macos-latest py3.10
Check failure on line 611 in xarray/tests/test_datatree.py
GitHub Actions / ubuntu-latest py3.11 all-but-dask
Check failure on line 611 in xarray/tests/test_datatree.py
GitHub Actions / macos-latest py3.12
Check failure on line 611 in xarray/tests/test_datatree.py
GitHub Actions / ubuntu-latest py3.10 min-all-deps
Check failure on line 611 in xarray/tests/test_datatree.py
GitHub Actions / ubuntu-latest py3.10
Check failure on line 611 in xarray/tests/test_datatree.py
GitHub Actions / ubuntu-latest py3.12