This repository was archived by the owner on Feb 26, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed
Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff line change 44
55import os
66
7+ from bluepyopt .ephys .acc import ArbLabel
8+ from bluepyopt .ephys .parameterscalers import NrnSegmentSomaDistanceScaler
9+
710from . import utils
8- from bluepyopt .ephys import create_hoc
11+ from bluepyopt .ephys import create_acc , create_hoc
912
1013
1114import pytest
12- import numpy
1315
1416DEFAULT_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
You can’t perform that action at this time.
0 commit comments