For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Python function
unflatten
unflatten()
max.tree.unflatten(treedef, leaves, *, exact=True)
Rebuilds a tree from a structure and its leaves.
The inverse of flatten(), always building a fresh tree.
-
Parameters:
-
- treedef (TreeDef) – The structure, as
flatten()reported it. - leaves (Iterable[Any]) – One value per leaf slot, left to right; with
exact, any trailing values are left unconsumed. - exact (bool) – When
False, stop after the structure’s leaves and leave trailing values (e.g. a shared iterator’s later items) in place instead of raising. Too few leaves is always an error.
- treedef (TreeDef) – The structure, as
-
Returns:
-
The rebuilt tree.
-
Raises:
-
- TypeError – If a cycle closes through a node whose class declares no
__tree_empty__. - ValueError – If there are too few leaves for the structure (or too many
when
exactisTrue), or iftreedefdid not come fromflatten().
- TypeError – If a cycle closes through a node whose class declares no
-
Return type: