Group class

(Shortest import: from brian2 import Group)

class brian2.groups.group.Group(*args, **kw)[source]

Bases: VariableOwner, BrianObject

Methods

custom_operation(*args, **kwds)

resolve_all(identifiers, run_namespace[, ...])

Resolve a list of identifiers.

run_regularly(code[, dt, clock, when, ...])

Run abstract code in the group's namespace.

runner(*args, **kwds)

Details

custom_operation(*args, **kwds)[source]
resolve_all(identifiers, run_namespace, user_identifiers=None, additional_variables=None)[source]

Resolve a list of identifiers. Calls Group._resolve for each identifier.

Parameters:

identifiers : iterable of str

The names to look up.

run_namespace : dict-like, optional

An additional namespace that is used for variable lookup (if not defined, the implicit namespace of local variables is used).

user_identifiers : iterable of str, optional

The names in identifiers that were provided by the user (i.e. are part of user-specified equations, abstract code, etc.). Will be used to determine when to issue namespace conflict warnings. If not specified, will be assumed to be identical to identifiers.

additional_variables : dict-like, optional

An additional mapping of names to Variable objects that will be checked before Group.variables.

Returns:

variables : dict of Variable or Function

A mapping from name to Variable/Function object for each of the names given in identifiers

Raises

KeyError

If one of the names in identifier cannot be resolved

run_regularly(code, dt=None, clock=None, when='start', order=0, name=None, codeobj_class=None)[source]

Run abstract code in the group’s namespace. The created CodeRunner object will be automatically added to the group, it therefore does not need to be added to the network manually. However, a reference to the object will be returned, which can be used to later remove it from the group or to set it to inactive.

Parameters:

code : str

The abstract code to run.

dt : Quantity, optional

The time step to use for this custom operation. Cannot be combined with the clock argument.

clock : Clock, optional

The update clock to use for this operation. If neither a clock nor the dt argument is specified, defaults to the clock of the group.

when : str, optional

When to run within a time step, defaults to the 'start' slot. See Scheduling for possible values.

name : str, optional

A unique name, if non is given the name of the group appended with ‘run_regularly’, ‘run_regularly_1’, etc. will be used. If a name is given explicitly, it will be used as given (i.e. the group name will not be prepended automatically).

codeobj_class : class, optional

The CodeObject class to run code with. If not specified, defaults to the group’s codeobj_class attribute.

Returns:

obj : CodeRunner

A reference to the object that will be run.

runner(*args, **kwds)[source]