larch.model.tree.NestingTree.new_node
larch.model.tree.NestingTree.new_node¶
- NestingTree.new_node(*, code=None, **kwarg)[source]¶
Add a new nesting node to this NestingTree.
A new unique code is automatically created and returned by this method for creating new nests.
All arguments must be given as keyword parameters.
- Parameters
parameter (str) – The name of the parameter to associate with this nest.
children (Collection[int], optional) – The code numbers for the children of this nest. These can be elemental alternatives or other nests. If not given, no children will be defined initially, but they can be added later.
parent (int, optional) – The code number for the parent of this nest. If not given, the parent is implied as the root node, unless and until set to some other node.
name (str, optional) – A human-readable name to associate with this nest.
code (int, optional) – Use this code for the new nest. If this code already exists, a ValueError is raised.
- Returns
int – The new code for this nest.
- Raises
ValueError – If a new code is given but it already exists in this tree.