From 380c1550c353898aa01805c2c8d3484a79089481 Mon Sep 17 00:00:00 2001 From: Luc Grosheintz Date: Tue, 27 Feb 2024 09:01:25 +0100 Subject: [PATCH] Improve usecases 'func_proc{,_pnt}'. Check that if there's multiple instances of the mechanisms the functions and procedures use the values for the correct instance. --- test/usecases/func_proc/func_proc.mod | 4 ++-- test/usecases/func_proc/simulate.py | 18 ++++++++++---- test/usecases/func_proc_pnt/func_proc_pnt.mod | 4 ++-- test/usecases/func_proc_pnt/simulate.py | 24 ++++++++++++++----- 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/test/usecases/func_proc/func_proc.mod b/test/usecases/func_proc/func_proc.mod index b8ad6b46c..c11f662eb 100644 --- a/test/usecases/func_proc/func_proc.mod +++ b/test/usecases/func_proc/func_proc.mod @@ -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() { diff --git a/test/usecases/func_proc/simulate.py b/test/usecases/func_proc/simulate.py index 261ec5407..ca1ffc73b 100644 --- a/test/usecases/func_proc/simulate.py +++ b/test/usecases/func_proc/simulate.py @@ -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 diff --git a/test/usecases/func_proc_pnt/func_proc_pnt.mod b/test/usecases/func_proc_pnt/func_proc_pnt.mod index b97ccd03a..c39f846fb 100644 --- a/test/usecases/func_proc_pnt/func_proc_pnt.mod +++ b/test/usecases/func_proc_pnt/func_proc_pnt.mod @@ -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 } diff --git a/test/usecases/func_proc_pnt/simulate.py b/test/usecases/func_proc_pnt/simulate.py index 41c22b460..20d676006 100644 --- a/test/usecases/func_proc_pnt/simulate.py +++ b/test/usecases/func_proc_pnt/simulate.py @@ -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)])