def setUp(self): sim.setup(num_processes=2, rank=1, min_delay=0.123) self.p1 = sim.Population(4, sim.IF_cond_exp(), structure=space.Line()) self.p2 = sim.Population(5, sim.HH_cond_exp(), structure=space.Line()) assert_array_equal(self.p2._mask_local, numpy.array([0,1,0,1,0], dtype=bool)) random.mpi_rank = 1 random.num_processes = 2
def setUp(self): sim.setup(num_processes=2, rank=1, min_delay=0.123) self.p1 = sim.Population(4, sim.IF_cond_exp(), structure=space.Line()) self.p2 = sim.Population(5, sim.HH_cond_exp(), structure=space.Line()) assert_array_equal(self.p2._mask_local, numpy.array([0, 1, 0, 1, 0], dtype=bool)) connection_list = [ (0, 0, 0.0, 1.0), (3, 0, 0.0, 1.0), (2, 3, 0.0, 1.0), # local (2, 2, 0.0, 1.0), (0, 1, 0.0, 1.0), # local ] list_connector = connectors.FromListConnector(connection_list) syn = sim.StaticSynapse() self.ref_prj = sim.Projection(self.p1, self.p2, list_connector, syn) self.orig_gather_dict = recording.gather_dict # create reference to original function # The gather_dict function in recording needs to be temporarily replaced so it can work with # a mock version of the function to avoid it throwing an mpi4py import error when setting # the rank in pyNN.mock by hand to > 1 def mock_gather_dict(D, all=False): return D recording.gather_dict = mock_gather_dict
def setUp(self, sim=sim, **extra): sim.setup(num_processes=2, rank=1, min_delay=0.123, **extra) self.p1 = sim.Population(4, sim.IF_cond_exp(), structure=space.Line()) self.p2 = sim.Population(5, sim.HH_cond_exp(), structure=space.Line()) assert_array_equal(self.p1._mask_local, np.array([0, 1, 0, 1], dtype=bool)) assert_array_equal(self.p2._mask_local, np.array([0, 1, 0, 1, 0], dtype=bool))
def setUp(self, sim=sim, **extra): sim.setup(min_delay=0.123, **extra) self.p1 = sim.Population(4, sim.IF_cond_exp(), structure=space.Line()) self.p2 = sim.Population(5, sim.HH_cond_exp(), structure=space.Line()) self.connection_list = [ (0, 0, 0.1, 0.1), (3, 0, 0.2, 0.11), (2, 3, 0.3, 0.12), # local (2, 2, 0.4, 0.13), (0, 1, 0.5, 0.14), # local ]
def setUp(self): sim.setup(num_processes=2, rank=1, min_delay=0.123) self.p1 = sim.Population(4, sim.IF_cond_exp(), structure=space.Line()) self.p2 = sim.Population(5, sim.HH_cond_exp(), structure=space.Line()) assert_array_equal(self.p2._mask_local, numpy.array([0,1,0,1,0], dtype=bool)) self.connection_list = [ (0, 0, 0.1, 0.1), (3, 0, 0.2, 0.11), (2, 3, 0.3, 0.12), # local (2, 2, 0.4, 0.13), (0, 1, 0.5, 0.14), # local ]
def test_set_structure(self): p = sim.Population(11, sim.IF_cond_exp(), structure=space.Grid2D()) pv = p[2, 5, 7, 8] new_struct = space.Line() def set_struct(struct): pv.structure = struct self.assertRaises(AttributeError, set_struct, new_struct)
def test_generate_positions(self): line = space.Line(dx=100.0, x0=-100.0, y=444.0, z=987.0) n = 2 positions = line.generate_positions(n) assert_equal(positions.shape, (3, n)) assert_allclose(positions, np.array([[-100, 444, 987], [0, 444, 987]], float).T, rtol=1e-15)
def test_generate_positions(self): line = space.Line(dx=100.0, x0=-100.0, y=444.0, z=987.0) n = 2 positions = line.generate_positions(n) assert_equal(positions.shape, (3, n)) assert_arrays_almost_equal( positions, numpy.array([[-100, 444, 987], [0, 444, 987]], float).T, threshold=1e-15)
def test_generate_positions_default_parameters(self): line = space.Line() n = 4 positions = line.generate_positions(n) assert_equal(positions.shape, (3, n)) assert_arrays_almost_equal( positions, numpy.array([[0, 0, 0], [1, 0, 0], [2, 0, 0], [3, 0, 0]], float).T, threshold=1e-15)
def test_generate_positions_default_parameters(self): line = space.Line() n = 4 positions = line.generate_positions(n) assert_equal(positions.shape, (3, n)) assert_allclose(positions, np.array([[0, 0, 0], [1, 0, 0], [2, 0, 0], [3, 0, 0]], float).T, rtol=1e-15)
def test_get_parameters(self): params = dict(dx=100.0, x0=-100.0, y=444.0, z=987.0) line = space.Line(**params) assert_equal(line.get_parameters(), params)
def test__eq__(self): line1 = space.Line() line2 = space.Line(1.0, 0.0, 0.0, 0.0) line3 = space.Line(dx=2.0) assert_equal(line1, line2) assert line1 != line3
def setUp(self, sim=sim, **extra): sim.setup(nmin_delay=0.123, **extra) self.p1 = sim.Population(5, sim.IF_cond_exp(), structure=space.Line()) self.p2 = sim.Population(5, sim.HH_cond_exp(), structure=space.Line())
def test_connect_with_pre_post_mismatch(self, sim=sim): syn = sim.StaticSynapse() C = connectors.CloneConnector(self.ref_prj) p3 = sim.Population(5, sim.IF_cond_exp(), structure=space.Line()) self.assertRaises(errors.ConnectionError, sim.Projection, self.p1, p3, C, syn)
def test_generate_positions(self): line = space.Line() assert_arrays_almost_equal( line.generate_positions(3), numpy.array([[0, 0, 0], [1, 0, 0], [2, 0, 0]], float), threshold=1e-15)