예제 #1
0
 def test_connect_with_weight_array(self):
     w_in = numpy.arange(self.p1.size*self.p2.size, 0.0, -1.0).reshape(self.p1.size, self.p2.size)
     connector = AllToAllConnector(weights=w_in)
     prj = MockProjection(self.p1, self.p2, self.rng, "excitatory")
     connector.connect(prj)
     self.assertEqual(prj.n, self.p1.size*self.p2.size)
     assert_arrays_almost_equal(numpy.array(prj.connection_manager.weights), w_in.flatten(), 1e-6)
예제 #2
0
 def test_connect_with_no_self_connections(self):
     connector = AllToAllConnector(allow_self_connections=False,
                                   weights=0.1)
     prj = MockProjection(self.p1, self.p1, self.rng, "excitatory")
     connector.connect(prj)
     self.assertEqual(prj.n, self.p1.size * (self.p1.size - 1))
     self.assertEqual(prj.connection_manager.weights, [[0.1]] * prj.n)
예제 #3
0
 def test_connect_with_no_self_connections(self):
     connector = AllToAllConnector(allow_self_connections=False,
                                   weights=0.1)
     prj = MockProjection(self.p1, self.p1, self.rng, "excitatory")
     connector.connect(prj)
     self.assertEqual(prj.n, self.p1.size*(self.p1.size-1))
     self.assertEqual(prj.connection_manager.weights, [[0.1]]*prj.n)
예제 #4
0
 def test_connect_with_single_weight(self):
     connector = AllToAllConnector(allow_self_connections=True,
                                   weights=0.1)
     prj = MockProjection(self.p1, self.p2, self.rng, "excitatory")
     connector.connect(prj)
     self.assertEqual(prj.n, self.p1.size*self.p2.size)
     self.assertEqual(prj.connection_manager.weights, [[0.1]]*prj.n)
예제 #5
0
 def test_connect_with_random_weights(self):
     connector = AllToAllConnector(
         weights=RandomDistribution("uniform", [0.3, 0.4], rng=self.rng))
     prj = MockProjection(self.p1, self.p2, self.rng, "excitatory")
     connector.connect(prj)
     self.assertEqual(prj.n, self.p1.size * self.p2.size)
     assert_arrays_almost_equal(numpy.array(prj.connection_manager.weights),
                                numpy.arange(0, prj.n), 1e-6)
예제 #6
0
 def test_connect_with_weight_array(self):
     w_in = numpy.arange(self.p1.size * self.p2.size, 0.0,
                         -1.0).reshape(self.p1.size, self.p2.size)
     connector = AllToAllConnector(weights=w_in)
     prj = MockProjection(self.p1, self.p2, self.rng, "excitatory")
     connector.connect(prj)
     self.assertEqual(prj.n, self.p1.size * self.p2.size)
     assert_arrays_almost_equal(numpy.array(prj.connection_manager.weights),
                                w_in.flatten(), 1e-6)
예제 #7
0
 def test_connect_with_distance_dependent_weights_simple(self):
     self.p1.positions = numpy.zeros((3,self.p1.size))
     connector = AllToAllConnector(weights="d*d")
     prj = MockProjection(self.p1, self.p2, self.rng, "excitatory")
     connector.connect(prj)
     self.assertEqual(prj.n, self.p1.size*self.p2.size)
     w_expected = numpy.array([w*w for w in range(self.p2.size)]*self.p1.size, float).flatten()
     assert_arrays_almost_equal(numpy.array(prj.connection_manager.weights),
                                w_expected, 1e-6)
예제 #8
0
 def test_connect_with_distance_dependent_weights_simple(self):
     self.p1.positions = numpy.zeros((3, self.p1.size))
     connector = AllToAllConnector(weights="d*d")
     prj = MockProjection(self.p1, self.p2, self.rng, "excitatory")
     connector.connect(prj)
     self.assertEqual(prj.n, self.p1.size * self.p2.size)
     w_expected = numpy.array([w * w
                               for w in range(self.p2.size)] * self.p1.size,
                              float).flatten()
     assert_arrays_almost_equal(numpy.array(prj.connection_manager.weights),
                                w_expected, 1e-6)
예제 #9
0
 def test_connect_with_single_weight(self):
     connector = AllToAllConnector(allow_self_connections=True, weights=0.1)
     prj = MockProjection(self.p1, self.p2, self.rng, "excitatory")
     connector.connect(prj)
     self.assertEqual(prj.n, self.p1.size * self.p2.size)
     self.assertEqual(prj.connection_manager.weights, [[0.1]] * prj.n)
예제 #10
0
 def test_connect_with_random_weights(self):
     connector = AllToAllConnector(weights=RandomDistribution("uniform", [0.3, 0.4], rng=self.rng))
     prj = MockProjection(self.p1, self.p2, self.rng, "excitatory")
     connector.connect(prj)
     self.assertEqual(prj.n, self.p1.size*self.p2.size)
     assert_arrays_almost_equal(numpy.array(prj.connection_manager.weights), numpy.arange(0, prj.n), 1e-6)