-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The new structure is to have one directory per keyword. Tests can be organized in separate test files, named test_*.py (or simulate.py if that's a better name). Numerous tests have been polished to make them easier to read, using better names and functions to extract common functionality.
- Loading branch information
Showing
36 changed files
with
341 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/usecases/cnexp_array/leonhard.mod → test/usecases/cnexp/cnexp_array.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
NEURON { | ||
SUFFIX leonhard | ||
SUFFIX cnexp_array | ||
RANGE z | ||
} | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
test/usecases/cnexp_scalar/leonhard.mod → test/usecases/cnexp/cnexp_scalar.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
NEURON { | ||
SUFFIX leonhard | ||
SUFFIX cnexp_scalar | ||
} | ||
|
||
STATE { x } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
NEURON { | ||
SUFFIX functions | ||
RANGE x | ||
} | ||
|
||
ASSIGNED { | ||
x | ||
} | ||
|
||
FUNCTION x_plus_a(a) { | ||
x_plus_a = x + a | ||
} | ||
|
||
FUNCTION v_plus_a(a) { | ||
v_plus_a = v + a | ||
} | ||
|
||
FUNCTION identity(v) { | ||
identity = v | ||
} | ||
|
||
INITIAL { | ||
x = 1.0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
NEURON { | ||
POINT_PROCESS point_functions | ||
RANGE x | ||
} | ||
|
||
ASSIGNED { | ||
x | ||
} | ||
|
||
FUNCTION x_plus_a(a) { | ||
x_plus_a = x + a | ||
} | ||
|
||
FUNCTION v_plus_a(a) { | ||
v_plus_a = v + a | ||
} | ||
|
||
FUNCTION identity(v) { | ||
identity = v | ||
} | ||
|
||
INITIAL { | ||
x = 1.0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
NEURON { | ||
SUFFIX recursion | ||
} | ||
|
||
FUNCTION fibonacci(n) { | ||
if (n == 0 || n == 1) { | ||
fibonacci = 1 | ||
} else { | ||
fibonacci = fibonacci(n-1) + fibonacci(n-2) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from neuron import h | ||
|
||
|
||
def check_functions(get_instance): | ||
for x, value in zip(coords, values): | ||
get_instance(x).x = value | ||
|
||
for x, value in zip(coords, values): | ||
expected = 100.0 + value | ||
actual = get_instance(x).x_plus_a(100.0) | ||
assert actual == expected, f"{expected} != {actual}" | ||
|
||
x = coords[0] | ||
v0 = -42.0 | ||
h.finitialize(v0) | ||
|
||
# Check `f(v)`. | ||
expected = 42.0 | ||
actual = get_instance(x).identity(expected) | ||
assert actual == expected, f"{actual} == {expected}" | ||
|
||
# Check `f` using `v`. | ||
expected = -2.0 | ||
actual = get_instance(x).v_plus_a(40.0) | ||
assert actual == expected, f"{actual} == {expected}" | ||
|
||
|
||
nseg = 5 | ||
s = h.Section() | ||
s.nseg = nseg | ||
|
||
s.insert("functions") | ||
|
||
coords = [(0.5 + k) * 1.0 / nseg for k in range(nseg)] | ||
values = [0.1 + k for k in range(nseg)] | ||
|
||
point_processes = {x: h.point_functions(s(x)) for x in coords} | ||
|
||
check_functions(lambda x: s(x).functions) | ||
check_functions(lambda x: point_processes[x]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import math | ||
|
||
import numpy as np | ||
from neuron import gui | ||
from neuron import h | ||
|
||
|
||
s = h.Section(name="soma") | ||
s.insert("recursion") | ||
|
||
n = 6 | ||
actual = [s(0.5).recursion.fibonacci(i) for i in range(n)] | ||
expected = [1, 1, 2, 3, 5, 8] | ||
|
||
assert actual == expected, f"{actual} != {expected}" |
2 changes: 1 addition & 1 deletion
2
test/usecases/global_breakpoint/leonhard.mod → test/usecases/global/read_only.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
NEURON { | ||
SUFFIX leonhard | ||
SUFFIX read_only | ||
GLOBAL c | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/usecases/parameter/test_parameter.mod → test/usecases/parameter/range_parameter.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
NEURON { | ||
POINT_PROCESS test_parameter | ||
POINT_PROCESS range_parameter | ||
RANGE x, y | ||
} | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import numpy as np | ||
|
||
from neuron import h, gui | ||
from neuron.units import ms | ||
|
||
s = h.Section() | ||
|
||
pp = h.range_parameter(s(0.5)) | ||
|
||
# Defaults set in the PARAMETER block: | ||
assert pp.x == 42.0 | ||
assert pp.y == 0.0 | ||
|
||
# Assignable: | ||
pp.x = 42.1 | ||
assert pp.x == 42.1 | ||
|
||
h.stdinit() | ||
h.tstop = 5.0 * ms | ||
h.run() | ||
|
||
# Values (not) set during the INITIAL block: | ||
assert pp.x == 42.1 | ||
assert pp.y == 43.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
NEURON { | ||
POINT_PROCESS pp | ||
} |
Oops, something went wrong.