예제 #1
0
 def test_record_with_single_variable(self, sim=sim):
     p = sim.Population(14, sim.EIF_cond_exp_isfa_ista())
     p.record('v')
     sim.run(12.3)
     data = p.get_data(gather=True).segments[0]
     self.assertEqual(len(data.analogsignalarrays), 1)
     n_values = int(round(12.3 / sim.get_time_step())) + 1
     self.assertEqual(data.analogsignalarrays[0].name, 'v')
     self.assertEqual(data.analogsignalarrays[0].shape, (n_values, p.size))
예제 #2
0
 def test_record_with_single_variable(self, sim=sim):
     p = sim.Population(14, sim.EIF_cond_exp_isfa_ista())
     p.record('v')
     sim.run(12.3)
     data = p.get_data(gather=True).segments[0]
     self.assertEqual(len(data.analogsignalarrays), 1)
     n_values = int(round(12.3 / sim.get_time_step())) + 1
     self.assertEqual(data.analogsignalarrays[0].name, 'v')
     self.assertEqual(data.analogsignalarrays[0].shape, (n_values, p.size))
예제 #3
0
 def test_record_with_v_and_spikes(self, sim=sim):
     p = sim.Population(2, sim.EIF_cond_exp_isfa_ista())
     p.record(('v', 'spikes'))
     sim.run(10.0)
     data = p.get_data(gather=True).segments[0]
     self.assertEqual(len(data.analogsignalarrays), 1)
     n_values = int(round(10.0 / sim.get_time_step())) + 1
     names = set(arr.name for arr in data.analogsignalarrays)
     self.assertEqual(names, set(('v')))
     for arr in data.analogsignalarrays:
         self.assertEqual(arr.shape, (n_values, p.size))
예제 #4
0
 def test_record_with_v_and_spikes(self, sim=sim):
     p = sim.Population(2, sim.EIF_cond_exp_isfa_ista())
     p.record(('v', 'spikes'))
     sim.run(10.0)
     data = p.get_data(gather=True).segments[0]
     self.assertEqual(len(data.analogsignalarrays), 1)
     n_values = int(round(10.0 / sim.get_time_step())) + 1
     names = set(arr.name for arr in data.analogsignalarrays)
     self.assertEqual(names, set(('v')))
     for arr in data.analogsignalarrays:
         self.assertEqual(arr.shape, (n_values, p.size))
예제 #5
0
 def test_record_with_multiple_variables(self):
     p = sim.Population(2, sim.EIF_cond_exp_isfa_ista())
     p.record(("v", "w", "gsyn_exc"))
     sim.run(10.0)
     data = p.get_data(gather=True).segments[0]
     self.assertEqual(len(data.analogsignalarrays), 3)
     n_values = int(round(10.0 / sim.get_time_step())) + 1
     names = set(arr.name for arr in data.analogsignalarrays)
     self.assertEqual(names, set(("v", "w", "gsyn_exc")))
     for arr in data.analogsignalarrays:
         self.assertEqual(arr.shape, (n_values, p.size))
예제 #6
0
 def test_record_with_multiple_variables(self, sim=sim):
     p = sim.Population(4, sim.EIF_cond_exp_isfa_ista())
     pv = p[0, 3]
     pv.record(('v', 'w', 'gsyn_exc'))
     sim.run(10.0)
     data = p.get_data(gather=True).segments[0]
     self.assertEqual(len(data.analogsignals), 3)
     n_values = int(round(10.0 / sim.get_time_step())) + 1
     names = set(arr.name for arr in data.analogsignals)
     self.assertEqual(names, set(('v', 'w', 'gsyn_exc')))
     for arr in data.analogsignals:
         self.assertEqual(arr.shape, (n_values, pv.size))
예제 #7
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)
예제 #8
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)
예제 #9
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)
예제 #10
0
 def test_time_step(self):
     sim.setup(0.123, min_delay=0.246)
     self.assertEqual(sim.get_time_step(), 0.123)
예제 #11
0
 def test_time_step(self, sim=sim):
     sim.setup(0.123, min_delay=0.246, **self.extra)
     self.assertAlmostEqual(sim.get_time_step(), 0.123)
     sim.end()
예제 #12
0
 def test_time_step(self, sim=sim):
     sim.setup(0.123, min_delay=0.246, **self.extra)
     self.assertAlmostEqual(sim.get_time_step(), 0.123)
     sim.end()
예제 #13
0
 def test_time_step(self):
     sim.setup(0.123, min_delay=0.246)
     self.assertEqual(sim.get_time_step(), 0.123)