-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Get voltage via `prop->node`. When calling functions directly, don't have access to the `NrnThread` and therefore can't get node properties, like the voltage from there. The solution is to create a link from the Prop to the Node. Then use that link to figure out the node properties. The trick to make the two cases uniform is the same as we use for instance data, we create pointers to array of length one (by taking the address of the element) and setting `_iml`/`id` to `0`. * Artificial cells aren't associated with a node. * Support top LOCALs in non-vectorized MOD files. * Test function calls with non-threadsafe MOD files. * Test globals in non-VECTORIZED MOD files. * Improve function calling coverage. * Test function calls for ARTIFICIAL_CELLs. * Remove debugging output.
- Loading branch information
Showing
7 changed files
with
252 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
NEURON { | ||
ARTIFICIAL_CELL art_functions | ||
RANGE x | ||
GLOBAL gbl | ||
} | ||
|
||
ASSIGNED { | ||
gbl | ||
v | ||
x | ||
} | ||
|
||
FUNCTION x_plus_a(a) { | ||
x_plus_a = x + a | ||
} | ||
|
||
FUNCTION identity(v) { | ||
identity = v | ||
} | ||
|
||
INITIAL { | ||
x = 1.0 | ||
gbl = 42.0 | ||
} | ||
|
||
: A LINEAR block makes a MOD file not VECTORIZED. | ||
STATE { | ||
z | ||
} | ||
|
||
LINEAR lin { | ||
~ z = 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,38 @@ | ||
NEURON { | ||
SUFFIX non_threadsafe | ||
RANGE x | ||
GLOBAL gbl | ||
} | ||
|
||
ASSIGNED { | ||
gbl | ||
v | ||
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 | ||
gbl = 42.0 | ||
} | ||
|
||
: A LINEAR block makes a MOD file not VECTORIZED. | ||
STATE { | ||
z | ||
} | ||
|
||
LINEAR lin { | ||
~ z = 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,38 @@ | ||
NEURON { | ||
POINT_PROCESS point_non_threadsafe | ||
RANGE x | ||
GLOBAL gbl | ||
} | ||
|
||
ASSIGNED { | ||
gbl | ||
v | ||
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 | ||
gbl = 42.0 | ||
} | ||
|
||
: A LINEAR block makes a MOD file not VECTORIZED. | ||
STATE { | ||
z | ||
} | ||
|
||
LINEAR lin { | ||
~ z = 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
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,43 @@ | ||
NEURON { | ||
SUFFIX non_threadsafe | ||
GLOBAL gbl | ||
} | ||
|
||
LOCAL top_local | ||
|
||
PARAMETER { | ||
parameter = 41.0 | ||
} | ||
|
||
ASSIGNED { | ||
gbl | ||
} | ||
|
||
FUNCTION get_gbl() { | ||
get_gbl = gbl | ||
} | ||
|
||
FUNCTION get_top_local() { | ||
get_top_local = top_local | ||
} | ||
|
||
FUNCTION get_parameter() { | ||
get_parameter = parameter | ||
} | ||
|
||
INITIAL { | ||
gbl = 42.0 | ||
top_local = 43.0 | ||
} | ||
|
||
: A LINEAR block makes the MOD file not thread-safe and not | ||
: vectorized. We don't otherwise care about anything below | ||
: this comment. | ||
STATE { | ||
z | ||
} | ||
|
||
LINEAR lin { | ||
~ z = 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,33 @@ | ||
import numpy as np | ||
|
||
from neuron import h, gui | ||
from neuron.units import ms | ||
|
||
|
||
def test_non_threadsafe(): | ||
nseg = 1 | ||
|
||
s = h.Section() | ||
s.insert("non_threadsafe") | ||
s.nseg = nseg | ||
|
||
h.finitialize() | ||
|
||
instance = s(0.5).non_threadsafe | ||
|
||
# Check INITIAL values. | ||
assert instance.get_parameter() == 41.0 | ||
assert instance.get_gbl() == 42.0 | ||
assert instance.get_top_local() == 43.0 | ||
|
||
# Check reassigning a value. Top LOCAL variables | ||
# are not exposed to HOC/Python. | ||
h.parameter_non_threadsafe = 32.1 | ||
h.gbl_non_threadsafe = 33.2 | ||
|
||
assert instance.get_parameter() == 32.1 | ||
assert instance.get_gbl() == 33.2 | ||
|
||
|
||
if __name__ == "__main__": | ||
test_non_threadsafe() |