コード例 #1
0
def test_restart_interal():

    # Run part-way and serialize:
    b1 = ExternalPopulation('100', record=True)
    i1 = InternalPopulation(v_min=0, v_max=.02, dv=.001)
    b1_i1 = Connection(b1, i1, 1, weights=.005, delays=0.0)
    simulation = Network([b1, i1], [b1_i1])
    simulation.run(dt=.001, tf=.01, t0=0)
    i1_str = i1.to_json()
    b1_str = b1.to_json()
    
    # Rehydrate and continue run:
    b2 = ExternalPopulation(**json.loads(b1_str))
    i2 = InternalPopulation(**json.loads(i1_str))
    simulation2 = Network([b2, i2], [Connection(b2, i2, 1, weights=.005, delays=0.0)])
    simulation2.run(dt=.001, tf=.02, t0=.01)
    
    # Run straight through, for comparison:
    b3 = ExternalPopulation('100', record=True)
    i3 = InternalPopulation(v_min=0, v_max=.02, dv=.001)
    simulation3 = Network([b3, i3], [Connection(b3, i3, 1, weights=.005, delays=0.0)])
    simulation3.run(dt=.001, tf=.02, t0=0)

    # Test:
    for y1, y2 in zip(i1.firing_rate_record, i3.firing_rate_record):
        np.testing.assert_almost_equal(y1, y2, 8) 

    b3.to_json(StringIO.StringIO())
    i3.to_json(StringIO.StringIO())
    b1_i1.to_json(StringIO.StringIO())
コード例 #2
0
def test_marshal_connection():
    c = Connection(0, 1, 1, weights=.005, delays=.005)
    c.to_json()