File: test_rangevarplot.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 (56 lines) | stat: -rw-r--r-- 1,474 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
import pytest
import gc


@pytest.fixture
def model_rangevarplot(neuron_instance):
    h, rxd, data, save_path = neuron_instance

    def make_rvp(with_sec=True, with_species=True):
        dend = h.Section(name="dend")
        dend.L = 3
        dend.diam = 2
        dend.nseg = 3

        def my_initial(node):
            if h.distance(node, dend(0)) < 2:
                return 1
            else:
                return 0

        cyt = rxd.Region([dend], name="cyt")
        c = rxd.Species(cyt, name="c", initial=my_initial)

        g = h.RangeVarPlot(c, dend(0), dend(1))
        c = c if with_species else None
        dend = dend if with_sec else None
        gc.collect()
        return (dend, cyt, c, g)

    yield (h, rxd, make_rvp)


def test_rangevarplot(model_rangevarplot):
    h, rxd, make_rvp = model_rangevarplot
    dend, cyt, c, g = make_rvp()
    vec = h.Vector()
    g.to_vector(vec)
    assert vec.to_python() == [0, 1, 1, 0, 0]


def test_rangevarplot_no_species(model_rangevarplot):
    h, rxd, make_rvp = model_rangevarplot
    dend, cyt, c, g = make_rvp(with_species=False)
    vec = h.Vector()
    g.to_vector(vec)
    assert vec.to_python() == [0, 0, 0, 0, 0]


def test_rangevarplot_no_section(model_rangevarplot):
    h, rxd, make_rvp = model_rangevarplot
    dend, cyt, c, g = make_rvp(with_sec=False)
    vec = h.Vector()
    g.to_vector(vec)
    for sec in h.allsec():
        assert False
    assert vec.to_python() == [0, 0, 0, 0, 0]