stacking#

Convert a Python tree of separate objects <-> one stacked object.

stack/unstack, tree_zip, apply_func_to_leaf_subtrees, and the basic ragged/uniform twins. This is one of three distinct meanings of “stacking” in the library – distinct from leading stack_shape batch axes on one object’s cores, and from the uniform supercore representation (docs/batching_and_stacking.md).

Functions#

tree_depth(t)

get_first_leaf(xx)

trees_have_same_structure(tree1, tree2)

Checks if two trees (nested sequences) have the same structure.

apply_func_to_leaf_subtrees(tree, func, leaf_structure)

Apply a function to all "leafs" in a tree.

stack(T, axes)

Stack array-like nested tree structure.

unstack(S, axes)

Unstack nested sequence of arrays along specificed array axes.

sum_leafs_along_axes(S, axes)

Sum leafs of a tree of NDArrays along specified axes.

basic_ragged_unstack(x, first_leaf_num_nonstacking_axes)

Unstack stacked ragged array tuple into array-like tree

basic_ragged_stack(xx)

Stack array-like tree of ragged array tuples into single ragged array tuple.

basic_uniform_unstack(x, first_leaf_num_nonstacking_axes)

Unstack stacked uniform array tuple into array-like tree

basic_uniform_stack(xx)

Stack array-like tree of uniform array tuples into single ragged array tuple.

tree_zip(T1, T2)

Zips two trees with the same structure.