Ejemplo n.º 1
0
    def test_get_spikes_with_gather(self, sim=sim):
        t1 = 12.3
        t2 = 13.4
        t3 = 14.5
        p = sim.Population(14, sim.EIF_cond_exp_isfa_ista())
        p.record('v')
        sim.run(t1)
        sim.run(t2)
        sim.reset()
        p.record('spikes')
        p.record('w')
        sim.run(t3)
        data = p.get_data(gather=True)
        self.assertEqual(len(data.segments), 2)

        seg0 = data.segments[0]
        self.assertEqual(len(seg0.analogsignalarrays), 1)
        self.assertEqual(len(seg0.spiketrains), 0)

        seg1 = data.segments[1]
        self.assertEqual(len(seg1.analogsignalarrays), 2)
        self.assertEqual(len(seg1.spiketrains), p.size)
        assert_array_equal(
            seg1.spiketrains[7],
            numpy.array([p.first_id + 7, p.first_id + 7 + 5]) % t3)
Ejemplo n.º 2
0
    def test_get_data_with_gather(self, sim=sim):
        t1 = 12.3
        t2 = 13.4
        t3 = 14.5
        p = sim.Population(14, sim.EIF_cond_exp_isfa_ista())
        pv = p[::3]
        pv.record('v')
        sim.run(t1)
        # what if we call p.record between two run statements?
        # would be nice to get an AnalogSignal with a non-zero t_start
        # but then need to make sure we get the right initial value
        sim.run(t2)
        sim.reset()
        pv.record('spikes')
        pv.record('w')
        sim.run(t3)
        data = p.get_data(gather=True)
        self.assertEqual(len(data.segments), 2)

        seg0 = data.segments[0]
        self.assertEqual(len(seg0.analogsignals), 1)
        self.assertEqual(len(seg0.spiketrains), 0)

        seg1 = data.segments[1]
        self.assertEqual(len(seg1.analogsignals), 2)
        self.assertEqual(len(seg1.spiketrains), pv.size)
        assert_array_equal(seg1.spiketrains[2],
                        numpy.array([p.first_id + 6, p.first_id + 6 + 5]) % t3)
Ejemplo n.º 3
0
    def test_get_data_with_gather(self):
        t1 = 12.3
        t2 = 13.4
        t3 = 14.5
        p = sim.Population(14, sim.EIF_cond_exp_isfa_ista())
        pv = p[::3]
        pv.record('v')
        sim.run(t1)
        # what if we call p.record between two run statements?
        # would be nice to get an AnalogSignalArray with a non-zero t_start
        # but then need to make sure we get the right initial value
        sim.run(t2)
        sim.reset()
        pv.record('spikes')
        pv.record('w')
        sim.run(t3)
        data = p.get_data(gather=True)
        self.assertEqual(len(data.segments), 2)

        seg0 = data.segments[0]
        self.assertEqual(len(seg0.analogsignalarrays), 1)
        v = seg0.analogsignalarrays[0]
        self.assertEqual(v.name, 'v')
        num_points = int(round((t1 + t2)/sim.get_time_step())) + 1
        self.assertEqual(v.shape, (num_points, pv.size))
        self.assertEqual(v.t_start, 0.0*pq.ms)
        self.assertEqual(v.units, pq.mV)
        self.assertEqual(v.sampling_period, 0.1*pq.ms)
        self.assertEqual(len(seg0.spiketrains), 0)

        seg1 = data.segments[1]
        self.assertEqual(len(seg1.analogsignalarrays), 2)
        w = seg1.filter(name='w')[0]
        self.assertEqual(w.name, 'w')
        num_points = int(round(t3/sim.get_time_step())) + 1
        self.assertEqual(w.shape, (num_points, pv.size))
        self.assertEqual(v.t_start, 0.0)
        self.assertEqual(len(seg1.spiketrains), pv.size)
        assert_array_equal(seg1.spiketrains[2],
                           numpy.array([p.first_id+6, p.first_id+6+5]) % t3)
Ejemplo n.º 4
0
    def test_get_data_with_gather(self):
        t1 = 12.3
        t2 = 13.4
        t3 = 14.5
        p = sim.Population(14, sim.EIF_cond_exp_isfa_ista())
        p.record('v')
        sim.run(t1)
        # what if we call p.record between two run statements?
        # would be nice to get an AnalogSignalArray with a non-zero t_start
        # but then need to make sure we get the right initial value
        sim.run(t2)
        sim.reset()
        p.record('spikes')
        p.record('w')
        sim.run(t3)
        data = p.get_data(gather=True)
        self.assertEqual(len(data.segments), 2)

        seg0 = data.segments[0]
        self.assertEqual(len(seg0.analogsignalarrays), 1)
        v = seg0.analogsignalarrays[0]
        self.assertEqual(v.name, 'v')
        num_points = int(round((t1 + t2) / sim.get_time_step())) + 1
        self.assertEqual(v.shape, (num_points, p.size))
        self.assertEqual(v.t_start, 0.0 * pq.ms)
        self.assertEqual(v.units, pq.mV)
        self.assertEqual(v.sampling_period, 0.1 * pq.ms)
        self.assertEqual(len(seg0.spiketrains), 0)

        seg1 = data.segments[1]
        self.assertEqual(len(seg1.analogsignalarrays), 2)
        w = seg1.filter(name='w')[0]
        self.assertEqual(w.name, 'w')
        num_points = int(round(t3 / sim.get_time_step())) + 1
        self.assertEqual(w.shape, (num_points, p.size))
        self.assertEqual(v.t_start, 0.0)
        self.assertEqual(len(seg1.spiketrains), p.size)
        assert_array_equal(
            seg1.spiketrains[7],
            numpy.array([p.first_id + 7, p.first_id + 7 + 5]) % t3)
Ejemplo n.º 5
0
 def test_get_data_with_gather(self, sim=sim):
     t1 = 12.3
     t2 = 13.4
     t3 = 14.5
     p1 = sim.Population(11, sim.IF_cond_exp())
     p2 = sim.Population(6, sim.IF_cond_alpha())
     p3 = sim.Population(3, sim.EIF_cond_exp_isfa_ista())
     a = sim.Assembly(p3, p1, p2)
     a.record('v')
     sim.run(t1)
     # what if we call p.record between two run statements?
     # would be nice to get an AnalogSignal with a non-zero t_start
     # but then need to make sure we get the right initial value
     sim.run(t2)
     sim.reset()
     a.record('spikes')
     p3.record('w')
     sim.run(t3)
     data = a.get_data(gather=True)
     self.assertEqual(len(data.segments), 2)
     seg0 = data.segments[0]
     self.assertEqual(len(seg0.analogsignals), 1)
     v = seg0.filter(name='v')[0]
     self.assertEqual(v.name, 'v')
     num_points = int(round((t1 + t2) / sim.get_time_step())) + 1
     self.assertEqual(v.shape, (num_points, a.size))
     self.assertEqual(v.t_start, 0.0 * pq.ms)
     self.assertEqual(v.units, pq.mV)
     self.assertEqual(v.sampling_period, 0.1 * pq.ms)
     self.assertEqual(len(seg0.spiketrains), 0)
     
     seg1 = data.segments[1]
     self.assertEqual(len(seg1.analogsignals), 2)
     w = seg1.filter(name='w')[0]
     self.assertEqual(w.name, 'w')
     num_points = int(round(t3 / sim.get_time_step())) + 1
     self.assertEqual(w.shape, (num_points, p3.size))
     self.assertEqual(v.t_start, 0.0)
     self.assertEqual(len(seg1.spiketrains), a.size)
Ejemplo n.º 6
0
    def test_get_spikes_with_gather(self, sim=sim):
        t1 = 12.3
        t2 = 13.4
        t3 = 14.5
        p = sim.Population(14, sim.EIF_cond_exp_isfa_ista())
        p.record('v')
        sim.run(t1)
        sim.run(t2)
        sim.reset()
        p.record('spikes')
        p.record('w')
        sim.run(t3)
        data = p.get_data(gather=True)
        self.assertEqual(len(data.segments), 2)

        seg0 = data.segments[0]
        self.assertEqual(len(seg0.analogsignalarrays), 1)
        self.assertEqual(len(seg0.spiketrains), 0)

        seg1 = data.segments[1]
        self.assertEqual(len(seg1.analogsignalarrays), 2)
        self.assertEqual(len(seg1.spiketrains), p.size)
        assert_array_equal(seg1.spiketrains[7],
                            numpy.array([p.first_id + 7, p.first_id + 7 + 5]) % t3)
Ejemplo n.º 7
0
 def test_reset(self):
     sim.setup()
     sim.run(1000.0)
     sim.reset()
     self.assertEqual(sim.get_current_time(), 0.0)
Ejemplo n.º 8
0
 def test_reset(self, sim=sim):
     sim.setup(**self.extra)
     sim.run(100.0)
     sim.reset()
     self.assertEqual(sim.get_current_time(), 0.0)
     sim.end()
Ejemplo n.º 9
0
 def test_reset(self, sim=sim):
     sim.setup(**self.extra)
     sim.run(100.0)
     sim.reset()
     self.assertEqual(sim.get_current_time(), 0.0)
     sim.end()
Ejemplo n.º 10
0
 def test_reset(self):
     sim.setup()
     sim.run(1000.0)
     sim.reset()
     self.assertEqual(sim.get_current_time(), 0.0)