File: monitors.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 (53 lines) | stat: -rw-r--r-- 1,257 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
Check that various monitors work correctly.
"""

from brian2 import *
from brian2.tests.features import FeatureTest, InaccuracyError


class SpikeMonitorTest(FeatureTest):
    category = "Monitors"
    name = "SpikeMonitor"
    tags = ["NeuronGroup", "run", "SpikeMonitor"]

    def run(self):
        N = 100
        tau = 10 * ms
        eqs = """
        dv/dt = (I-v)/tau : 1
        I : 1
        """
        self.G = G = NeuronGroup(N, eqs, threshold="v>1", reset="v=0")
        G.I = linspace(0, 2, N)
        self.M = M = SpikeMonitor(G)
        run(100 * ms)

    def results(self):
        return {"i": self.M.i[:], "t": self.M.t[:]}

    compare = FeatureTest.compare_arrays


class StateMonitorTest(FeatureTest):
    category = "Monitors"
    name = "StateMonitor"
    tags = ["NeuronGroup", "run", "StateMonitor"]

    def run(self):
        N = 10
        tau = 10 * ms
        eqs = """
        dv/dt = (I-v)/tau : 1
        I : 1
        """
        self.G = G = NeuronGroup(N, eqs, threshold="v>1", reset="v=0.1")
        G.v = 0.1
        G.I = linspace(1.1, 2, N)
        self.M = M = StateMonitor(G, "v", record=True)
        run(100 * ms)

    def results(self):
        return self.M.v[:]

    compare = FeatureTest.compare_arrays