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)
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)
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)
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)
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)
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)
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)
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)
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)
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)