|
1 | 1 | """Test ephys.parameterscalers"""
|
2 | 2 |
|
3 | 3 | import json
|
4 |
| - |
| 4 | +import pathlib |
| 5 | +import tempfile |
| 6 | +import arbor |
5 | 7 |
|
6 | 8 | import pytest
|
7 | 9 |
|
@@ -143,3 +145,33 @@ def test_parameterscalers_iexpr_generator_unsupported_attr():
|
143 | 145 | 'unsupported attribute tau.'):
|
144 | 146 | iexpr = value_scaler.acc_scale_iexpr(
|
145 | 147 | value=value, constant_formatter=lambda v: '%.9g' % v)
|
| 148 | + |
| 149 | + |
| 150 | +@pytest.mark.unit |
| 151 | +def test_parameterscalers_iexpr(): |
| 152 | + """ephys.parameterscalers: Test iexpr""" |
| 153 | + # iexpr from bluepyopt/tests/test_ephys/test_parameterscalers.py |
| 154 | + iexpr = '(sub (scalar 0.62109375) ' \ |
| 155 | + '(mul (log (pi) ) ' \ |
| 156 | + '(exp (div (distance (region "soma")) ' \ |
| 157 | + '(scalar 0.421875) ) ) ) )' |
| 158 | + |
| 159 | + # modified decor as in |
| 160 | + # bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_cell_decor.acc |
| 161 | + simple_cell_decor_with_iexpr = \ |
| 162 | + '(arbor-component\n' \ |
| 163 | + ' (meta-data (version "0.9-dev"))\n' \ |
| 164 | + ' (decor\n' \ |
| 165 | + ' (paint (region "soma") ' \ |
| 166 | + '(membrane-capacitance 0.01 (scalar 1.0)))\n' \ |
| 167 | + ' (paint (region "soma") ' \ |
| 168 | + '(scaled-mechanism (density (mechanism "default::hh" ' \ |
| 169 | + '("gnabar" 0.10299326453483033) ("gkbar" 0.027124836082684685))) ' \ |
| 170 | + f'("gkbar" {iexpr})))))' |
| 171 | + |
| 172 | + with tempfile.TemporaryDirectory() as test_dir: |
| 173 | + decor_filename = pathlib.Path(test_dir).joinpath("decor.acc") |
| 174 | + with open(decor_filename, "w") as f: |
| 175 | + f.write(simple_cell_decor_with_iexpr) |
| 176 | + # check that load_component is not raising any error here |
| 177 | + arbor.load_component(decor_filename).component |
0 commit comments