pydata / xarray

N-D labeled arrays and datasets in Python
https://xarray.dev
Apache License 2.0
3.61k stars 1.08k forks source link

Extracting `formatting_html` as a standalone library? #5022

Open darikg opened 3 years ago

darikg commented 3 years ago

Hi, xarray is a superb library but my favorite icing on the cake is the out-of-the-box rich HTML display in Jupyter. I've been finding myself wanting the same thing for every class I use in python that is fundamentally a hierachically structured numerical dataset.

Has there been any discussion of generalizing the whole thing? I'd be happy to give it a shot myself, but I was hoping to pick your collective brains first, especially @benbovy and @jsignell, (who based on my very preliminary github sleuthing were early heavy-lifters?)

jsignell commented 3 years ago

I'm glad you like it! @benbovy really did all the work on writing it. I think there was some talk of extracting it to a separate library, but I'm not sure if it was obvious how to generalize it. It depends whether you would want it to be a standalone library (like pprint) or whether you'd want the libraries to integrate with it (probably using entrypoints).

I would start by thinking about one or two other classes that you'd like to see represented this way and try to see how well what currently exists generalizes.

benbovy commented 3 years ago

I'm glad too that you like it. Without the work of @jsignell this would likely still be an open, unfinished PR!

Not sure either how we could generalize it. Also, note that the CSS code used for displaying this rich output is not super robust: it relies on some dirty hacks that required special care in some front-ends (e.g., https://github.com/pydata/pydata-sphinx-theme/issues/274). It's still not displayed correctly when notebooks are rendered on GitHub (although in general GitHub's notebook rendering is not quite reliable anyway).

darikg commented 3 years ago

Thank you both! I'll report back if I get anywhere with it