network_operation function
(Shortest import: from brian2 import network_operation)
- brian2.core.operations.network_operation(when=None)[source]
Decorator to make a function get called every time step of a simulation.
The function being decorated should either have no arguments, or a single argument which will be called with the current time
t
.- Parameters:
dt :
Quantity
, optionalThe time step to be used for the simulation. Cannot be combined with the
clock
argument.clock :
Clock
, optionalThe update clock to be used. If neither a clock, nor the
dt
argument is specified, thedefaultclock
will be used.when : str, optional
In which scheduling slot to execute the operation during a time step. Defaults to
'start'
. See Scheduling for possible values.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.
See also
Notes
Converts the function into a
NetworkOperation
.If using the form:
@network_operations(when='end') def f(): ...
Then the arguments to network_operation must be keyword arguments.
Examples
Print something each time step: >>> from brian2 import * >>> @network_operation … def f(): … print(‘something’) … >>> net = Network(f)
Print the time each time step:
>>> @network_operation ... def f(t): ... print('The time is', t) ... >>> net = Network(f)
Specify a dt, etc.:
>>> @network_operation(dt=0.5*ms, when='end') ... def f(): ... print('This will happen at the end of each timestep.') ... >>> net = Network(f)