pyrates.utility module

Functions for performing parameter grid simulations with pyrates model_templates.

class pyrates.utility.Interactive2DParamPlot(data_map: array, data_series: DataFrame, x_values: array, y_values: array, x_key: str, y_key: str, param_map: DataFrame, tmin=0.0, title=None, **kwargs)[source]

Bases: object


Try to access a column in data_series using x and y values based on cursor position

Is called on mouse button press event. Converts the current cursor coordinates inside the plot into x and y values based on the data in x_values and y_values. x and y values are used to access a column in data_series. Access of data_series can be customized in self.get_data().




get_data(x, y)[source]
update_lineplot(x, y)[source]
pyrates.utility.adapt_circuit(circuit: Union[CircuitTemplate, str], params: dict, param_map: dict) 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: 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_ir_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_ir_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, and the mapping between the data frame column names and the parameter grid.

Return type


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

Directly simulate dynamics of a circuit.

pyrates.utility.linearize_grid(grid: dict, permute: bool = False) 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


pyrates.utility.set_num_axis_ticks(ax, num_x_ticks=10, num_y_ticks=10)[source]

Set the number of x and y ticks of a plot axis

  • ax

  • num_x_ticks

  • num_y_ticks