# StateUpdateMethod class¶

(Shortest import: from brian2 import StateUpdateMethod)

class brian2.stateupdaters.base.StateUpdateMethod[source]

Bases: object

Methods

 __call__(equations[, variables, method_options]) Generate abstract code from equations. apply_stateupdater(equations, variables, method) Applies a given state updater to equations. register(name, stateupdater) Register a state updater.

Details

abstract __call__(equations, variables=None, method_options=None)[source]

Generate abstract code from equations. The method also gets the the variables because some state updaters have to check whether variable names reflect other state variables (which can change from timestep to timestep) or are external values (which stay constant during a run) For convenience, this arguments are optional – this allows to directly see what code a state updater generates for a set of equations by simply writing euler(eqs), for example.

Parameters

equations : Equations

The model equations.

variables : dict, optional

The Variable objects for the model variables.

method_options : dict, optional

Additional options specific to the state updater.

Returns :

——- :

code : str

The abstract code performing a state update step.

static apply_stateupdater(equations, variables, method, method_options=None, group_name=None)[source]

Applies a given state updater to equations. If a method is given, the state updater with the given name is used or if is a callable, then it is used directly. If a method is a list of names, all the methods will be tried until one that doesn’t raise an UnsupportedEquationsException is found.

Parameters

equations : Equations

The model equations.

variables : dict

The dictionary of Variable objects, describing the internal model variables.

method : {callable, str, list of str}

A callable usable as a state updater, the name of a registered state updater or a list of names of state updaters.

Returns

abstract_code : str

The code integrating the given equations.

static register(name, stateupdater)[source]

Register a state updater. Registered state updaters can be referred to via their name.

Parameters

name : str

A short name for the state updater (e.g. 'euler')

stateupdater : StateUpdaterMethod

The state updater object, e.g. an ExplicitStateUpdater.