register_as_default#
- treescope.register_as_default[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.)If the root object being rendered defines the special method
__treescope_root_repr__
, that method will be assumed to take no arguments and return a representation of the root object in Treescope’s intermediate representation. This can be used to fully customize the rendering of a particular type of object. (Most types should instead define__treescope_repr__
, which allows the rendering to be customized at any level of the tree, not just the root.)- Parameters:
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.
- Raises:
RuntimeError – If IPython is not available.