root/trunk/test/regression/incremental_spiketime_set.py @ 777

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
3import sys
4import numpy
5
6dt = 0.1 # ms
7t_step = 100.0 # ms
8lag = 3.0 # ms
9interactive = False
10
11if interactive:
12    import pylab
13    pylab.rcParams['interactive'] = interactive
14
15simulator_name = sys.argv[-1]
16sim = __import__("pyNN.%s" % simulator_name, None, None, [simulator_name])
17
18sim.setup(timestep=dt)
19
20spiketimes = numpy.arange(2.0,t_step,t_step/13.0)
21
22spikesources = sim.Population(2, sim.SpikeSourceArray)
23cells = sim.Population(2, sim.IF_curr_exp)
24
25conn = sim.Projection(spikesources, cells, sim.OneToOneConnector(weights=0.1))
26
27cells.record_v()
28
29spikesources[0].spike_times = spiketimes
30spikesources[1].spike_times = spiketimes + lag
31
32t = sim.run(t_step)
33t = sim.run(t_step)
34
35spiketimes += 2*t_step
36spikesources[0].spike_times = spiketimes
37# note we add no new spikes to the second source
38t = sim.run(t_step)
39
40final_v_0 = cells[0:1].get_v()[-1,2]
41final_v_1 = cells[1:2].get_v()[-1,2]
42
43sim.end()
44
45if 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
53assert final_v_0 > -64.0
54assert final_v_1 < -64.99
Note: See TracBrowser for help on using the browser.