def test_2(self): net = Network() A = Group(1, "V = B['V']") B = Group(1, "V = A['V']") A[...] = 1 B[...] = 2 net.append(A) net.append(B) net.run(n=1) assert A['V'][0] == 2 and B['V'][0] == 1
def test_1(self): A = Group(1, "V = B['V']") A[...] = 1 B = Group(1, "V = A['V']") B[...] = 2 A.setup() B.setup() A.evaluate(dt=1, update=False) B.evaluate(dt=1, update=False) A.update() B.update() assert A['V'][0] == 2 and B['V'][0] == 1
def test_1(self): G = Group(5, 'V = I; I') Z = np.ones(5) DenseConnection(Z, G('I'), 1) DenseConnection(Z, G('I'), 2) G.run() assert np_equal(3 * np.ones(5), G('V'))
def test_Group_asarray(self): G = Group((5, 5), dtype=[('U', float), ('V', int)], fill=1) A = G.asarray() assert A.shape == (5, 5) assert A.dtype == np.dtype([('U', float), ('V', int)]) assert A['U'].sum() == 25 assert A['V'].sum() == 25
def test_3(self): net = Network(Clock(0.0, 1.0, 0.001)) src = Group((1, ), 'dV/dt=1') src[...] = 1 dst = Group((1, ), 'I') dst[...] = 0 kernel = np.ones(1) C = DenseConnection(src('V'), dst('I'), kernel) net.append(src) net.append(dst) V, I = [], [] @net.clock.every(0.1, order=-1) def do(t): V.append(src['V'][0]) I.append(dst['I'][0]) net.run(time=1.0, dt=0.1) assert np_equal( np.array(V), [1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0]) assert np_equal( np.array(I), [0.0, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9])
def test_subgroup_connections(self): src = np.ones((3, 3)) dst = Group((3, 3), '''U = A+B+V; V = C+D+Z; Z = E A;B;C;D;E''') SparseConnection(src, dst('A'), np.ones((1, 1))) SparseConnection(src, dst('B'), np.ones((1, 1))) SparseConnection(src, dst('C'), np.ones((1, 1))) SparseConnection(src, dst('D'), np.ones((1, 1))) SparseConnection(src, dst('E'), np.ones((1, 1))) Z = dst('U') links = [] for c in Z.connections: links.append(c.target_name) assert 'A' in links assert 'B' in links assert 'C' in links assert 'D' in links assert 'E' in links
def setUp(self): self.Z = Group((3, 3))
def setUp(self): self.Z = Group((3, 5), fill=1.2)
def setUp(self): self.Z = Group()
def setUp(self): self.Z = Group((5, 5), dtype=[('x', float), ('y', float)])
def setUp(self): self.Z = Group((5, 5), dtype=[('U', np.double), ('V', np.int32)])
def setUp(self): self.Z = Group((5, 5), dtype=[('U', float), ('V', int)])