File: test_thresholder.py

package info (click to toggle)
brian 2.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,872 kB
  • sloc: python: 51,820; cpp: 2,033; makefile: 108; sh: 72
file content (28 lines) | stat: -rw-r--r-- 691 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import pytest
from numpy.testing import assert_equal

from brian2 import *
from brian2.devices.device import reinit_and_delete


@pytest.mark.standalone_compatible
def test_simple_threshold():
    G = NeuronGroup(4, "v : 1", threshold="v > 1")
    G.v = [1.5, 0, 3, -1]
    s_mon = SpikeMonitor(G)
    run(defaultclock.dt)
    assert_equal(s_mon.count, np.array([1, 0, 1, 0]))


@pytest.mark.standalone_compatible
def test_scalar_threshold():
    c = 2
    G = NeuronGroup(4, "", threshold="c > 1")
    s_mon = SpikeMonitor(G)
    run(defaultclock.dt)
    assert_equal(s_mon.count, np.array([1, 1, 1, 1]))


if __name__ == "__main__":
    test_simple_threshold()
    test_scalar_threshold()