awkward icon indicating copy to clipboard operation
awkward copied to clipboard

HTML repr for awkward instances

Open martindurant opened this issue 4 years ago • 4 comments

Description of new feature

The current implementation shows awkward instances (principally arrays) as blocks of XML. Since a lot of usage will be via notebooks, it would be very helpful to provide a visual layout, including expandable sections. The dask project has undertaken such work over the last couple of years, and users of, for example, the array API have found it to be very useful.

martindurant avatar Sep 21 '21 14:09 martindurant

This was something I thought about recently too. I started hacking away at it, but ran out of time. Thanks for ear-marking this with an issue :)

agoose77 avatar Sep 21 '21 14:09 agoose77

The XML blocks are for the layouts only, which are public API, but somewhat of a "debugging view" for developers. (Awkward v2 can't be wrapped with the high-level ak.Array yet, so right now, it's the only view for v2.) The choice of XML was because it's human readable, has a natural indentation, and kinda looks like standard Python reprs that are enclosed in angle brackets (<, >). The motivations weren't any deeper than that, and there is no program that I know of that expects them to be strict XML.

HTML views would be cool, but that strikes me as a high-level thing, for ak.Array. (Though I suppose both high- and low-level views could get an HTML treatment.) I wonder what form it should take: nested boxes? a tree?

It would be important for the default rendering to not be large, even if the type contains records with many fields. These things will pop up in output, unasked for, and it can be annoying when such things make the window scroll (like Matplotlib's histograms when you forget to add a semicolon).

Maybe if the representation starts small and only gets big if you click on parts to unpack them? (Like a GitHub diff, which provides more context if you click on "...".) Maybe type information could be integrated into values?

jpivarski avatar Sep 21 '21 15:09 jpivarski

Oh certainly for both! I was mainly talking about the contents/layout XML, but it would make a lot of sense to include that in the higher-level objects too, as expandable parts. Note that the text repr, when not in the notebook, will remain unchanged.

martindurant avatar Sep 21 '21 15:09 martindurant

This isn't pressing for this release.

agoose77 avatar Nov 15 '22 17:11 agoose77