-
Notifications
You must be signed in to change notification settings - Fork 473
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
Change HTML repr away from LaTeX to a Sparse/Dask-like repr #1133
Conversation
this would definitely be a big improvement of the expanded HTML repr of xarray objects (I never really looked at the repr of quantities in a notebook so I can't comment on that), although the repr for big To properly format the collapsed or text repr we'd need to first modify |
Also, just to add a note here: assuming the The API would be _repr_inline_(max_width) returning a string. |
Pinging @hgrecco for your thoughts on this in particular as maintainer, since it's been three weeks since the initial inquiry? Thanks! |
I've been wondering whether the |
@keewis That's a good point. I wouldn't be too concerned about monkeypatching for something like In any case, since it isn't quite the simple thing I initially thought, I think it would be best to defer implementation of |
agreed. I'd say let's implement this in |
Just wanted to ping @hgrecco again on this. I'll be working on some xarray & Pint integration docs for MetPy in the near future, and it would be great to have this HTML repr in (or at have the general direction approved) by then. |
Sorry for the late reply,. pandemic times! I was also never really happy by the way pint represents this. So I agree with the change as long as an scalar is kept "normal" (as you also showed)!. Thanks for the PR (and pinging again! |
Sounds good, I'll work on the tests and then mark as ready for review! |
ec65e47
to
e59008a
Compare
537ddaa
to
93eeec4
Compare
Hopefully I've finally gotten the uncertainties stuff fixed, so (assuming it is) this should be ready for review and merge. |
93eeec4
to
f510bee
Compare
bors r+ |
Thanks for this PR! |
Build succeeded: |
While I've never been a big fan of Pint's LaTeX repr in JupyterLab/Jupyter Notebook due to working with large arrays that would crash the renderer, I've recently been working a lot with various wrapping combinations of xarray, Pint, Dask, and Sparse, in which Pint's LaTeX repr performs particularly poorly. Even if Pint's repr were elided (#765), it would still poorly nest with the other HTML reprs.
This motivated me to implement an alternative HTML repr for Pint using a simple HTML table similar to what both Dask and Sparse use. As shown in this demonstration notebook, this allows much better nesting of HTML reprs. A quick example image is below:
This doesn't quite take care of xarray's unit repr discussions (since this only shows up when expanding the data in a dataset), but I still think it is a worthwhile improvement for the expanded view. @keewis do you have any thoughts on this particular interaction?
Marking as a WIP/draft for now to see if this is a welcome format for the HTML repr first before I dig too much into optimizing the implementation and writing tests for it.
black -t py36 . && isort -rc . && flake8
with no errorsTagging @nbren12, @hgrecco, @jondoesntgit, @natezb, @ipcoder, @keewis, and @TomNicholas for input based on past issues (#654, #765, and xarray-contrib/pint-xarray#6).