every
self, period, offset=0.0, wait=0.0, net_id=0) core.Simulate.every(
Decorator to declare a callback method that will be called periodically during the simulation.
Example of setting increasing inputs to a population every 100 ms, with an offset of 90 ms (or -10 ms relative to the period):
@every(period=100., offset=-10.)
def step_input(n):
= float(n) / 100.
pop.I
10000.) simulate(
step_input()
will be called at times 90, 190, …, 9990 ms during the call to simulate()
.
The method must accept only n
as parameter (an integer being 0 the first time the method is called, and incremented afterwards) and can not return anything.
The times at which the method is called are relative to the time when simulate()
is called (if t
is already 150 before calling simulate()
, the first call will then be made at t=240
with the previous example).
If multiple callbacks are defined, they will be called in the order of their declaration if they occur at the same time.
wait
can be combined with offset
, so if period=100.
, offset=50.
and wait=500.
, the first call will be made 550 ms after the call to `simulate()
Parameters
Name | Type | Description | Default |
---|---|---|---|
period | float | interval in ms between two calls to the function. If less than dt , will be called every step. |
required |
offset | float | by default, the first call to the method will be made at the start of the simulation. The offset delays the call within the period (default: 0.0). Can be negative, in which case it will be counted from the end of the period. | 0.0 |
wait | float | allows to wait for a certain amount of time (in ms) before starting to call the method. | 0.0 |