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

Commit 86307ec

Browse files
author
Jaquier Aurélien Tristan
committed
add tests for new scaler and modified create_hoc
1 parent f8d555f commit 86307ec

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

bluepyopt/tests/test_ephys/test_create_hoc.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import os
66

77
from bluepyopt.ephys.acc import ArbLabel
8+
from bluepyopt.ephys.locations import NrnSomaDistanceCompLocation
89
from bluepyopt.ephys.parameterscalers import NrnSegmentSomaDistanceScaler
10+
from bluepyopt.ephys.parameterscalers import NrnSegmentSomaDistanceStepScaler
911

1012
from . import utils
1113
from bluepyopt.ephys import create_acc, create_hoc
@@ -151,3 +153,33 @@ def test_range_exprs_to_hoc():
151153
assert hoc[0].param_name == 'gkbar_hh'
152154
val_gt = '(-0.8696 + 2.087*exp((%.17g)*0.0031))*0.025000000000000001'
153155
assert hoc[0].value == val_gt
156+
157+
158+
@pytest.mark.unit
159+
def test_range_exprs_to_hoc_step_scaler():
160+
"""ephys.create_hoc: Test range_exprs_to_hoc with step scaler"""
161+
# apical_region = ArbLabel("region", "apic", "(tag 4)")
162+
apical_location = NrnSomaDistanceCompLocation(
163+
name='apic100',
164+
soma_distance=100,
165+
seclist_name='apical',
166+
)
167+
param_scaler = NrnSegmentSomaDistanceStepScaler(
168+
name='soma-distance-step-scaler',
169+
distribution='{value} * (0.1 + 0.9 * int('
170+
'({distance} > {step_begin}) & ('
171+
'{distance} < {step_end})))',
172+
step_begin=300,
173+
step_end=500)
174+
175+
range_expr = create_hoc.RangeExpr(
176+
location=apical_location,
177+
name="gCa_LVAstbar_Ca_LVAst",
178+
value=1,
179+
value_scaler=param_scaler
180+
)
181+
182+
hoc = create_hoc.range_exprs_to_hoc([range_expr])
183+
assert hoc[0].param_name == 'gCa_LVAstbar_Ca_LVAst'
184+
val_gt = '1 * (0.1 + 0.9 * int((%.17g > 300) && (%.17g < 500)))'
185+
assert hoc[0].value == val_gt

bluepyopt/tests/test_ephys/test_parameterscalers.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@ def test_NrnSegmentSectionDistanceScaler_eval_dist_with_dict():
4949

5050
assert (scaler.eval_dist(values=_values, distance=10)
5151
== '0.5 + (1 - (abs(10 - 8) / 4)) * 1')
52+
53+
54+
@pytest.mark.unit
55+
def test_NrnSegmentSomaDistanceStepScaler_eval_dist_with_dict():
56+
"""ephys.parameterscalers: eval_dist of NrnSegmentSomaDistanceStepScaler"""
57+
58+
dist = '{value} * (0.1 + 0.9 * int(' \
59+
'({distance} > {step_begin}) & ({distance} < {step_end})))'
60+
61+
scaler = ephys.parameterscalers.NrnSegmentSomaDistanceStepScaler(
62+
distribution=dist, step_begin=300, step_end=500)
63+
64+
_values = {'value': 1}
65+
66+
assert (scaler.eval_dist(values=_values, distance=10)
67+
== '1 * (0.1 + 0.9 * int((10 > 300) & (10 < 500)))')
5268

5369

5470
@pytest.mark.unit

0 commit comments

Comments
 (0)