PyRates.pyrates.utility
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:
- 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:
- 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.grid_search(circuit_template: CircuitTemplate | str, param_grid: dict | DataFrame, param_map: dict, step_size: float, simulation_time: float, outputs: dict, inputs: dict | None = None, sampling_step_size: float | None = None, permute_grid: bool = False, **kwargs) tuple[source]
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