Exemple #1
0
 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
Exemple #2
0
 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])
Exemple #3
0
 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
Exemple #4
0
    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])