penzai.treescope.treescope_ipython.register_as_default(fancy_selections: bool = True, streaming: bool = True, compress_html: bool = True)[source]#

Registers treescope as the default IPython renderer.

This tells IPython to use treescope as a renderer for any object that doesn’t have a specific renderer registered with IPython directly.

Treescope will be configured to produce an HTML representation of most objects that do not have their own custom renderers. It will also be configured to produce summaries of jax.Array in text mode. Note that due to the way that IPython’s text prettyprinter works, we can’t easily set it up as a fallback renderer in text mode because IPython will prefer to use ordinary repr if it exists.

Note that this hooks into every use of IPython.display.display(...). To avoid messing up ordinary display objects, if the object has a _repr_html_ method already, we defer to that. (But if it’s a structure containing display objects, we still use treescope as normal.)

  • fancy_selections – Whether to use a fancy renderer for selections, outlining the selected nodes, instead of directly showing the repr of the selection object itself.

  • streaming – Whether to render in streaming mode, which immediately displays the structure of the output while computing more expensive leaf renderings. This is useful in interactive contexts, but can mess with other users of IPython’s formatting because the final rendered HTML is empty.

  • compress_html – Whether to zlib-compress (i.e. zip) treescope renderings to reduce their size when transmitted to the browser or saved into a notebook.


RuntimeError – If IPython is not available.