Skip to content

Commit

Permalink
Improve usecases 'func_proc{,_pnt}'. (#1182)
Browse files Browse the repository at this point in the history
Check that if there's multiple instances of the mechanisms the functions
and procedures use the values for the correct instance.
  • Loading branch information
1uc authored and ohm314 committed May 21, 2024
1 parent 3ff1d01 commit e5ae9bc
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 16 deletions.
4 changes: 2 additions & 2 deletions test/usecases/func_proc/func_proc.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ PROCEDURE set_x_a(a) {
x = a
}

FUNCTION get_a_42(a) {
get_a_42 = a + 42
FUNCTION x_plus_a(a) {
x_plus_a = x + a
}

PROCEDURE set_a_x() {
Expand Down
18 changes: 13 additions & 5 deletions test/usecases/func_proc/simulate.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
from neuron import h

nseg = 5
s = h.Section()
s.nseg = nseg

s.insert("test_func_proc")

s(0.5).test_func_proc.set_x_42()
coords = [(0.5 + k) * 1.0 / nseg for k in range(nseg)]
values = [ 0.1 + k for k in range(nseg)]

assert s(0.5).test_func_proc.x == 42
for x in coords:
s(x).test_func_proc.set_x_42()
assert s(x).test_func_proc.x == 42

s(0.5).test_func_proc.set_x_a(13.7)
for x, value in zip(coords, values):
s(x).test_func_proc.set_x_a(value)

assert s(0.5).test_func_proc.x == 13.7
for x, value in zip(coords, values):
assert s(x).test_func_proc.x == value

assert s(0.5).test_func_proc.get_a_42(42) == 84
for x, value in zip(coords, values):
assert s(x).test_func_proc.x_plus_a(100.0) == 100.0 + value
4 changes: 2 additions & 2 deletions test/usecases/func_proc_pnt/func_proc_pnt.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ PROCEDURE set_x_a(a) {
x = a
}

FUNCTION get_a_42(a) {
get_a_42 = a + 42
FUNCTION x_plus_a(a) {
x_plus_a = x + a
}
24 changes: 18 additions & 6 deletions test/usecases/func_proc_pnt/simulate.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
from neuron import h

nseg = 5
s = h.Section()
s.nseg = nseg

pnt_proc = h.test_func_proc_pnt(s(0.5))
point_processes = []
for k in range(nseg):
x = (0.5 + k) * 1.0 / nseg
point_processes.append(h.test_func_proc_pnt(s(x)))

pnt_proc.set_x_42()
for k in range(nseg):
point_processes[k].set_x_42()

assert pnt_proc.x == 42
for k in range(nseg):
assert point_processes[k].x == 42

pnt_proc.set_x_a(13.7)
for k in range(nseg):
value = 0.1 + k
point_processes[k].set_x_a(value)

assert pnt_proc.x == 13.7
for k in range(nseg):
value = 0.1 + k
assert point_processes[k].x == value
assert point_processes[k].x_plus_a(1000.0) == 1000.0 + value

assert pnt_proc.get_a_42(42) == 84
print([point_processes[k].x for k in range(nseg)])

0 comments on commit e5ae9bc

Please sign in to comment.