|
Revision 777, 1.2 KB
(checked in by apdavison, 3 years ago)
|
|
Fixed ticket:166, I think, and wrote a much better regression test for the issue (there was already an old test of sorts, since this has been broken before for other simulators). All I need to do now is automate the running of regression tests (-;
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Id
|
| Line | |
|---|
| 1 | """Check that changing the spike_times of a SpikeSourceArray mid-simulation works (see ticket:166)""" |
|---|
| 2 | |
|---|
| 3 | import sys |
|---|
| 4 | import numpy |
|---|
| 5 | |
|---|
| 6 | dt = 0.1 # ms |
|---|
| 7 | t_step = 100.0 # ms |
|---|
| 8 | lag = 3.0 # ms |
|---|
| 9 | interactive = False |
|---|
| 10 | |
|---|
| 11 | if interactive: |
|---|
| 12 | import pylab |
|---|
| 13 | pylab.rcParams['interactive'] = interactive |
|---|
| 14 | |
|---|
| 15 | simulator_name = sys.argv[-1] |
|---|
| 16 | sim = __import__("pyNN.%s" % simulator_name, None, None, [simulator_name]) |
|---|
| 17 | |
|---|
| 18 | sim.setup(timestep=dt) |
|---|
| 19 | |
|---|
| 20 | spiketimes = numpy.arange(2.0,t_step,t_step/13.0) |
|---|
| 21 | |
|---|
| 22 | spikesources = sim.Population(2, sim.SpikeSourceArray) |
|---|
| 23 | cells = sim.Population(2, sim.IF_curr_exp) |
|---|
| 24 | |
|---|
| 25 | conn = sim.Projection(spikesources, cells, sim.OneToOneConnector(weights=0.1)) |
|---|
| 26 | |
|---|
| 27 | cells.record_v() |
|---|
| 28 | |
|---|
| 29 | spikesources[0].spike_times = spiketimes |
|---|
| 30 | spikesources[1].spike_times = spiketimes + lag |
|---|
| 31 | |
|---|
| 32 | t = sim.run(t_step) |
|---|
| 33 | t = sim.run(t_step) |
|---|
| 34 | |
|---|
| 35 | spiketimes += 2*t_step |
|---|
| 36 | spikesources[0].spike_times = spiketimes |
|---|
| 37 | # note we add no new spikes to the second source |
|---|
| 38 | t = sim.run(t_step) |
|---|
| 39 | |
|---|
| 40 | final_v_0 = cells[0:1].get_v()[-1,2] |
|---|
| 41 | final_v_1 = cells[1:2].get_v()[-1,2] |
|---|
| 42 | |
|---|
| 43 | sim.end() |
|---|
| 44 | |
|---|
| 45 | if interactive: |
|---|
| 46 | id, t, vtrace = cells[0:1].get_v().T |
|---|
| 47 | print vtrace.shape |
|---|
| 48 | print t.shape |
|---|
| 49 | pylab.plot(t, vtrace) |
|---|
| 50 | id, t, vtrace = cells[1:2].get_v().T |
|---|
| 51 | pylab.plot(t, vtrace) |
|---|
| 52 | |
|---|
| 53 | assert final_v_0 > -64.0 |
|---|
| 54 | assert final_v_1 < -64.99 |
|---|