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

Commit d46979b

Browse files
Merge pull request #498 from BlueBrain/arbor-v0.10
fix arbor tests with latest arbor version
2 parents 4fcf47a + d1758ba commit d46979b

27 files changed

+114
-68
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [ubuntu-latest]
15-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
15+
python-version: ["3.9", "3.10", "3.11", "3.12"]
1616
include:
1717
- os: macos-12
1818
python-version: "3.10"
@@ -34,7 +34,7 @@ jobs:
3434
run: tox
3535

3636
- name: "Upload coverage to Codecov"
37-
uses: codecov/codecov-action@v2
37+
uses: codecov/codecov-action@v4
3838
with:
3939
token: ${{ secrets.CODECOV_TOKEN }}
4040
fail_ci_if_error: false

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ News
8585
Requirements
8686
============
8787

88-
* `Python 3.8+ <https://www.python.org/downloads/release/python-380/>`_
88+
* `Python 3.9+ <https://www.python.org/downloads/release/python-390/>`_
8989
* `Pip <https://pip.pypa.io>`_ (installed by default in newer versions of Python)
9090
* `Neuron 7.4+ <http://neuron.yale.edu/>`_ (compiled with Python support)
9191
* `eFEL eFeature Extraction Library <https://github.com/BlueBrain/eFEL>`_ (automatically installed by pip)

bluepyopt/ephys/morphologies.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ def load(morpho_filename, replace_axon):
307307
morpho = arbor.load_component(morpho_filename).component
308308
elif morpho_suffix == '.swc':
309309
morpho = arbor.load_swc_arbor(morpho_filename)
310+
# turn loaded_morphology into morphology type
311+
morpho = morpho.morphology
310312
elif morpho_suffix == '.asc':
311313
morpho = arbor.load_asc(morpho_filename).morphology
312314
else:

bluepyopt/ephys/protocols.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,12 @@ def instantiate_iclamp_stimuli(self, decor, use_labels=False):
602602
for i, stim in enumerate(self.stimuli):
603603
if not isinstance(stim, stimuli.SynapticStimulus):
604604
if hasattr(stim, 'envelope'):
605-
arb_iclamp = arbor.iclamp(stim.envelope())
605+
envelope = stim.envelope()
606+
envelope = [
607+
(t * arbor.units.ms, curr * arbor.units.nA)
608+
for (t, curr) in envelope
609+
]
610+
arb_iclamp = arbor.iclamp(envelope)
606611
else:
607612
raise ValueError('Stimulus must provide envelope method '
608613
' or be of type NrnNetStimStimulus to be'
@@ -648,7 +653,9 @@ def instantiate_recordings(self, cell_model, use_labels=False):
648653

649654
cell_model.probe('voltage',
650655
arb_loc.ref if use_labels else arb_loc.loc,
651-
frequency=10) # could be a parameter
656+
f"probe-{i}",
657+
# frequency could be a parameter
658+
frequency=10 * arbor.units.kHz)
652659

653660
return cell_model
654661

bluepyopt/ephys/simulators.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,11 @@ def run(self, arb_cell_model, tstop=None, dt=None):
372372
dt = dt if dt is not None else self.dt
373373

374374
if dt is not None:
375-
return arb_cell_model.run(tfinal=tstop, dt=dt)
375+
return arb_cell_model.run(
376+
tfinal=tstop * arbor.units.ms, dt=dt * arbor.units.ms
377+
)
376378
else:
377-
return arb_cell_model.run(tfinal=tstop)
379+
return arb_cell_model.run(tfinal=tstop * arbor.units.ms)
378380

379381

380382
class ArbSimulatorException(Exception):

bluepyopt/ephys/templates/acc/decor_acc_template.jinja2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(arbor-component
2-
(meta-data (version "0.1-dev"))
2+
(meta-data (version "0.9-dev"))
33
(decor
44
{%- for mech, params in global_mechs.items() %}
55
{%- if mech is not none %}
@@ -10,7 +10,7 @@
1010
{%- endif %}
1111
{%- else %}
1212
{%- for param in params %}
13-
(default ({{ param.name }} {{ param.value }}))
13+
(default ({{ param.name }} {{ param.value }} (scalar 1.0)))
1414
{%- endfor %}
1515
{%- endif %}
1616
{%- endfor %}
@@ -27,13 +27,13 @@
2727
{%- endif %}
2828
{%- else %}
2929
{%- for param in params %}
30-
(paint {{loc.ref}} ({{ param.name }} {{ param.value }}))
30+
(paint {{loc.ref}} ({{ param.name }} {{ param.value }} (scalar 1.0)))
3131
{%- endfor %}
3232
{%- endif %}
3333
{%- endfor %}
3434

3535
{%- for synapse_name, mech_params in pprocess_mechs[loc].items() %}
36-
(place {{loc.ref}} (synapse (mechanism "{{ mech_params.mech }}" {%- for param in mech_params.params %} ("{{ param.name }}" {{ param.value }}){%- endfor %})) "{{ synapse_name }}")
36+
(place {{loc.ref}} (synapse (mechanism "{{ mech_params.mech }}" {%- for param in mech_params.params %} ("{{ param.name }}" {{ param.value }} (scalar 1.0)){%- endfor %})) "{{ synapse_name }}")
3737
{%- endfor %}
3838

3939
{%- endfor %}))

bluepyopt/ephys/templates/acc/label_dict_acc_template.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(arbor-component
2-
(meta-data (version "0.1-dev"))
2+
(meta-data (version "0.9-dev"))
33
(label-dict
44
{%- for loc, label in label_dict.items() %}
55
{{ label.defn }}

bluepyopt/tests/test_ephys/test_create_acc.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ def run_short_sim(cable_cell):
537537
arb_cell_model.properties.catalogue.extend(arbor.bbp_catalogue(), "BBP::")
538538

539539
# Run a very short simulation to test mechanism instantiation
540-
arb_cell_model.run(tfinal=0.1)
540+
arb_cell_model.run(tfinal=0.1 * arbor.units.ms)
541541

542542

543543
@pytest.mark.unit
@@ -665,6 +665,10 @@ def check_acc_dir(test_dir, ref_dir):
665665
with open(ref_dir_file / file) as f:
666666
ref_file = f.read()
667667
assert ref_file == test_file
668+
# check that load_component is not raising any error here
669+
fpath = pathlib.Path(test_dir) / file
670+
if fpath.suffix == "acc":
671+
arbor.load_component(fpath).component
668672

669673

670674
@pytest.mark.unit

bluepyopt/tests/test_ephys/test_parameterscalers.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
"""Test ephys.parameterscalers"""
22

33
import json
4-
4+
import pathlib
5+
import tempfile
6+
import arbor
57

68
import pytest
79

@@ -143,3 +145,33 @@ def test_parameterscalers_iexpr_generator_unsupported_attr():
143145
'unsupported attribute tau.'):
144146
iexpr = value_scaler.acc_scale_iexpr(
145147
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
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
(arbor-component
2-
(meta-data (version "0.1-dev"))
2+
(meta-data (version "0.9-dev"))
33
(decor
4-
(default (gSKv3_1bar_SKv3_1 65))
5-
(paint (region "soma") (gSKv3_1bar_SKv3_1 65))
6-
(paint (region "soma") (gSKv3_1bar_SKv3_1 65))
4+
(default (gSKv3_1bar_SKv3_1 65 (scalar 1.0)))
5+
(paint (region "soma") (gSKv3_1bar_SKv3_1 65 (scalar 1.0)))
6+
(paint (region "soma") (gSKv3_1bar_SKv3_1 65 (scalar 1.0)))
77
(paint (region "dend") (density (mechanism "BBP::Ih")))
8-
(paint (region "apic") (gSKv3_1bar_SKv3_1 65))
9-
(paint (region "apic") (gSKv3_1bar_SKv3_1 65))
8+
(paint (region "apic") (gSKv3_1bar_SKv3_1 65 (scalar 1.0)))
9+
(paint (region "apic") (gSKv3_1bar_SKv3_1 65 (scalar 1.0)))
1010
(paint (region "apic") (density (mechanism "BBP::Ih")))))

0 commit comments

Comments
 (0)