archimedes.tree.leavesΒΆ

archimedes.tree.leaves(tree: Tree, is_leaf: Callable[[Any], bool] | None = None) list[ArrayLike]ΒΆ

Extract all leaf values from a tree.

Parameters:
  • tree (Tree) – A tree from which to extract leaves.

  • is_leaf (callable, optional) – A function that takes a tree node as input and returns a boolean indicating whether it should be considered a leaf.

Returns:

leaves – A list of all leaf values from the tree.

Return type:

list

See also

tree_flatten

Flatten a tree into a list of leaves and a treedef

tree_map

Apply a function to each leaf in a tree