skbio.tree.TreeNode.extend#

TreeNode.extend(nodes, uncache=True)[source]#

Add a list of nodes to self’s children.

Parameters:
nodesiterable of TreeNode

Nodes to add as children.

Changed in version 0.6.2: Can accept any iterable type in addition to list as input.

uncachebool, optional

Whether to clear caches of the tree if present (default: True). See details.

Added in version 0.6.3.

See also

append

Notes

This method will remove existing parents of the nodes if they have any, set their parents to self, and add the nodes to the end of self’s children.

The uncache parameter applies to both donor and recipient trees.

Examples

>>> from skbio import TreeNode
>>> root = TreeNode(name="root")
>>> root.extend([TreeNode(name="child1"), TreeNode(name="child2")])
>>> print(root)
(child1,child2)root;