from brian2 import CodeRunner)
CodeRunner(group, template, code='', user_code=None, dt=None, clock=None, when='start', order=0, name='coderunner*', check_units=True, template_kwds=None, needed_variables=None, override_conditional_write=None, codeobj_class=None, generate_empty_code=True)¶
On creation, we try to run the before_run method with an empty additional namespace (see
Network.before_run()). If the namespace is already complete this might catch unit mismatches.
The group to which this object belongs.
The template that should be used for code generation
code : str, optional
The abstract code that should be executed every time step. The
update_abstract_codemethod might generate this code dynamically before every run instead.
The time step to be used for the simulation. Cannot be combined with the
user_code : str, optional
The abstract code as specified by the user, i.e. without any additions of internal code that the user not necessarily knows about. This will be used for warnings and error messages.
The update clock to be used. If neither a clock, nor the
dtargument is specified, the
defaultclockwill be used.
when : str, optional
In which scheduling slot to execute the operation during a time step. Defaults to
order : int, optional
The priority of this operation for operations occurring at the same time step and in the same scheduling slot. Defaults to 0.
name : str, optional
The name for this object.
check_units : bool, optional
Whether the units should be checked for consistency before a run. Is activated (
True) by default but should be switched off for state updaters (units are already checked for the equations and the generated abstract code might have already replaced variables with their unit-less values)
template_kwds : dict, optional
A dictionary of additional information that is passed to the template.
needed_variables: list of str, optional :
A list of variables that are neither present in the abstract code, nor in the
USES_VARIABLESstatement in the template. This is only rarely necessary, an example being a
StateMonitorwhere the names of the variables are neither known to the template nor included in the abstract code statements.
override_conditional_write: list of str, optional :
A list of variable names which are used as conditions (e.g. for refractoriness) which should be ignored.
codeobj_class : class, optional
CodeObjectclass to run code with. If not specified, defaults to the
generate_empty_code : bool, optional
Whether to generate a
CodeObjectif there is no abstract code to execute. Defaults to
Truebut should be switched off e.g. for a
StateUpdaterwhen there is nothing to do.
Update the abstract code for the code object.