step_current_generator currently allows times for amplitude changes to be set in the past:
nest.set(min_delay=1, max_delay=1) # simplifies Connect below
nest.Simulate(10)
c = nest.Create('step_current_generator', params={'amplitude_times': [5, 12], 'amplitude_values': [500, -1000]})
n = nest.Create("iaf_psc_alpha", params={'V_th': float('inf')})
v = nest.Create("voltmeter")
nest.Connect(c+v, n)
nest.Simulate(6)
ve = v.events
for t, V in zip(ve["times"], ve["V_m"]):
print(f"{t:6.3f} {V:8.3f}")
which yields
11.000 -70.000
12.000 -70.000
13.000 -70.000
14.000 -73.807
15.000 -77.251
The user might assume here (or accidentally pass such values) that the generator will inject a depolarizing current (500 pA) when the simulation resumes, i.e., we to see depolarization at 11 ms. But we only see hyperpolarization from 14 ms onwards as an effect of the -1000 pA current turned on at 12 ms.
The best solution here (and in other corresponding generators) would be to prohibit setting times in the past. The earliest permitted time would be "now" plus one time step or, for continuous-time devices, now + epsilon (so the time stamp of the event is at now plus one step).
step_current_generatorcurrently allows times for amplitude changes to be set in the past:which yields
The user might assume here (or accidentally pass such values) that the generator will inject a depolarizing current (500 pA) when the simulation resumes, i.e., we to see depolarization at 11 ms. But we only see hyperpolarization from 14 ms onwards as an effect of the -1000 pA current turned on at 12 ms.
The best solution here (and in other corresponding generators) would be to prohibit setting times in the past. The earliest permitted time would be "now" plus one time step or, for continuous-time devices, now + epsilon (so the time stamp of the event is at now plus one step).