-
-
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
Update Datatree html repr to indicate inheritance #9633
Merged
TomNicholas
merged 7 commits into
pydata:main
from
TomNicholas:datatree-html-repr-inherited
Oct 21, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3979fca
_inherited_vars -> inherited_vars
TomNicholas 21d0e95
implementation using Coordinates
TomNicholas ca7e3e8
datatree.DataTree -> xarray.DataTree
TomNicholas 01a923c
only show inherited coordinates on root
TomNicholas 7a6708e
test that there is an Inherited coordinates header
TomNicholas 596d8e0
Merge branch 'main' into datatree-html-repr-inherited
TomNicholas 77c1e8f
Merge branch 'main' into datatree-html-repr-inherited
TomNicholas 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
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 |
---|---|---|
|
@@ -320,6 +320,25 @@ def test_two_children( | |
) | ||
|
||
|
||
class TestDataTreeInheritance: | ||
def test_inherited_section_present(self) -> None: | ||
dt = xr.DataTree.from_dict( | ||
{ | ||
"/": None, | ||
"a": None, | ||
} | ||
) | ||
with xr.set_options(display_style="html"): | ||
html = dt._repr_html_().strip() | ||
# checks that the section appears somewhere | ||
assert "Inherited coordinates" in html | ||
|
||
# TODO how can we assert that the Inherited coordinates section does not appear in the child group? | ||
# with xr.set_options(display_style="html"): | ||
# child_html = dt["a"]._repr_html_().strip() | ||
# assert "Inherited coordinates" not in child_html | ||
Comment on lines
+336
to
+339
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. I'm not really sure how to test this any better. Both the correct and incorrect behaviour would give |
||
|
||
|
||
class Test__wrap_datatree_repr: | ||
""" | ||
Unit tests for _wrap_datatree_repr. | ||
|
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 assume this logic now basically matches that in
datatree_repr
?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.
That's the idea yes