-
Notifications
You must be signed in to change notification settings - Fork 44
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
html repr #78
html repr #78
Conversation
for more information, see https://pre-commit.ci
Thanks for doing the ping @TomNicholas! Let me also ping @benbovy since he did the majority of the work on the xarray repr. |
Is there a way to indent everything but groups? That might help clarify that groups is the 'top level' organizer and everything beneath it is just another leaf-dataset? Unless I totally did not understand that right, hehe. |
I don't think that makes sense - Variables and sub-Groups exist at the same level within a given Group. In the topmost (i.e. root) group you can select a Variable via |
You might be right, my main reason to say that is that the output is quite large (long scroll) and visually very homogenous to look at. This can make it hard to find the thing you are looking for. Additionally some visual elements like in the dask client repr could help the user grasp the high level structure of the tree more easily. These rounded boxes (or something similar) could be color coded for e.g. (leaf, branch etc). |
This line should control how many items a group dropdown must have before it is folded by default. If we set it to 0 it should fold all groups be default.
This is trickier, but I agree some kind of graphical representation would be nice. I do like the way the printable string repr shows you the structure. This is so much harder for me to implement though that I might leave it to a second PR. |
Yeah absolutely, this was a 'nice to have' from my end. Not required. Root level folding seems very beneficial for large sets of groups, so that would be nice to implement here (and it seems quite easy). |
Thanks for the ping @jsignell, and also glad to see that it was easy to reuse the xarray repr code here (with the hope that the hacks used there won't have too much impact here).
I think this could be already achieved - although a bit less fancy than the dask repr - with some basic UI design applied to the group names like font-weight or color variation(s), or by prepending repeated symbol(s) (dot, cross, etc.) to those names so that it informs about their hierarchical level. |
This diff is impressively small! |
Makes sense @benbovy - that is basically how anytree achieves this:
I imagine I could use similar logic to how anytree's |
"<ul class='xr-sections'>" | ||
f"<div style='padding-left:2rem;'>{children_li}<br></div>" | ||
"</ul>" |
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'm currently padding the sub-groups here to indent them, but I think this is where I would need to add lines instead.
I'm going to merge this now and leave #87 up to discuss how to improve the html repr in the future. |
* html repr displays data in root group * displays under name 'xarray.DataTree' * creates a html repr for each sub-group, but it looks messed up * correctly indents sub-groups * show names of groups * refactoring * dodge type hinting bug * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix failing test in merg * fix bug caused by merge * whatsnew Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
My attempt at an arbitrarily-deeply nested html repr.
That's for the test datatree, whose string repr currently looks like this:
I'm pretty pleased with this, but open to feedback.
Some things I think could be improved are:
Not really sure how to test it exactly either.
pre-commit run --all-files
api.rst
@jsignell you will probably be interested to see this - thanks for making the xarray html repr code so neat that I was able to easily extend it!
@rabernat @jbusecke opinions welcome too