Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit c6d28a9

Browse files
committed
make range_exprs_to_hoc public
1 parent e47903b commit c6d28a9

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

bluepyopt/ephys/create_hoc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def generate_reinitrng(mechs) -> str:
9898
return reinitrng_content
9999

100100

101-
def _range_exprs_to_hoc(range_params):
101+
def range_exprs_to_hoc(range_params):
102102
"""Process raw range parameters to hoc strings"""
103103

104104
ret = []
@@ -330,7 +330,7 @@ def create_hoc(mechs,
330330
del template_params['pprocess_params']
331331
del template_params['point_channels']
332332

333-
template_params['range_params'] = _range_exprs_to_hoc(
333+
template_params['range_params'] = range_exprs_to_hoc(
334334
template_params['range_params']
335335
)
336336
re_init_rng = generate_reinitrng(mechs)

bluepyopt/tests/test_ephys/test_create_hoc.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
import os
66

7+
from bluepyopt.ephys.acc import ArbLabel
8+
from bluepyopt.ephys.parameterscalers import NrnSegmentSomaDistanceScaler
9+
710
from . import utils
8-
from bluepyopt.ephys import create_hoc
11+
from bluepyopt.ephys import create_acc, create_hoc
912

1013

1114
import pytest
12-
import numpy
1315

1416
DEFAULT_LOCATION_ORDER = [
1517
'all',
@@ -127,3 +129,25 @@ def test_generate_reinitrng():
127129
re_init_rng = create_hoc.generate_reinitrng([mech])
128130
assert 'func hash_str() {localobj sf strdef right' in re_init_rng
129131
assert ' hash = (hash * 31 + char_int) % (2 ^ 31 - 1)' in re_init_rng
132+
133+
134+
@pytest.mark.unit
135+
def test_range_exprs_to_hoc():
136+
"""ephys.create_hoc: Test range_exprs_to_hoc"""
137+
apical_region = ArbLabel("region", "apic", "(tag 4)")
138+
param_scaler = NrnSegmentSomaDistanceScaler(
139+
name='soma-distance-scaler',
140+
distribution='(-0.8696 + 2.087*math.exp(({distance})*0.0031))*{value}'
141+
)
142+
143+
range_expr = create_acc.RangeExpr(
144+
location=apical_region,
145+
name="gkbar_hh",
146+
value=0.025,
147+
value_scaler=param_scaler
148+
)
149+
150+
hoc = create_hoc.range_exprs_to_hoc([range_expr])
151+
assert hoc[0].param_name == 'gkbar_hh'
152+
val_gt = '(-0.8696 + 2.087*exp((%.17g)*0.0031))*0.025000000000000001'
153+
assert hoc[0].value == val_gt

0 commit comments

Comments
 (0)