pyphi.labels.NodeLabels#
- class pyphi.labels.NodeLabels(labels, node_indices)[source]#
-
Text labels for nodes in a substrate.
Labels can either be instantiated as a tuple of strings:
>>> NodeLabels(('A', 'IN'), (0, 1)) NodeLabels(('A', 'IN'))
Or, if all labels are a single character, as a string:
>>> NodeLabels('AB', (0, 1)) NodeLabels(('A', 'B'))
- coerce_to_indices(nodes)[source]#
Return the sorted node indices for
nodes, which may be given either as integer indices or as node labels.- Raises:
TypeError – If
nodesis not iterable, or is a string (a label must be given inside a tuple, such as("A",)).ValueError – If
nodesmixes labels with indices, contains booleans, non-integer numbers, or nested sequences, names an unknown label or an out-of-range index, or names a unit more than once.
- Parameters:
- Return type:
- coerce_to_labels(nodes)[source]#
Return the node labels for
nodes, which may be given either as labels or as integer indices.