def test_getSpikes(self): p = sim.Population(3, sim.IF_curr_alpha()) p.record('spikes') sim.run(10.0) p.get_data = Mock() p.getSpikes() p.get_data.assert_called_with('spikes', True)
def test_get_v(self, sim=sim): p = sim.Population(3, sim.IF_curr_alpha()) p.record_v() sim.run(10.0) p.get_data = Mock() p.get_v() p.get_data.assert_called_with('v', True)
def test_print_v(self, sim=sim): p = sim.Population(3, sim.IF_curr_alpha()) p.record_v() sim.run(10.0) p.write_data = Mock() p.print_v("foo.txt") p.write_data.assert_called_with('foo.txt', 'v', True)
def test_inject(self, sim=sim): p = sim.Population(3, sim.IF_curr_alpha()) cs = Mock() p.inject(cs) meth, args, kwargs = cs.method_calls[0] self.assertEqual(meth, "inject_into") self.assertEqual(args, (p, ))
def test_id_to_index(self, sim=sim): p = sim.Population(11, sim.IF_curr_alpha()) pv = p[2, 5, 7, 8] self.assertEqual(pv.id_to_index(pv[0]), 0) self.assertEqual(pv.id_to_index(pv[3]), 3) self.assertEqual(pv.id_to_index(p[2]), 0) self.assertEqual(pv.id_to_index(p[8]), 3)
def test_inject(self): pv = sim.Population(3, sim.IF_curr_alpha())[1, 2] cs = Mock() pv.inject(cs) meth, args, kwargs = cs.method_calls[0] self.assertEqual(meth, "inject_into") self.assertEqual(args, (pv,))
def test_printSpikes(self, sim=sim): # TODO: implement assert_deprecated p = sim.Population(3, sim.IF_curr_alpha()) p.record('spikes') sim.run(10.0) p.write_data = Mock() p.printSpikes("foo.txt") p.write_data.assert_called_with('foo.txt', 'spikes', True)
def setUp(self): sim.setup() self.p1 = sim.Population(7, sim.IF_cond_exp()) self.p2 = sim.Population(4, sim.IF_cond_exp()) self.p3 = sim.Population(5, sim.IF_curr_alpha()) self.syn1 = sim.StaticSynapse(weight=0.123, delay=0.5) self.random_connect = sim.FixedNumberPostConnector(n=2) self.syn2 = sim.StaticSynapse(weight=0.456, delay=0.4) self.all2all = sim.AllToAllConnector()
def setUp(self, sim=sim, **extra): sim.setup(**extra) self.p1 = sim.Population(7, sim.IF_cond_exp()) self.p2 = sim.Population(4, sim.IF_cond_exp()) self.p3 = sim.Population(5, sim.IF_curr_alpha()) self.syn1 = sim.StaticSynapse(weight=0.006, delay=0.5) self.random_connect = sim.FixedNumberPostConnector(n=2) self.syn2 = sim.StaticSynapse(weight=0.012, delay=0.4) self.all2all = sim.AllToAllConnector() self.syn3 = sim.TsodyksMarkramSynapse(weight=0.012, delay=0.6, U=0.2, tau_rec=50)
def test_inject(self, sim=sim): p1 = sim.Population(3, sim.IF_curr_alpha()) p2 = sim.Population(5, sim.IF_cond_exp()) a = p1 + p2 cs = Mock() a.inject(cs) meth, args, kwargs = cs.method_calls[0] self.assertEqual(meth, "inject_into") self.assertEqual(args, (p1,)) meth, args, kwargs = cs.method_calls[1] self.assertEqual(meth, "inject_into") self.assertEqual(args, (p2,))
def setUp(self, sim=sim, **extra): self.MIN_DELAY = 0.123 sim.setup(num_processes=2, rank=1, min_delay=self.MIN_DELAY, **extra) self.p1 = sim.Population(7, sim.IF_cond_exp()) self.p2 = sim.Population(4, sim.IF_cond_exp()) self.p3 = sim.Population(5, sim.IF_curr_alpha()) self.projections = {"cond": {}, "curr": {}} for psr, post in (("cond", self.p2), ("curr", self.p3)): for rt in ("excitatory", "inhibitory"): self.projections[psr][rt] = sim.Projection( self.p1, post, sim.AllToAllConnector(safe=True), sim.StaticSynapse(), receptor_type=rt)
def test_id_to_index_with_populationview(self, sim=sim): p = sim.Population(11, sim.IF_curr_alpha()) view = p[3:7] self.assertIsInstance(view, sim.PopulationView) assert_array_equal(p.id_to_index(view), numpy.arange(3, 7))
def test_id_to_index(self, sim=sim): p = sim.Population(11, sim.IF_curr_alpha()) self.assertEqual(p.id_to_index(p[0]), 0) self.assertEqual(p.id_to_index(p[10]), 10)
def test_id_to_index_with_array(self, sim=sim): p = sim.Population(121, sim.IF_curr_alpha()) pv = p[2, 5, 7, 8, 19, 37, 49, 82, 83, 99] assert_array_equal(pv.id_to_index(pv.all_cells[3:9:2]), numpy.arange(3, 9, 2))
def test_id_to_index_with_invalid_id(self, sim=sim): p = sim.Population(11, sim.IF_curr_alpha()) pv = p[2, 5, 7, 8] self.assertRaises(IndexError, pv.id_to_index, p[0]) self.assertRaises(IndexError, pv.id_to_index, p[9])
def test__getitem__invalid(self, sim=sim): p = sim.Population(23, sim.IF_curr_alpha()) pv = p[1, 5, 6, 8, 11, 12, 15, 16, 19, 20] self.assertRaises(TypeError, pv.__getitem__, "foo")
def test_record_invalid_variable(self, sim=sim): p = sim.Population(14, sim.IF_curr_alpha()) self.assertRaises( errors.RecordingError, p.record, ('v', 'gsyn_exc')) # can't record gsyn_exc from this celltype
def test__getitem__invalid(self, sim=sim): p = sim.Population(23, sim.IF_curr_alpha()) self.assertRaises(TypeError, p.__getitem__, "foo")
def test_id_to_index_with_invalid_ids(self, sim=sim): p = sim.Population(11, sim.IF_curr_alpha()) self.assertRaises(ValueError, p.id_to_index, [p.first_id - 1] + p.all_cells[0:3].tolist())
def test_id_to_index_with_invalid_id(self, sim=sim): p = sim.Population(11, sim.IF_curr_alpha()) self.assertRaises(ValueError, p.id_to_index, p.last_id + 1) self.assertRaises(ValueError, p.id_to_index, p.first_id - 1)
def test_id_to_index_with_array(self, sim=sim): p = sim.Population(11, sim.IF_curr_alpha()) assert_array_equal(p.id_to_index(p.all_cells[3:9:2]), numpy.arange(3, 9, 2))