The print_child_tree function#

Aliases#

halerium.core.print_child_tree
print_child_tree(scopetor, extractor=<function <lambda>>, stop_criterion=None)#

Print child tree.

Prints the scopetor, all its children, all the children of these children, and so on, in a tree-like structure for quick visual inspection. What information is to be printed for each child can be controlled by the extractor argument.

Parameters:
  • scopetor – The scopetor whose child tree to print.

  • extractor (callable) – The extractor function controlling what information is to be printed for each child. It must take one scopee as argument and return what is to be printed for that scopee. The default just returns the scopee’s name.

  • stop_criterion (callable, None) – A stopping criterion. When applying it to a scopee in the tree yields True, stop going deeper into the branch of that scopee.

Examples

>>> from halerium.core import Graph, Variable, Entity
>>> from halerium.core.utilities.print import print_child_tree
>>>
>>> with Graph('g') as g:
>>>     with g.inputs:
>>>         Variable('i')
>>>     with Entity('e') as e:
>>>         Variable('v')
>>>         Variable('w')
>>>
>>> print_child_tree(g)

g ├─e │ ├─v │ └─w ├─inputs │ └─i └─outputs