-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Improve display of HTML reprs #10785
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
Conversation
CC folks who may have opinions/ideas here: @jsignell @eni-awowale @TomNicholas |
I like all this. Shall we add an emoji to indicate a group and separate it form the remaining sections, so |
Yeah I think this is much better. It still uses a lot of vertical space and is fairly information sparse but this is an improvement! |
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 like it!
I did a bigger clean-up of the DataTree HTML code, adding in the 📁 icon. I ended up deleting a handful of very fragile mock tests. I tried to make the folder icon / path name clickable to hide individual groups. I was able to get something working with the aid of AI code generation, but couldn't get it looking right after an hour of fiddling, so I'll let something with better CSS skills figure that out later. |
This looks great, but if we're going to hide empty sections, shouldn't we also do that for Dataset and so on? |
Probably yes? This would make text and HTML reprs more aligned. It's less of an issue for Dataset, because Dataset does not have a recursive repr. |
I've made this change for Dataset and DataArray, too. I'm now using the exact same logic for deciding to show sections between the text and HTML reprs, and added some (non-exhaustive) tests. |
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.
Amazing!
#10795 removes some of the unnecessary vertical whitespace from Jupyter notebooks. As usual with HTML formatting glitches, the issue was mostly due to defaults from inherited styles. |
The current DataTree repr never expands sub-groups, and shows all DataTree attributes even if they are empty. This makes it annoying to visualize nested DataTrees, especially if the top levels are just splitting into sub-groups.
This PR hides missing sections, and as a simple heuristic, automatically expands sub-groups if there are no data variables associated with a group level. I've also added a 📁 icon to make groups more visually distinct.
Using one of the examples from the docs:
Before:

After:

whats-new.rst