pyphi.substrate_generator.create_substrate#

pyphi.substrate_generator.create_substrate(node_params, labels=None)[source]#

Build a Substrate from per-node specifications.

Each node names a mechanism (a key in MECHANISMS), its inputs, and a params dict. The resulting substrate TPM matches the dynamic_tpm of the substrate_modeler library, in which the present state equals the past state.

Parameters:
  • node_params (Mapping[int, Mapping] or Sequence[Mapping]) –

    Either an integer-keyed mapping (nodes taken in sorted key order) or an ordered iterable of node specs. Each spec is a dict with keys:

    • "mechanism" (str): mechanism name, or

    • "composite" (list of sub-specs) plus optional "mechanism_combination" (str, default "selective") and "combination_params" (dict);

    • "inputs" (tuple[int]): the unit’s input indices;

    • "params" (dict): mechanism parameters (e.g. input_weights, determinism, threshold, weight_scale_mapping).

  • labels (Sequence[str] or NodeLabels, optional) – Node labels. Defaults to A, B, C, ....

Returns:

Substrate – A PyPhi substrate.

Raises:

TypeError – If node_params is a mapping whose keys are not all integers.

Return type:

Substrate

Notes

The connectivity matrix is assembled in two passes: every input edge is first marked with weight 1, then the real edge weights of weighted mechanisms (WEIGHTED) overwrite those markers. State-dependent mechanisms (STATE_DEPENDENT) read the unit’s own state, so a self-loop is inserted into the connectivity matrix when the spec does not already include one.