Autovisualizer

Autovisualizer#

class treescope.Autovisualizer[source]#

Bases: Protocol

Protocol for autovisualizers.

An autovisualizer is a callable object that can be used to customize Treescope for rendering purposes. The active autovisualizer is called once for each subtree of a rendered PyTree, and can choose to:

  • render it normally (but possibly customize its children),

  • replace the rendering of that PyTree with a custom rich display object,

  • or replace the current autovisualizer with a new one that will be active while rendering the children.

Methods

__init__(*args, **kwargs)

__call__(value, path)

Runs the autovisualizer on a node at a given path.

abstract __call__(value: Any, path: str | None) IPythonVisualization | VisualizationFromTreescopePart | ChildAutovisualizer | None[source]#

Runs the autovisualizer on a node at a given path.

Parameters:
  • value – A value being rendered in treescope.

  • path – Optionally, a path to this node, represented as a string that can be used to reach this node from the root (e.g. “.foo.bar[‘baz’]”).

Returns:

A visualization for this subtree, a child autovisualizer to use while rendering the node’s children, or None to continue rendering the node normally using the current autovisualizer.