StateUpdateMethod class

(Shortest import: from brian2 import StateUpdateMethod)

class brian2.stateupdaters.base.StateUpdateMethod[source]

Bases: object

Attributes

stateupdaters A dictionary mapping state updater names to StateUpdateMethod objects

Methods

__call__(equations[, variables]) Generate abstract code from equations.
can_integrate(equations, variables) Determine whether the state updater is a suitable choice.
determine_stateupdater(equations, variables, ...) Determine a suitable state updater.
register(name, stateupdater) Register a state updater.

Details

stateupdaters

A dictionary mapping state updater names to StateUpdateMethod objects

__call__(equations, variables=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.

Returns:

code : str

The abstract code performing a state update step.

can_integrate(equations, variables)[source]

Determine whether the state updater is a suitable choice. Should return False if it is not appropriate (e.g. non-linear equations for a linear state updater) and a True if it is appropriate.

Parameters:

equations : Equations

The model equations.

variables : dict

The Variable objects for the model variables.

Returns:

ability : bool

True if this state updater is able to integrate the given equations, False otherwise.

static determine_stateupdater(equations, variables, method)[source]

Determine a suitable state updater. If a method is given, the state updater with the given name is used. In case it is a callable, it will be used even if it is a state updater that claims it is not applicable. If it is a string, the state updater registered with that name will be used, but in this case an error will be raised if it claims not to be applicable. If a method is a list of names, all the methods will be tried until one that can integrate the equations 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.

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.