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
update
update()
max.experimental.tree_utils.update(tree, state, *, leaf=None, shared=False)
Writes path-keyed values into tree, in place.
The counterpart of paths(), taking the same knobs. Only leaves are
written, and an unnamed leaf is left alone.
-
Parameters:
-
- tree (Any) – The tree to write into. Mutated.
- state (Mapping[str, Any]) – The values to write, keyed by dotted path as
paths()returns them. - leaf (type | tuple[type, ...] | Callable[[Any], bool] | None) – Where the walk stops, and so what counts as a writable position.
- shared (bool) – Whether a value reachable by two paths is one leaf or two. Set, one write reaches every path to it, and the tie survives.
-
Returns:
-
treeitself, or a rebuilt root when the root is atuple. -
Raises:
-
- TypeError – If a value must be written under a positional key and its
node declares no
__tree_setattr__. - ValueError – If some entry in
statenames no leaf intree.
- TypeError – If a value must be written under a positional key and its
node declares no
-
Return type: