qom.utils.loopers module¶
Module containing utility functions for loopers.
- qom.utils.loopers.plot_looper_results(looper, params_plotter: dict)¶
Helper function to plot results.
- Parameters:
looper (
qom.loopers.axes.*
) – Instance of the looper.params_plotter (dict) – Parameters of the plotter. Refer to Notes of
qom.ui.plotters.base.BasePlotter
for all available parameters.
- qom.utils.loopers.run_looper_instance(args)¶
Function to run a single instance of
wrap_looper
.- Parameters:
args (list) – Arguments of the
wrap_looper
function.- Returns:
looper – Instance of the looper.
- Return type:
qom.loopers.axes.*
- qom.utils.loopers.run_loopers_in_parallel(looper_name: str, func, params: dict, params_system: dict, plot: bool = False, subplots: bool = False, params_plotter: dict = {}, num_processes: int = None, cb_update=None)¶
Function to run multiple loopers in parallel processes.
- Parameters:
looper_name ({
'XLooper'
,'XYLooper'
,'XYZLooper'
}) –- Name of the looper. Available options are:
value
meaning
’XLooper’
1D looper (
qom.loopers.axes.XLooper
) (fallback).’XYLooper’
2D looper (
qom.loopers.axes.XYLooper
).’XYZLooper’
3D looper (
qom.loopers.axes.XYZLooper
).
func (callable) – Function to loop, formatted as
func(system_params)
, wheresystem_params
is a dictionary of the updated parameters for the system for that iteration of the looper.params (dict) – Parameters of the looper. Refer to Notes of
qom.loopers.base.BaseLooper
for all available options.params_system (dict) – Parameters of the system. If not provided, new keys are created for the looper variables.
plot (bool, default=False) – Option to plot the results of the main process.
subplots (bool, default=False) – Option to plot the results of each subprocesses.
params_plotter (dict, optional) – Parameters of the plotter.
num_processes (int, optional) – Number of loopers to run in parallel. The slicing of the values is performed on the first axis. If not provided, then the number slices are determined automatically, throttled by the number of available cores.
cb_update (callable) – Callback function to update status and progress, formatted as
cb_update(status, progress, reset)
, wherestatus
is a string,progress
is a float andreset
is a boolean.
- Returns:
looper – Instance of the looper.
- Return type:
qom.loopers.axes.*
- qom.utils.loopers.wrap_looper(looper_name: str, func, params: dict, params_system: dict, plot: bool = False, params_plotter: dict = {}, cb_update=None, parallel=False, p_index: int = 0, p_start: float = None)¶
Function to wrap loopers.
- Parameters:
looper_name ({
'XLooper'
,'XYLooper'
,'XYZLooper'
}) –- Name of the looper. Available options are:
value
meaning
’XLooper’
1D looper (
qom.loopers.axes.XLooper
) (fallback).’XYLooper’
2D looper (
qom.loopers.axes.XYLooper
).’XYZLooper’
3D looper (
qom.loopers.axes.XYZLooper
).
func (callable) – Function to loop, formatted as
func(system_params)
, wheresystem_params
is a dictionary of the updated parameters for the system for that iteration of the looper.params (dict) – Parameters of the looper. Refer to Notes of
qom.loopers.base.BaseLooper
for all available options.params_system (dict) – Parameters of the system. If not provided, new keys are created for the looper variables.
plot (bool, default=False) – Option to plot the results of the main process.
params_plotter (dict, optional) – Parameters of the plotter.
cb_update (callable) – Callback function to update status and progress, formatted as
cb_update(status, progress, reset)
, wherestatus
is a string,progress
is a float andreset
is a boolean.parallel (bool, default=False) – Option to format outputs when running in parallel.
p_index (int, default=0) – Index of the process.
p_start (float, optional) – Time at which the process was started. If not provided, the value is initialized to current time.
- Returns:
looper – Instance of the looper.
- Return type:
qom.loopers.axes.*