File: test_include_flux.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 (39 lines) | stat: -rw-r--r-- 1,009 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
from .testutils import compare_data, tol


def test_include_flux(neuron_instance):
    """Test that node.include_flux gives the correct concentrations for 1D.

    node.include_flux can take either a; integer, Python function or NEURON
    pointer. All three are tested here for 1D intercellular rxd.
    """

    h, rxd, data, save_path = neuron_instance
    sec = h.Section(name="sec")
    sec.L = 10
    sec.nseg = 11
    sec.diam = 5

    cyt = rxd.Region(h.allsec(), name="cyt", nrn_region="i")
    ip3 = rxd.Species(
        cyt, name="ip3", initial=lambda nd: 1000 if nd.segment == sec(0.3) else 0
    )

    def callbackfun():
        return 1000

    h.finitialize(-70)

    for nd in ip3.nodes(sec(0.1)):
        nd.include_flux(1000)

    for nd in ip3.nodes(sec(0.5)):
        nd.include_flux(callbackfun)

    for nd in ip3.nodes(sec(0.9)):
        nd.include_flux(sec(0.3)._ref_ip3i)

    h.continuerun(10)
    if not save_path:
        max_err = compare_data(data)
        assert max_err < tol