def test_linked_var_in_reset_size_1(): G1 = NeuronGroup(1, 'x:1') G2 = NeuronGroup(1, '''x_linked : 1 (linked) y:1''', threshold='y>1', reset='y=0; x_linked += 1') G2.x_linked = linked_var(G1, 'x') G2.y = 1.1 # In this context, x_linked should not be considered as a scalar variable # and therefore the reset statement should be allowed run(3*defaultclock.dt) assert_equal(G1.x[:], 1)
def test_linked_var_in_reset_size_1(): G1 = NeuronGroup(1, 'x:1') G2 = NeuronGroup(1, '''x_linked : 1 (linked) y:1''', threshold='y>1', reset='y=0; x_linked += 1') G2.x_linked = linked_var(G1, 'x') G2.y = 1.1 # In this context, x_linked should not be considered as a scalar variable # and therefore the reset statement should be allowed run(3*defaultclock.dt) assert_equal(G1.x[:], 1)
def test_linked_var_in_reset_incorrect(): # Raise an error if a scalar variable (linked variable from a group of size # 1 is set in a reset statement of a group with size > 1) G1 = NeuronGroup(1, 'x:1') G2 = NeuronGroup(2, '''x_linked : 1 (linked) y:1''', threshold='y>1', reset='y=0; x_linked += 1') G2.x_linked = linked_var(G1, 'x') G2.y = 1.1 net = Network(G1, G2) # It is not well-defined what x_linked +=1 means in this context # (as for any other shared variable) assert_raises(SyntaxError, lambda: net.run(0*ms))
def test_linked_var_in_reset_incorrect(): # Raise an error if a scalar variable (linked variable from a group of size # 1 is set in a reset statement of a group with size > 1) G1 = NeuronGroup(1, 'x:1') G2 = NeuronGroup(2, '''x_linked : 1 (linked) y:1''', threshold='y>1', reset='y=0; x_linked += 1') G2.x_linked = linked_var(G1, 'x') G2.y = 1.1 net = Network(G1, G2) # It is not well-defined what x_linked +=1 means in this context # (as for any other shared variable) assert_raises(SyntaxError, lambda: net.run(0*ms))