tensornetwork.NodeCollection¶
-
class
tensornetwork.
NodeCollection
(container: Union[Set[tensornetwork.network_components.AbstractNode], List[tensornetwork.network_components.AbstractNode]])¶ Context manager for easy collection of a set or list of nodes.
The following examples are equivalent:
# 1. Using a NodeCollection context: nodes_set = set() with NodeCollection(nodes_set): a = tn.Node(...) b = tn.Node(...) # 2. Explicitly adding each node to the set: nodes_set = set() a = tn.Node(...) nodes_set.add(a) b = tn.Node(...) nodes_set.add(b)
-
__init__
(container: Union[Set[tensornetwork.network_components.AbstractNode], List[tensornetwork.network_components.AbstractNode]])¶ Initialize the NodeCollection context manager.
Parameters: container – The container to hold the created nodes, can be a list or a set. Raises: ValueError
– If container is not a list or set.
Methods
__init__
(container, …)Initialize the NodeCollection context manager. add
(node)-