pyphi.labels.NodeLabels#

class pyphi.labels.NodeLabels(labels, node_indices)[source]#

Bases: Sequence[str]

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'))
Parameters:
labels2indices(labels)[source]#

Convert a tuple of node labels to node indices.

Parameters:

labels (Sequence[str])

Return type:

tuple[int, …]

indices2labels(indices)[source]#

Convert a tuple of node indices to node labels.

Parameters:

indices (Sequence[int])

Return type:

tuple[str, …]

coerce_to_indices(nodes)[source]#

Return the node indices for nodes, which may be given either as integer indices or as node labels.

Parameters:

nodes (Iterable[int | str | integer] | None)

Return type:

tuple[int, …]

coerce_to_labels(nodes)[source]#

Return the node labels for nodes, which may be given either as labels or as integer indices.

Parameters:

nodes (Iterable[int | str | integer] | None)

Return type:

tuple[str | int, …]

label_string(nodes, state, sep=None)[source]#

Return a single string labeling the nodes.

Parameters:
Return type:

str

set_case_by_state(labels, states)[source]#

Return a list of labels with case set by the corresponding state.

Parameters:
Return type:

list[str]