Ejemplo n.º 1
0
 def test___add__two(self, sim=sim):
     # adding two population views should give an Assembly
     pv1 = sim.Population(6, sim.IF_curr_exp())[2, 3, 5]
     pv2 = sim.Population(17, sim.IF_cond_exp())[4, 2, 16]
     assembly = pv1 + pv2
     self.assertIsInstance(assembly, sim.Assembly)
     self.assertEqual(assembly.populations, [pv1, pv2])
Ejemplo n.º 2
0
 def test___add__two(self, sim=sim):
     # adding two populations should give an Assembly
     p1 = sim.Population(6, sim.IF_curr_exp())
     p2 = sim.Population(17, sim.IF_cond_exp())
     assembly = p1 + p2
     self.assertIsInstance(assembly, sim.Assembly)
     self.assertEqual(assembly.populations, [p1, p2])
Ejemplo n.º 3
0
 def test_get_multiple_params_no_gather(self, sim=sim):
     sim.simulator.state.num_processes = 2
     sim.simulator.state.mpi_rank = 1
     p1 = sim.Population(
         4,
         sim.IF_cond_exp(tau_m=12.3,
                         tau_syn_E=[0.987, 0.988, 0.989, 0.990],
                         i_offset=lambda i: -0.2 * i))
     p2 = sim.Population(
         3,
         sim.IF_curr_exp(tau_m=12.3,
                         tau_syn_E=[0.991, 0.992, 0.993],
                         i_offset=lambda i: -0.2 * (i + 4)))
     a = p1 + p2
     tau_syn_E, tau_m, i_offset = a.get(('tau_syn_E', 'tau_m', 'i_offset'),
                                        gather=False)
     self.assertIsInstance(tau_m, float)
     self.assertIsInstance(tau_syn_E, np.ndarray)
     assert_array_equal(tau_syn_E, np.array([0.988, 0.990, 0.992]))
     self.assertEqual(tau_m, 12.3)
     assert_array_almost_equal(i_offset,
                               np.array([
                                   -0.2,
                                   -0.6,
                                   -1.0,
                               ]),
                               decimal=12)
     sim.simulator.state.num_processes = 1
     sim.simulator.state.mpi_rank = 0
Ejemplo n.º 4
0
 def test_get_positions(self, sim=sim):
     p = sim.Population(11, sim.IF_curr_exp())
     ppos = numpy.random.uniform(size=(3, 11))
     p._positions = ppos
     pv = sim.PopulationView(parent=p, selector=slice(3, 9, 2))
     assert_array_equal(pv.positions,
                        numpy.array([ppos[:, 3], ppos[:, 5], ppos[:, 7]]).T)
Ejemplo n.º 5
0
 def test_all_iterator(self, sim=sim):
     p1 = sim.Population(11, sim.IF_cond_exp())
     p2 = sim.Population(6, sim.IF_cond_alpha())
     p3 = sim.Population(3, sim.IF_curr_exp())
     a = sim.Assembly(p1, p2, p3)
     assert hasattr(a.all(), "next") or hasattr(a.all(), "__next__")  # 2nd form is for Py3
     ids = list(a.all())
     self.assertEqual(ids, p1.all_cells.tolist() + p2.all_cells.tolist() + p3.all_cells.tolist())
Ejemplo n.º 6
0
 def test_conductance_based(self):
     p1 = sim.Population(11, sim.IF_cond_exp())
     p2 = sim.Population(6, sim.IF_cond_alpha())
     p3 = sim.Population(3, sim.IF_curr_exp())
     a1 = sim.Assembly(p1, p2)
     a2 = sim.Assembly(p1, p3)
     self.assertTrue(a1.conductance_based)
     self.assertFalse(a2.conductance_based)
Ejemplo n.º 7
0
 def test__homogeneous_synapses(self):
     p1 = sim.Population(11, sim.IF_cond_exp())
     p2 = sim.Population(6, sim.IF_cond_alpha())
     p3 = sim.Population(3, sim.IF_curr_exp())
     a1 = sim.Assembly(p1, p2)
     a2 = sim.Assembly(p1, p3)
     self.assertTrue(a1._homogeneous_synapses)
     self.assertFalse(a2._homogeneous_synapses)
Ejemplo n.º 8
0
 def test___add__three(self, sim=sim):
     # adding three populations should give an Assembly
     p1 = sim.Population(6, sim.IF_curr_exp())
     p2 = sim.Population(17, sim.IF_cond_exp())
     p3 = sim.Population(9, sim.HH_cond_exp())
     assembly = p1 + p2 + p3
     self.assertIsInstance(assembly, sim.Assembly)
     self.assertEqual(assembly.populations, [p1, p2, p3])
Ejemplo n.º 9
0
 def test___add__three(self, sim=sim):
     # adding three population views should give an Assembly
     pv1 = sim.Population(6, sim.IF_curr_exp())[0:3]
     pv2 = sim.Population(17, sim.IF_cond_exp())[1, 5, 14]
     pv3 = sim.Population(9, sim.HH_cond_exp())[3:8]
     assembly = pv1 + pv2 + pv3
     self.assertIsInstance(assembly, sim.Assembly)
     self.assertEqual(assembly.populations, [pv1, pv2, pv3])
Ejemplo n.º 10
0
 def test__non_homogeneous_synapses(self, sim=sim):
     p1 = sim.Population(11, sim.IF_cond_exp())
     p3 = sim.Population(3, sim.IF_curr_exp())
     a2 = sim.Assembly(p1, p3)
     self.assertFalse(a2._homogeneous_synapses)
Ejemplo n.º 11
0
 def test_iter(self, sim=sim):
     p = sim.Population(6, sim.IF_curr_exp())
     itr = p.__iter__()
     assert hasattr(itr, "next") or hasattr(itr, "__next__")
     self.assertEqual(len(list(itr)), 6)
Ejemplo n.º 12
0
 def test_iter(self, sim=sim):
     p = sim.Population(33, sim.IF_curr_exp())
     pv = p[1, 5, 6, 8, 11, 12]
     itr = pv.__iter__()
     assert hasattr(itr, "next") or hasattr(itr, "__next__")
     self.assertEqual(len(list(itr)), 6)