Modules of the PyRates core package.

pyrates.utility module

Functions for performing parameter grid simulations with pyrates model_templates.

pyrates.utility.adapt_circuit(circuit: Union[pyrates.frontend.template.circuit.CircuitTemplate, str], params: dict, param_map: dict) → pyrates.frontend.template.circuit.CircuitTemplate[source]

Changes the parametrization of a circuit.

  • circuit – Circuit instance.
  • params – Key-value pairs of the parameters that should be changed.
  • param_map – Map between the keys in params and the circuit variables.

Updated circuit instance.

Return type:


pyrates.utility.clear(model: pyrates.frontend.template.circuit.CircuitTemplate, **kwargs)[source]

Function that clears all temporary files and caches that have been created via a PyRates model.

  • model – Instance of a CircuitTemplate.
  • kwargs – Additional keyword arguments to be passed to clear_frontend_caches.
pyrates.utility.clear_frontend_caches(clear_template_cache=True, clear_operator_cache=True)[source]

Utility to clear caches in the frontend.

  • clear_template_cache – toggles whether or not to clear the template_cache that contains all previously loaded templates
  • clear_operator_cache – toggles whether or not to clear the cache of unique OperatorIR instances

check if a directory exists and create it otherwise

Function that runs multiple parametrizations of the same circuit in parallel and returns a combined output.

  • circuit_template – Path to the circuit template.
  • param_grid – Key-value pairs for each circuit parameter that should be altered over different circuit parametrizations.
  • param_map – Key-value pairs that map the keys of param_grid to concrete circuit variables.
  • step_size – Simulation step-size in s.
  • simulation_time – Simulation time in s.
  • outputs – Output variables as provided to the run method of :class:ComputeGraph.
  • inputs – Extrinsic inputs as provided to the run method of :class:ComputeGraph.
  • sampling_step_size – Sampling step-size as provided to the run method of :class:ComputeGraph.
  • permute_grid – If true, all combinations of the provided param_grid values will be realized. If false, the param_grid values will be traversed pairwise.
  • kwargs – Additional keyword arguments passed to the call.

Simulation results stored in a multi-index data frame, the mapping between the data frame column names and the parameter grid, the simulation time, and the memory consumption.

Return type:


pyrates.utility.integrate(circuit: Union[str, pyrates.frontend.template.circuit.CircuitTemplate], **kwargs)[source]

Directly simulate dynamics of a circuit.

pyrates.utility.linearize_grid(grid: dict, permute: bool = False) → pandas.core.frame.DataFrame[source]

Turns the grid into a grid that can be traversed linearly, i.e. pairwise.

  • grid – Parameter grid.
  • permute – If true, all combinations of the parameter values in grid will be created.

Resulting linear grid in form of a data frame.

Return type: