File: test_ba.py

package info (click to toggle)
neuron 8.2.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,760 kB
  • sloc: cpp: 149,571; python: 58,465; ansic: 50,329; sh: 3,510; xml: 213; pascal: 51; makefile: 35; sed: 5
file content (134 lines) | stat: -rw-r--r-- 2,566 bytes parent folder | download | duplicates (3)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
from neuron import h, coreneuron

pc = h.ParallelContext()


def model():
    s = h.Section()
    s.insert("ba0")
    s.insert("ba1")
    return s


def run(m):
    r = []
    pc.set_maxstep(10)
    h.finitialize()
    r.append(result(m))
    pc.psolve(h.dt)
    r.append(result(m))
    return r


def result(m):
    r = {}
    seg = m(0.5)
    for mech in [seg.ba0, seg.ba1]:
        for rv in mech:
            r[rv.name()] = rv[0]
    return r


std = [
    {
        "bi_ba0": 0.0,
        "i_ba0": 1.0,
        "ai_ba0": 2.0,
        "bb_ba0": 3.0,
        "b_ba0": -1.0,
        "pval_ba0": -1.0,
        "as_ba0": -1.0,
        "bs_ba0": 4.0,
        "bit_ba0": 0.0,
        "it_ba0": 0.0,
        "ait_ba0": 0.0,
        "bbt_ba0": 0.0,
        "bt_ba0": -1.0,
        "pvalt_ba0": -1.0,
        "ast_ba0": -1.0,
        "bst_ba0": 0.0,
        "icur_ba1": 0.0,
        "bi_ba1": 0.0,
        "i_ba1": 1.0,
        "ai_ba1": 2.0,
        "bb_ba1": 3.0,
        "b_ba1": 5.0,
        "pval_ba1": -1.0,
        "as_ba1": -1.0,
        "bs_ba1": 6.0,
        "bit_ba1": 0.0,
        "it_ba1": 0.0,
        "ait_ba1": 0.0,
        "bbt_ba1": 0.0,
        "bt_ba1": 0.0,
        "pvalt_ba1": -1.0,
        "ast_ba1": -1.0,
        "bst_ba1": 0.0,
        "s_ba1": 0.0,
    },
    {
        "bi_ba0": 0.0,
        "i_ba0": 1.0,
        "ai_ba0": 2.0,
        "bb_ba0": 5.0,
        "b_ba0": 7.0,
        "pval_ba0": 6.0,
        "as_ba0": 8.0,
        "bs_ba0": 9.0,
        "bit_ba0": 0.0,
        "it_ba0": 0.0,
        "ait_ba0": 0.0,
        "bbt_ba0": 0.0125,
        "bt_ba0": 0.025,
        "pvalt_ba0": 0.025,
        "ast_ba0": 0.025,
        "bst_ba0": 0.025,
        "icur_ba1": 0.0,
        "bi_ba1": 0.0,
        "i_ba1": 1.0,
        "ai_ba1": 2.0,
        "bb_ba1": 7.0,
        "b_ba1": 9.0,
        "pval_ba1": 10.0,
        "as_ba1": 11.0,
        "bs_ba1": 12.0,
        "bit_ba1": 0.0,
        "it_ba1": 0.0,
        "ait_ba1": 0.0,
        "bbt_ba1": 0.0125,
        "bt_ba1": 0.0125,
        "pvalt_ba1": 0.025,
        "ast_ba1": 0.025,
        "bst_ba1": 0.025,
        "s_ba1": 0.25,
    },
]


# to make a new std copy output of following to std = ... above and run black.
def mk_std():
    m = model()
    r = run(m)
    print(r)


def cmp(r, s):
    if r != s:
        print("standard", s)
        print("result", r)
    assert r == s


def test_ba():
    m = model()
    r = run(m)
    cmp(r, std)

    coreneuron.enable = True
    h.CVode().cache_efficient(1)
    r = run(m)
    cmp(r, std)


if __name__ == "__main__":
    test_ba()