Debian Codegraph @

brian2/tests/test_thresholder.py

raw
1 import pytest
2 from numpy.testing import assert_equal
3
4 from brian2 import *
5 from brian2.devices.device import reinit_and_delete
6
7
8 @pytest.mark.standalone_compatible
9 def test_simple_threshold():
10 G = NeuronGroup(4, "v : 1", threshold="v > 1")
11 G.v = [1.5, 0, 3, -1]
12 s_mon = SpikeMonitor(G)
13 run(defaultclock.dt)
14 assert_equal(s_mon.count, np.array([1, 0, 1, 0]))
15
16
17 @pytest.mark.standalone_compatible
18 def test_scalar_threshold():
19 c = 2
20 G = NeuronGroup(4, "", threshold="c > 1")
21 s_mon = SpikeMonitor(G)
22 run(defaultclock.dt)
23 assert_equal(s_mon.count, np.array([1, 1, 1, 1]))
24
25
26 if __name__ == "__main__":
27 test_simple_threshold()
28 test_scalar_threshold()