1. PyRates.pyrates

Modules of the PyRates core package.

1.4. 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

__call__(event)[source]

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().

Parameters:

event

Returns:

get_data(x, y)[source]
set_map_title(title)[source]
set_map_xlabel(label)[source]
set_map_ylabel(label)[source]
set_series_xlabel(label)[source]
set_series_ylabel(label)[source]
update_lineplot(x, y)[source]
pyrates.utility.adapt_circuit(circuit: CircuitTemplate | str, params: dict, param_map: dict) CircuitTemplate[source]

Changes the parametrization of a circuit.

Parameters:
  • 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.

Returns:

Updated circuit instance.

Return type:

CircuitIR

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

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

Parameters:
  • 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.

Parameters:
  • 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

pyrates.utility.create_directory(path)[source]

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.

Parameters:
  • 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 CircuitTemplate.run call.

Returns:

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

Return type:

tuple

pyrates.utility.integrate(circuit: 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.

Parameters:
  • grid – Parameter grid.

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

Returns:

Resulting linear grid in form of a data frame.

Return type:

pd.DataFrame

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

Parameters:
  • ax

  • num_x_ticks

  • num_y_ticks