# subsystem¶

Represents a candidate system for $$\varphi$$ and $$\Phi$$ evaluation.

class pyphi.subsystem.Subsystem(network, state, nodes, cut=None, mice_cache=None, repertoire_cache=None, single_node_repertoire_cache=None, _external_indices=None)

A set of nodes in a network.

Parameters: Keyword Arguments: network (Network) – The network the subsystem belongs to. state (tuple[int]) – The state of the network. nodes (tuple[int] or tuple[str]) – The nodes of the network which are in this subsystem. Nodes can be specified either as indices or as labels if the Network was passed node_labels. cut (Cut) – The unidirectional Cut to apply to this subsystem.
network

Network – The network the subsystem belongs to.

tpm

np.ndarray – The TPM conditioned on the state of the external nodes.

cm

np.ndarray – The connectivity matrix after applying the cut.

state

tuple[int] – The state of the network.

node_indices

tuple[int] – The indices of the nodes in the subsystem.

cut

Cut – The cut that has been applied to this subsystem.

null_cut

Cut – The cut object representing no cut.

nodes

tuple[Node] – The nodes in this Subsystem.

proper_state

tuple[int] – The state of the subsystem.

proper_state[i] gives the state of the $$i^{\textrm{th}}$$ node in the subsystem. Note that this is not the state of nodes[i].

connectivity_matrix

np.ndarray – Alias for Subsystem.cm.

size

int – The number of nodes in the subsystem.

is_cut

boolTrue if this Subsystem has a cut applied to it.

cut_indices

tuple[int] – The nodes of this subsystem to cut for $$\Phi$$ computations.

This was added to support MacroSubsystem, which cuts indices other than node_indices.

cut_mechanisms

list[tuple[int]] – The mechanisms that are cut in this system.

tpm_size

int – The number of nodes in the TPM.

cache_info()

Report repertoire cache statistics.

clear_caches()

Clear the mice and repertoire caches.

__bool__()

Return False if the Subsystem has no nodes, True otherwise.

__eq__(other)

Return whether this Subsystem is equal to the other object.

Two Subsystems are equal if their sets of nodes, networks, and cuts are equal.

__lt__(other)

Return whether this subsystem has fewer nodes than the other.

__gt__(other)

Return whether this subsystem has more nodes than the other.

__len__()

Return the number of nodes in this Subsystem.

to_json()

Return a JSON-serializable representation.

apply_cut(cut)

Return a cut version of this Subsystem.

Parameters: cut (Cut) – The cut to apply to this Subsystem. The cut subsystem. Subsystem
indices2nodes(indices)

Return Node for these indices.

Parameters: indices (tuple[int]) – The indices in question. The Node objects corresponding to these indices. tuple[Node] ValueError – If requested indices are not in the subsystem.
indices2labels(indices)

Return the node labels for the given indices.

cause_repertoire(mechanism, purview)

Return the cause repertoire of a mechanism over a purview.

Parameters: mechanism (tuple[int]) – The mechanism for which to calculate the cause repertoire. purview (tuple[int]) – The purview over which to calculate the cause repertoire. The cause repertoire of the mechanism over the purview. np.ndarray

Note

The returned repertoire is a distribution over purview node states, not the states of the whole network.

effect_repertoire(mechanism, purview)

Return the effect repertoire of a mechanism over a purview.

Parameters: mechanism (tuple[int]) – The mechanism for which to calculate the effect repertoire. purview (tuple[int]) – The purview over which to calculate the effect repertoire. The effect repertoire of the mechanism over the purview. np.ndarray

Note

The returned repertoire is a distribution over purview node states, not the states of the whole network.

repertoire(direction, mechanism, purview)

Return the cause or effect repertoire based on a direction.

Parameters: direction (Direction) – CAUSE or EFFECT. mechanism (tuple[int]) – The mechanism for which to calculate the repertoire. purview (tuple[int]) – The purview over which to calculate the repertoire. The cause or effect repertoire of the mechanism over the purview. np.ndarray ValueError – If direction is invalid.
unconstrained_repertoire(direction, purview)

Return the unconstrained cause/effect repertoire over a purview.

unconstrained_cause_repertoire(purview)

Return the unconstrained cause repertoire for a purview.

This is just the cause repertoire in the absence of any mechanism.

unconstrained_effect_repertoire(purview)

Return the unconstrained effect repertoire for a purview.

This is just the effect repertoire in the absence of any mechanism.

partitioned_repertoire(direction, partition)

Compute the repertoire of a partitioned mechanism and purview.

expand_repertoire(direction, repertoire, new_purview=None)

Distribute an effect repertoire over a larger purview.

Parameters: Keyword Arguments: direction (Direction) – CAUSE or EFFECT. repertoire (np.ndarray) – The repertoire to expand. new_purview (tuple[int]) – The new purview to expand the repertoire over. If None (the default), the new purview is the entire network. A distribution over the new purview, where probability is spread out over the new nodes. np.ndarray ValueError – If the expanded purview doesn’t contain the original purview.
expand_cause_repertoire(repertoire, new_purview=None)

Same as expand_repertoire() with direction set to CAUSE.

expand_effect_repertoire(repertoire, new_purview=None)

Same as expand_repertoire() with direction set to EFFECT.

cause_info(mechanism, purview)

Return the cause information for a mechanism over a purview.

effect_info(mechanism, purview)

Return the effect information for a mechanism over a purview.

cause_effect_info(mechanism, purview)

Return the cause-effect information for a mechanism over a purview.

This is the minimum of the cause and effect information.

evaluate_partition(direction, mechanism, purview, partition, repertoire=None)

Return the $$\varphi$$ of a mechanism over a purview for the given partition.

Parameters: Keyword Arguments: direction (Direction) – CAUSE or EFFECT. mechanism (tuple[int]) – The nodes in the mechanism. purview (tuple[int]) – The nodes in the purview. partition (Bipartition) – The partition to evaluate. repertoire (np.array) – The unpartitioned repertoire. If not supplied, it will be computed. The distance between the unpartitioned and partitioned repertoires, and the partitioned repertoire. tuple[int, np.ndarray]
find_mip(direction, mechanism, purview)

Return the minimum information partition for a mechanism over a purview.

Parameters: direction (Direction) – CAUSE or EFFECT. mechanism (tuple[int]) – The nodes in the mechanism. purview (tuple[int]) – The nodes in the purview. The irreducibility analysis for the mininum-information partition in one temporal direction. RepertoireIrreducibilityAnalysis
cause_mip(mechanism, purview)

Return the irreducibility analysis for the cause MIP.

Alias for find_mip() with direction set to CAUSE.

effect_mip(mechanism, purview)

Return the irreducibility analysis for the effect MIP.

Alias for find_mip() with direction set to EFFECT.

phi_cause_mip(mechanism, purview)

Return the $$\varphi$$ of the cause MIP.

This is the distance between the unpartitioned cause repertoire and the MIP cause repertoire.

phi_effect_mip(mechanism, purview)

Return the $$\varphi$$ of the effect MIP.

This is the distance between the unpartitioned effect repertoire and the MIP cause repertoire.

phi(mechanism, purview)

Return the $$\varphi$$ of a mechanism over a purview.

potential_purviews(direction, mechanism, purviews=False)

Return all purviews that could belong to the MaximallyIrreducibleCause/MaximallyIrreducibleEffect.

Filters out trivially-reducible purviews.

Parameters: Keyword Arguments: direction (Direction) – CAUSE or EFFECT. mechanism (tuple[int]) – The mechanism of interest. purviews (tuple[int]) – Optional subset of purviews of interest.
find_mice(direction, mechanism, purviews=False)

Return the MaximallyIrreducibleCause or MaximallyIrreducibleEffect for a mechanism.

Parameters: Keyword Arguments: direction (Direction) – :CAUSE or EFFECT. mechanism (tuple[int]) – The mechanism to be tested for irreducibility. purviews (tuple[int]) – Optionally restrict the possible purviews to a subset of the subsystem. This may be useful for _e.g._ finding only concepts that are “about” a certain subset of nodes. MaximallyIrreducibleCauseOrEffect
mic(mechanism, purviews=False)

Return the mechanism’s maximally-irreducible cause (MaximallyIrreducibleCause).

Alias for find_mice() with direction set to CAUSE.

mie(mechanism, purviews=False)

Return the mechanism’s maximally-irreducible effect (MaximallyIrreducibleEffect).

Alias for find_mice() with direction set to EFFECT.

phi_max(mechanism)

Return the $$\varphi^{\textrm{max}}$$ of a mechanism.

This is the maximum of $$\varphi$$ taken over all possible purviews.

null_concept

Return the null concept of this subsystem.

The null concept is a point in concept space identified with the unconstrained cause and effect repertoire of this subsystem.

concept(mechanism, purviews=False, cause_purviews=False, effect_purviews=False)

Return the concept specified by a mechanism within this subsytem.

Parameters: Keyword Arguments: mechanism (tuple[int]) – The candidate set of nodes. purviews (tuple[tuple[int]]) – Restrict the possible purviews to those in this list. cause_purviews (tuple[tuple[int]]) – Restrict the possible cause purviews to those in this list. Takes precedence over purviews. effect_purviews (tuple[tuple[int]]) – Restrict the possible effect purviews to those in this list. Takes precedence over purviews. The pair of maximally irreducible cause/effect repertoires that constitute the concept specified by the given mechanism. Concept
pyphi.subsystem.mip_partitions(mechanism, purview)

Return a generator over all mechanism-purview partitions, based on the current configuration.

pyphi.subsystem.mip_bipartitions(mechanism, purview)

Return an generator of all $$\varphi$$ bipartitions of a mechanism over a purview.

Excludes all bipartitions where one half is entirely empty, e.g:

 A     ∅
─── ✕ ───
B     ∅


is not valid, but

 A     ∅
─── ✕ ───
∅     B


is.

Parameters: mechanism (tuple[int]) – The mechanism to partition purview (tuple[int]) – The purview to partition Bipartition – Where each bipartition is: bipart[0].mechanism bipart[1].mechanism ─────────────────── ✕ ─────────────────── bipart[0].purview bipart[1].purview 

Example

>>> mechanism = (0,)
>>> purview = (2, 3)
>>> for partition in mip_bipartitions(mechanism, purview):
...     print(partition, '\n')
∅     0
─── ✕ ───
2     3

∅     0
─── ✕ ───
3     2

∅     0
─── ✕ ───
2,3    ∅

pyphi.subsystem.wedge_partitions(mechanism, purview)

Return an iterator over all wedge partitions.

These are partitions which strictly split the mechanism and allow a subset of the purview to be split into a third partition, e.g.:

 A     B     ∅
─── ✕ ─── ✕ ───
B     C     D


See PARTITION_TYPE in config for more information.

Parameters: mechanism (tuple[int]) – A mechanism. purview (tuple[int]) – A purview. Tripartition – all unique tripartitions of this mechanism and purview.
pyphi.subsystem.all_partitions(mechanism, purview)

Return all possible partitions of a mechanism and purview.

Partitions can consist of any number of parts.

Parameters: mechanism (tuple[int]) – A mechanism. purview (tuple[int]) – A purview. KPartition – A partition of this mechanism and purview into k parts.