Display
SVG rendering for Tree, Forest, ForestSum and TensorProductSum objects.
Displaying a tree
import kauri as kr
t = kr.Tree([[],[[]]])
kr.display(t)
Displaying a colored tree
import kauri as kr
t = kr.Tree([[[3],2],[1],0])
kr.display(t)
Displaying a forest
import kauri as kr
f = kr.CommutativeForest((kr.Tree([]), kr.Tree([[]]), kr.Tree([])))
kr.display(f)
Displaying a ForestSum
import kauri as kr
import kauri.bck as bck
t = kr.Tree([[],[]])
kr.display(bck.antipode(t))
Displaying a TensorProductSum
import kauri as kr
import kauri.bck as bck
t = kr.Tree([[],[]])
kr.display(bck.coproduct(t))
Displaying a planar tree and ordered forest
import kauri as kr
t = kr.PlanarTree([[],[[]]])
f = kr.NoncommutativeForest((kr.PlanarTree([[]]), kr.PlanarTree([])))
kr.display(t, f)
Displaying multiple objects side by side
Multiple arguments are rendered in a single image, analogous to
print(a, b, c). Strings are rendered as text labels:
import kauri as kr
t = kr.Tree([[], [[]]])
kr.display(t, "\u2192", t.unjoin())
- display(*objects: Tree | CommutativeForest | ForestSum | TensorProductSum | PlanarTree | NoncommutativeForest | str, scale: float = 1.0, fig_size: tuple = None, file_name: str = None, use_plt: bool = None, rationalise: bool = False) None[source]
Display one or more tree-algebra objects, optionally with string labels.
In Jupyter, renders inline SVG.
Multiple arguments are rendered side by side in a single image, analogous to
print(a, b, c). Strings are rendered as text labels between objects, e.g.display(t, "→", t.unjoin()).- Parameters:
objects – One or more objects or strings to display
scale – Scale factor for SVG output (default 1.0)
file_name – If provided, saves SVG to
file_name.svgrationalise – If True, rationalise float coefficients