finesse.analysis.actions.random.Execute

Overview

class finesse.analysis.actions.random.Execute(do_fn, parameters=None, name='execute')[source]

Bases: Action

An action that will execute the function passed to it when it is run.

Parameters
do_fnfunction

A function that takes an AnalysisState, and the name of the Exec action as its only arguments. If this function returns a BaseSolution object then it will be added to the simulations solution to return to the user.

parameterslist, optional

A list of parameters that will be changed by do_fn, if any.

namestr

The name to give this action.

Examples

A simple function to execute might use a pattern such as this, which generates a Solution that is returned back to the user.

>>> from finesse.solutions import SimpleSolution
>>> def my_action(state, name):
...     sol = SimpleSolution(name)
...     return sol

The SimpleSolution object is just an object you can store anything you want in. You can extract any state information about the simulation or model and store it here. This allows you to probe and store details that might not be available as a detector, for example.