from brian2 import network_operation)
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
The time step to be used for the simulation. Cannot be combined with the
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.
Converts the function into a
If using the form:
@network_operations(when='end') def f(): ...
Then the arguments to network_operation must be keyword arguments.
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)