base
adapters.base
Base adapter for processing SimulationExperiment metadata.
Extracts Python logic from Mako templates into reusable, testable methods. Backend-specific adapters (NetworkDynamics, PyRates, etc.) inherit from BaseAdapter and override or extend as needed.
Classes
| Name | Description |
|---|---|
| BaseAdapter | Base class for backend adapters. |
BaseAdapter
adapters.base.BaseAdapter(experiment)Base class for backend adapters.
Provides shared metadata processing that all code-generation backends need: dynamics library, node-dynamics mapping, coupling resolution, graph info, initial state parsing, etc.
Methods
| Name | Description |
|---|---|
| build_dynamics_dict | Build an ordered dict of all unique Dynamics models. |
| build_node_dynamics_map | Map each node id to its dynamics name. |
| build_weight_matrix | Build a dense weight matrix from explicit edges if over threshold. |
| collect_all_distributions | Collect SV and parameter distributions from all dynamics. |
| collect_events | Collect all events from experiment, nodes, and edges. |
| get_coupling_observed | Extract observed (obsf/obssym) from coupling definitions. |
| get_coupling_vars | Get names of state variables marked as coupling variables. |
| get_default_coupling | Return the default (first) coupling model. |
| get_execution_info | Extract execution config (find_fixpoint, etc.). |
| get_integration_info | Extract integration parameters. |
| get_network_info | Extract network metadata: n_nodes, graph generator, edges, etc. |
| get_noise_sigmas | Extract per-SV noise intensity values. |
| get_outdim | Coupling output dimension: number of coupling variables, or n_sv. |
| get_outsym_names | Output symbol names for the edge model. |
| is_heterogeneous | Check if the network has heterogeneous vertex types. |
| is_static | Check if dynamics is a static model (no differential equations). |
| is_stochastic_dynamics | Detect stochastic system: any SV with noise intensity > 0. |
| parse_node_parameters | Parse per-node parameter overrides from a Node object. |
| prepare_context | Build the full pre-computed context dict for template rendering. |
| resolve_couplings | Collect all unique coupling models as an OrderedDict. |
build_dynamics_dict
adapters.base.BaseAdapter.build_dynamics_dict()Build an ordered dict of all unique Dynamics models.
Always includes the default model first, then any additional dynamics from the network’s dynamics library (for heterogeneous networks).
build_node_dynamics_map
adapters.base.BaseAdapter.build_node_dynamics_map()Map each node id to its dynamics name.
Nodes without an explicit dynamics assignment use the default model. Returns {node_id: dynamics_name}.
build_weight_matrix
adapters.base.BaseAdapter.build_weight_matrix(edges_list, n_nodes, threshold=50)Build a dense weight matrix from explicit edges if over threshold.
collect_all_distributions
adapters.base.BaseAdapter.collect_all_distributions(dynamics_dict)Collect SV and parameter distributions from all dynamics.
Returns {dyn_name: {‘sv’: […], ‘param’: […], ‘has’: bool, ‘seed’: int}}
collect_events
adapters.base.BaseAdapter.collect_events()Collect all events from experiment, nodes, and edges.
Returns a list of (event, source) tuples where source is one of: ‘experiment’, ‘node:{id}’, ‘edge:{idx}’.
get_coupling_observed
adapters.base.BaseAdapter.get_coupling_observed(all_couplings)Extract observed (obsf/obssym) from coupling definitions.
Returns {coupling_name: [DerivedVariable, …]}.
get_coupling_vars
adapters.base.BaseAdapter.get_coupling_vars(dynamics)Get names of state variables marked as coupling variables.
get_default_coupling
adapters.base.BaseAdapter.get_default_coupling(all_couplings=None)Return the default (first) coupling model.
get_execution_info
adapters.base.BaseAdapter.get_execution_info()Extract execution config (find_fixpoint, etc.).
get_integration_info
adapters.base.BaseAdapter.get_integration_info()Extract integration parameters.
get_network_info
adapters.base.BaseAdapter.get_network_info()Extract network metadata: n_nodes, graph generator, edges, etc.
get_noise_sigmas
adapters.base.BaseAdapter.get_noise_sigmas(dynamics)Extract per-SV noise intensity values.
get_outdim
adapters.base.BaseAdapter.get_outdim(dynamics)Coupling output dimension: number of coupling variables, or n_sv.
get_outsym_names
adapters.base.BaseAdapter.get_outsym_names(dynamics, outdim, coupling=None)Output symbol names for the edge model.
Uses coupling.outsym if available, otherwise generates from coupling variables or state variables.
is_heterogeneous
adapters.base.BaseAdapter.is_heterogeneous(
dynamics_dict=None,
node_dynamics_map=None,
)Check if the network has heterogeneous vertex types.
is_static
adapters.base.BaseAdapter.is_static(dynamics)Check if dynamics is a static model (no differential equations).
is_stochastic_dynamics
adapters.base.BaseAdapter.is_stochastic_dynamics(dynamics_dict)Detect stochastic system: any SV with noise intensity > 0.
parse_node_parameters
adapters.base.BaseAdapter.parse_node_parameters(node)Parse per-node parameter overrides from a Node object.
Node.parameters is now a keyed dict {name: Parameter} (inlined). Returns {param_name: value}.
prepare_context
adapters.base.BaseAdapter.prepare_context()Build the full pre-computed context dict for template rendering.
This is the main entry point: templates receive this dict instead of doing metadata processing themselves.
resolve_couplings
adapters.base.BaseAdapter.resolve_couplings()Collect all unique coupling models as an OrderedDict.