From 3c887d7073c6b19fe1d81b46805bc688ca3eda68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Tue, 20 Aug 2024 11:30:54 +0200 Subject: [PATCH 1/9] fix arbor tests with latest arbor version --- bluepyopt/ephys/morphologies.py | 2 ++ bluepyopt/ephys/templates/acc/decor_acc_template.jinja2 | 2 +- bluepyopt/ephys/templates/acc/label_dict_acc_template.jinja2 | 2 +- bluepyopt/tests/test_ephys/test_create_acc.py | 2 +- bluepyopt/tests/test_ephys/testdata/acc/CCell/CCell_decor.acc | 2 +- .../tests/test_ephys/testdata/acc/CCell/CCell_label_dict.acc | 2 +- .../test_ephys/testdata/acc/CCell/simple_axon_replacement.acc | 2 +- .../tests/test_ephys/testdata/acc/expsyn/simple_cell_decor.acc | 2 +- .../test_ephys/testdata/acc/expsyn/simple_cell_label_dict.acc | 2 +- .../test_ephys/testdata/acc/l5pc/C060114A7_axon_replacement.acc | 2 +- .../tests/test_ephys/testdata/acc/l5pc/C060114A7_modified.acc | 2 +- bluepyopt/tests/test_ephys/testdata/acc/l5pc/l5pc_decor.acc | 2 +- .../tests/test_ephys/testdata/acc/l5pc/l5pc_label_dict.acc | 2 +- .../tests/test_ephys/testdata/acc/l5pc_py37/l5pc_decor.acc | 2 +- .../testdata/acc/simplecell/simple_axon_replacement.acc | 2 +- .../test_ephys/testdata/acc/simplecell/simple_cell_decor.acc | 2 +- .../testdata/acc/simplecell/simple_cell_label_dict.acc | 2 +- .../test_ephys/testdata/acc/simplecell/simple_modified.acc | 2 +- .../test_ephys/testdata/acc/templates/decor_acc_template.jinja2 | 2 +- .../testdata/acc/templates/label_dict_acc_template.jinja2 | 2 +- 20 files changed, 21 insertions(+), 19 deletions(-) diff --git a/bluepyopt/ephys/morphologies.py b/bluepyopt/ephys/morphologies.py index 27a6d5d4..9acd7dda 100644 --- a/bluepyopt/ephys/morphologies.py +++ b/bluepyopt/ephys/morphologies.py @@ -307,6 +307,8 @@ def load(morpho_filename, replace_axon): morpho = arbor.load_component(morpho_filename).component elif morpho_suffix == '.swc': morpho = arbor.load_swc_arbor(morpho_filename) + # turn loaded_morphology into morphology type + morpho = arbor.morphology(morpho.segment_tree) elif morpho_suffix == '.asc': morpho = arbor.load_asc(morpho_filename).morphology else: diff --git a/bluepyopt/ephys/templates/acc/decor_acc_template.jinja2 b/bluepyopt/ephys/templates/acc/decor_acc_template.jinja2 index 13ae43d1..ad2dbfe7 100644 --- a/bluepyopt/ephys/templates/acc/decor_acc_template.jinja2 +++ b/bluepyopt/ephys/templates/acc/decor_acc_template.jinja2 @@ -1,5 +1,5 @@ (arbor-component - (meta-data (version "0.1-dev")) + (meta-data (version "0.9-dev")) (decor {%- for mech, params in global_mechs.items() %} {%- if mech is not none %} diff --git a/bluepyopt/ephys/templates/acc/label_dict_acc_template.jinja2 b/bluepyopt/ephys/templates/acc/label_dict_acc_template.jinja2 index 508c0aa1..ca2e7dac 100644 --- a/bluepyopt/ephys/templates/acc/label_dict_acc_template.jinja2 +++ b/bluepyopt/ephys/templates/acc/label_dict_acc_template.jinja2 @@ -1,5 +1,5 @@ (arbor-component - (meta-data (version "0.1-dev")) + (meta-data (version "0.9-dev")) (label-dict {%- for loc, label in label_dict.items() %} {{ label.defn }} diff --git a/bluepyopt/tests/test_ephys/test_create_acc.py b/bluepyopt/tests/test_ephys/test_create_acc.py index baae6def..c1088596 100644 --- a/bluepyopt/tests/test_ephys/test_create_acc.py +++ b/bluepyopt/tests/test_ephys/test_create_acc.py @@ -537,7 +537,7 @@ def run_short_sim(cable_cell): arb_cell_model.properties.catalogue.extend(arbor.bbp_catalogue(), "BBP::") # Run a very short simulation to test mechanism instantiation - arb_cell_model.run(tfinal=0.1) + arb_cell_model.run(tfinal=0.1 *arbor.units.ms) @pytest.mark.unit diff --git a/bluepyopt/tests/test_ephys/testdata/acc/CCell/CCell_decor.acc b/bluepyopt/tests/test_ephys/testdata/acc/CCell/CCell_decor.acc index dd9c47e9..c1820f01 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/CCell/CCell_decor.acc +++ b/bluepyopt/tests/test_ephys/testdata/acc/CCell/CCell_decor.acc @@ -1,5 +1,5 @@ (arbor-component - (meta-data (version "0.1-dev")) + (meta-data (version "0.9-dev")) (decor (default (gSKv3_1bar_SKv3_1 65)) (paint (region "soma") (gSKv3_1bar_SKv3_1 65)) diff --git a/bluepyopt/tests/test_ephys/testdata/acc/CCell/CCell_label_dict.acc b/bluepyopt/tests/test_ephys/testdata/acc/CCell/CCell_label_dict.acc index 08c4efd5..2fcd0172 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/CCell/CCell_label_dict.acc +++ b/bluepyopt/tests/test_ephys/testdata/acc/CCell/CCell_label_dict.acc @@ -1,5 +1,5 @@ (arbor-component - (meta-data (version "0.1-dev")) + (meta-data (version "0.9-dev")) (label-dict (region-def "all" (all)) (region-def "apic" (tag 4)) diff --git a/bluepyopt/tests/test_ephys/testdata/acc/CCell/simple_axon_replacement.acc b/bluepyopt/tests/test_ephys/testdata/acc/CCell/simple_axon_replacement.acc index 7dee06c1..b5df598b 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/CCell/simple_axon_replacement.acc +++ b/bluepyopt/tests/test_ephys/testdata/acc/CCell/simple_axon_replacement.acc @@ -1,6 +1,6 @@ (arbor-component (meta-data - (version "0.1-dev")) + (version "0.9-dev")) (morphology (branch 0 -1 (segment 0 diff --git a/bluepyopt/tests/test_ephys/testdata/acc/expsyn/simple_cell_decor.acc b/bluepyopt/tests/test_ephys/testdata/acc/expsyn/simple_cell_decor.acc index ff1e8f1b..335b4ff1 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/expsyn/simple_cell_decor.acc +++ b/bluepyopt/tests/test_ephys/testdata/acc/expsyn/simple_cell_decor.acc @@ -1,5 +1,5 @@ (arbor-component - (meta-data (version "0.1-dev")) + (meta-data (version "0.9-dev")) (decor (paint (region "soma") (membrane-capacitance 0.01)) (paint (region "soma") (density (mechanism "default::pas"))) diff --git a/bluepyopt/tests/test_ephys/testdata/acc/expsyn/simple_cell_label_dict.acc b/bluepyopt/tests/test_ephys/testdata/acc/expsyn/simple_cell_label_dict.acc index fe69d135..ab69054e 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/expsyn/simple_cell_label_dict.acc +++ b/bluepyopt/tests/test_ephys/testdata/acc/expsyn/simple_cell_label_dict.acc @@ -1,5 +1,5 @@ (arbor-component - (meta-data (version "0.1-dev")) + (meta-data (version "0.9-dev")) (label-dict (region-def "all" (all)) (region-def "soma" (tag 1)) diff --git a/bluepyopt/tests/test_ephys/testdata/acc/l5pc/C060114A7_axon_replacement.acc b/bluepyopt/tests/test_ephys/testdata/acc/l5pc/C060114A7_axon_replacement.acc index 1723e930..e9f03844 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/l5pc/C060114A7_axon_replacement.acc +++ b/bluepyopt/tests/test_ephys/testdata/acc/l5pc/C060114A7_axon_replacement.acc @@ -1,6 +1,6 @@ (arbor-component (meta-data - (version "0.1-dev")) + (version "0.9-dev")) (morphology (branch 0 -1 (segment 0 diff --git a/bluepyopt/tests/test_ephys/testdata/acc/l5pc/C060114A7_modified.acc b/bluepyopt/tests/test_ephys/testdata/acc/l5pc/C060114A7_modified.acc index d47f3c7d..26451178 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/l5pc/C060114A7_modified.acc +++ b/bluepyopt/tests/test_ephys/testdata/acc/l5pc/C060114A7_modified.acc @@ -1,6 +1,6 @@ (arbor-component (meta-data - (version "0.1-dev")) + (version "0.9-dev")) (morphology (branch 0 -1 (segment 0 diff --git a/bluepyopt/tests/test_ephys/testdata/acc/l5pc/l5pc_decor.acc b/bluepyopt/tests/test_ephys/testdata/acc/l5pc/l5pc_decor.acc index 9b499549..2a7b5dfb 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/l5pc/l5pc_decor.acc +++ b/bluepyopt/tests/test_ephys/testdata/acc/l5pc/l5pc_decor.acc @@ -1,5 +1,5 @@ (arbor-component - (meta-data (version "0.1-dev")) + (meta-data (version "0.9-dev")) (decor (default (membrane-potential -65)) (default (temperature-kelvin 307.14999999999998)) diff --git a/bluepyopt/tests/test_ephys/testdata/acc/l5pc/l5pc_label_dict.acc b/bluepyopt/tests/test_ephys/testdata/acc/l5pc/l5pc_label_dict.acc index ea26ab1a..feec6f79 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/l5pc/l5pc_label_dict.acc +++ b/bluepyopt/tests/test_ephys/testdata/acc/l5pc/l5pc_label_dict.acc @@ -1,5 +1,5 @@ (arbor-component - (meta-data (version "0.1-dev")) + (meta-data (version "0.9-dev")) (label-dict (region-def "all" (all)) (region-def "soma" (tag 1)) diff --git a/bluepyopt/tests/test_ephys/testdata/acc/l5pc_py37/l5pc_decor.acc b/bluepyopt/tests/test_ephys/testdata/acc/l5pc_py37/l5pc_decor.acc index 017c701f..ba168a6f 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/l5pc_py37/l5pc_decor.acc +++ b/bluepyopt/tests/test_ephys/testdata/acc/l5pc_py37/l5pc_decor.acc @@ -1,5 +1,5 @@ (arbor-component - (meta-data (version "0.1-dev")) + (meta-data (version "0.9-dev")) (decor (default (membrane-potential -65)) (default (temperature-kelvin 307.14999999999998)) diff --git a/bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_axon_replacement.acc b/bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_axon_replacement.acc index 8b8d954e..5aad006f 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_axon_replacement.acc +++ b/bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_axon_replacement.acc @@ -1,6 +1,6 @@ (arbor-component (meta-data - (version "0.1-dev")) + (version "0.9-dev")) (morphology (branch 0 -1 (segment 0 diff --git a/bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_cell_decor.acc b/bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_cell_decor.acc index e5af159c..62686463 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_cell_decor.acc +++ b/bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_cell_decor.acc @@ -1,5 +1,5 @@ (arbor-component - (meta-data (version "0.1-dev")) + (meta-data (version "0.9-dev")) (decor (paint (region "soma") (membrane-capacitance 0.01)) (paint (region "soma") (density (mechanism "default::hh" ("gnabar" 0.10299326453483033) ("gkbar" 0.027124836082684685)))))) \ No newline at end of file diff --git a/bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_cell_label_dict.acc b/bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_cell_label_dict.acc index ea26ab1a..feec6f79 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_cell_label_dict.acc +++ b/bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_cell_label_dict.acc @@ -1,5 +1,5 @@ (arbor-component - (meta-data (version "0.1-dev")) + (meta-data (version "0.9-dev")) (label-dict (region-def "all" (all)) (region-def "soma" (tag 1)) diff --git a/bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_modified.acc b/bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_modified.acc index 89a99ad3..0e29834f 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_modified.acc +++ b/bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_modified.acc @@ -1,6 +1,6 @@ (arbor-component (meta-data - (version "0.1-dev")) + (version "0.9-dev")) (morphology (branch 0 -1 (segment 0 diff --git a/bluepyopt/tests/test_ephys/testdata/acc/templates/decor_acc_template.jinja2 b/bluepyopt/tests/test_ephys/testdata/acc/templates/decor_acc_template.jinja2 index b55ca0bc..60d1dc8c 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/templates/decor_acc_template.jinja2 +++ b/bluepyopt/tests/test_ephys/testdata/acc/templates/decor_acc_template.jinja2 @@ -1,5 +1,5 @@ (arbor-component - (meta-data (version "0.1-dev")) + (meta-data (version "0.9-dev")) (meta-data (info "test-decor")) (decor {%- for mech, params in global_mechs.items() %} diff --git a/bluepyopt/tests/test_ephys/testdata/acc/templates/label_dict_acc_template.jinja2 b/bluepyopt/tests/test_ephys/testdata/acc/templates/label_dict_acc_template.jinja2 index c439b12b..e2686dc0 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/templates/label_dict_acc_template.jinja2 +++ b/bluepyopt/tests/test_ephys/testdata/acc/templates/label_dict_acc_template.jinja2 @@ -1,5 +1,5 @@ (arbor-component - (meta-data (version "0.1-dev")) + (meta-data (version "0.9-dev")) (meta-data (info "test-label-dict")) (label-dict {%- for loc, label in label_dict.items() %}{# this is a comment #} From c1befc6cb5e897d1b37586b5330db0b109908234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Tue, 20 Aug 2024 11:42:16 +0200 Subject: [PATCH 2/9] lint fix --- bluepyopt/tests/test_ephys/test_create_acc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bluepyopt/tests/test_ephys/test_create_acc.py b/bluepyopt/tests/test_ephys/test_create_acc.py index c1088596..a2d2dd37 100644 --- a/bluepyopt/tests/test_ephys/test_create_acc.py +++ b/bluepyopt/tests/test_ephys/test_create_acc.py @@ -537,7 +537,7 @@ def run_short_sim(cable_cell): arb_cell_model.properties.catalogue.extend(arbor.bbp_catalogue(), "BBP::") # Run a very short simulation to test mechanism instantiation - arb_cell_model.run(tfinal=0.1 *arbor.units.ms) + arb_cell_model.run(tfinal=0.1 * arbor.units.ms) @pytest.mark.unit From 68f315ba6899051d23da3b0b6175c11df36a35e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Tue, 20 Aug 2024 11:54:20 +0200 Subject: [PATCH 3/9] drop support for python 3.8 --- .github/workflows/test.yml | 2 +- README.rst | 2 +- setup.py | 2 +- tox.ini | 5 ++--- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7b2f9532..55559313 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12"] include: - os: macos-12 python-version: "3.10" diff --git a/README.rst b/README.rst index 8c124b2f..3ffbe544 100644 --- a/README.rst +++ b/README.rst @@ -85,7 +85,7 @@ News Requirements ============ -* `Python 3.8+ `_ +* `Python 3.9+ `_ * `Pip `_ (installed by default in newer versions of Python) * `Neuron 7.4+ `_ (compiled with Python support) * `eFEL eFeature Extraction Library `_ (automatically installed by pip) diff --git a/setup.py b/setup.py index ad957baf..f90ce2fb 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,7 @@ ] EXTRA_ARBOR = [ - 'arbor>=0.7', + 'arbor>=0.10', ] setuptools.setup( diff --git a/tox.ini b/tox.ini index b135d453..60af05f4 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,6 @@ minversion = 4 [gh-actions] python = - 3.8: py3 3.9: py3 3.10: py3 3.11: py3 @@ -12,7 +11,7 @@ python = [testenv] envdir = - py3{8,9,10,11,}{-unit,-functional,-style,-syntax}: {toxworkdir}/py3 + py3{9,10,11,12,}{-unit,-functional,-style,-syntax}: {toxworkdir}/py3 docs: {toxworkdir}/docs extras = tests deps = @@ -46,7 +45,7 @@ commands = functional: pytest --cov=bluepyopt {[testenv]coverage_options} bluepyopt/tests -m neuroml [testenv:docs] -basepython = python3.8 +basepython = python3.9 changedir = docs deps = sphinx From f400cbbe0c44806d06f6b35362f7ffe4861e6105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Tue, 20 Aug 2024 15:16:31 +0200 Subject: [PATCH 4/9] fix arbor-related functional tests --- bluepyopt/ephys/protocols.py | 13 +++++++--- bluepyopt/ephys/simulators.py | 6 +++-- .../templates/acc/decor_acc_template.jinja2 | 6 ++--- .../testdata/acc/CCell/CCell_decor.acc | 10 ++++---- .../testdata/acc/expsyn/simple_cell_decor.acc | 4 ++-- .../testdata/acc/l5pc/l5pc_decor.acc | 24 +++++++++---------- .../testdata/acc/l5pc_py37/l5pc_decor.acc | 24 +++++++++---------- .../acc/simplecell/simple_cell_decor.acc | 2 +- .../acc/templates/decor_acc_template.jinja2 | 4 ++-- 9 files changed, 51 insertions(+), 42 deletions(-) diff --git a/bluepyopt/ephys/protocols.py b/bluepyopt/ephys/protocols.py index 804329f2..1b101ba6 100644 --- a/bluepyopt/ephys/protocols.py +++ b/bluepyopt/ephys/protocols.py @@ -602,7 +602,12 @@ def instantiate_iclamp_stimuli(self, decor, use_labels=False): for i, stim in enumerate(self.stimuli): if not isinstance(stim, stimuli.SynapticStimulus): if hasattr(stim, 'envelope'): - arb_iclamp = arbor.iclamp(stim.envelope()) + envelope = stim.envelope() + envelope = [ + (t * arbor.units.ms, curr * arbor.units.nA) + for (t, curr) in envelope + ] + arb_iclamp = arbor.iclamp(envelope) else: raise ValueError('Stimulus must provide envelope method ' ' or be of type NrnNetStimStimulus to be' @@ -631,7 +636,7 @@ def instantiate_recordings(self, cell_model, use_labels=False): """Instantiate recordings""" # Attach voltage probe sampling at 10 kHz (every 0.1 ms) - for i, rec in enumerate(self.recordings): + for _, rec in enumerate(self.recordings): # alternatively arbor.cable_probe_membrane_voltage arb_loc = rec.location.acc_label() if isinstance(arb_loc, list) and len(arb_loc) != 1: @@ -648,7 +653,9 @@ def instantiate_recordings(self, cell_model, use_labels=False): cell_model.probe('voltage', arb_loc.ref if use_labels else arb_loc.loc, - frequency=10) # could be a parameter + "0", # tag: default is '0' + # frequency could be a parameter + frequency=10 * arbor.units.kHz) return cell_model diff --git a/bluepyopt/ephys/simulators.py b/bluepyopt/ephys/simulators.py index de546633..a4d038ce 100644 --- a/bluepyopt/ephys/simulators.py +++ b/bluepyopt/ephys/simulators.py @@ -372,9 +372,11 @@ def run(self, arb_cell_model, tstop=None, dt=None): dt = dt if dt is not None else self.dt if dt is not None: - return arb_cell_model.run(tfinal=tstop, dt=dt) + return arb_cell_model.run( + tfinal=tstop * arbor.units.ms, dt=dt * arbor.units.ms + ) else: - return arb_cell_model.run(tfinal=tstop) + return arb_cell_model.run(tfinal=tstop * arbor.units.ms) class ArbSimulatorException(Exception): diff --git a/bluepyopt/ephys/templates/acc/decor_acc_template.jinja2 b/bluepyopt/ephys/templates/acc/decor_acc_template.jinja2 index ad2dbfe7..eac074cb 100644 --- a/bluepyopt/ephys/templates/acc/decor_acc_template.jinja2 +++ b/bluepyopt/ephys/templates/acc/decor_acc_template.jinja2 @@ -10,7 +10,7 @@ {%- endif %} {%- else %} {%- for param in params %} - (default ({{ param.name }} {{ param.value }})) + (default ({{ param.name }} {{ param.value }} (scalar 1.0))) {%- endfor %} {%- endif %} {%- endfor %} @@ -27,13 +27,13 @@ {%- endif %} {%- else %} {%- for param in params %} - (paint {{loc.ref}} ({{ param.name }} {{ param.value }})) + (paint {{loc.ref}} ({{ param.name }} {{ param.value }} (scalar 1.0))) {%- endfor %} {%- endif %} {%- endfor %} {%- for synapse_name, mech_params in pprocess_mechs[loc].items() %} - (place {{loc.ref}} (synapse (mechanism "{{ mech_params.mech }}" {%- for param in mech_params.params %} ("{{ param.name }}" {{ param.value }}){%- endfor %})) "{{ synapse_name }}") + (place {{loc.ref}} (synapse (mechanism "{{ mech_params.mech }}" {%- for param in mech_params.params %} ("{{ param.name }}" {{ param.value }} (scalar 1.0)){%- endfor %})) "{{ synapse_name }}") {%- endfor %} {%- endfor %})) diff --git a/bluepyopt/tests/test_ephys/testdata/acc/CCell/CCell_decor.acc b/bluepyopt/tests/test_ephys/testdata/acc/CCell/CCell_decor.acc index c1820f01..2427ea90 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/CCell/CCell_decor.acc +++ b/bluepyopt/tests/test_ephys/testdata/acc/CCell/CCell_decor.acc @@ -1,10 +1,10 @@ (arbor-component (meta-data (version "0.9-dev")) (decor - (default (gSKv3_1bar_SKv3_1 65)) - (paint (region "soma") (gSKv3_1bar_SKv3_1 65)) - (paint (region "soma") (gSKv3_1bar_SKv3_1 65)) + (default (gSKv3_1bar_SKv3_1 65 (scalar 1.0))) + (paint (region "soma") (gSKv3_1bar_SKv3_1 65 (scalar 1.0))) + (paint (region "soma") (gSKv3_1bar_SKv3_1 65 (scalar 1.0))) (paint (region "dend") (density (mechanism "BBP::Ih"))) - (paint (region "apic") (gSKv3_1bar_SKv3_1 65)) - (paint (region "apic") (gSKv3_1bar_SKv3_1 65)) + (paint (region "apic") (gSKv3_1bar_SKv3_1 65 (scalar 1.0))) + (paint (region "apic") (gSKv3_1bar_SKv3_1 65 (scalar 1.0))) (paint (region "apic") (density (mechanism "BBP::Ih"))))) \ No newline at end of file diff --git a/bluepyopt/tests/test_ephys/testdata/acc/expsyn/simple_cell_decor.acc b/bluepyopt/tests/test_ephys/testdata/acc/expsyn/simple_cell_decor.acc index 335b4ff1..e1ed15e0 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/expsyn/simple_cell_decor.acc +++ b/bluepyopt/tests/test_ephys/testdata/acc/expsyn/simple_cell_decor.acc @@ -1,6 +1,6 @@ (arbor-component (meta-data (version "0.9-dev")) (decor - (paint (region "soma") (membrane-capacitance 0.01)) + (paint (region "soma") (membrane-capacitance 0.01 (scalar 1.0))) (paint (region "soma") (density (mechanism "default::pas"))) - (place (locset "somacenter") (synapse (mechanism "default::expsyn" ("tau" 10))) "expsyn"))) \ No newline at end of file + (place (locset "somacenter") (synapse (mechanism "default::expsyn" ("tau" 10 (scalar 1.0)))) "expsyn"))) \ No newline at end of file diff --git a/bluepyopt/tests/test_ephys/testdata/acc/l5pc/l5pc_decor.acc b/bluepyopt/tests/test_ephys/testdata/acc/l5pc/l5pc_decor.acc index 2a7b5dfb..fb9c4e40 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/l5pc/l5pc_decor.acc +++ b/bluepyopt/tests/test_ephys/testdata/acc/l5pc/l5pc_decor.acc @@ -1,13 +1,13 @@ (arbor-component (meta-data (version "0.9-dev")) (decor - (default (membrane-potential -65)) - (default (temperature-kelvin 307.14999999999998)) - (default (membrane-capacitance 0.01)) - (default (axial-resistivity 100)) + (default (membrane-potential -65 (scalar 1.0))) + (default (temperature-kelvin 307.14999999999998 (scalar 1.0))) + (default (membrane-capacitance 0.01 (scalar 1.0))) + (default (axial-resistivity 100 (scalar 1.0))) (paint (region "all") (density (mechanism "default::pas/e=-75" ("g" 3.0000000000000001e-05)))) - (paint (region "soma") (ion-reversal-potential "na" 50)) - (paint (region "soma") (ion-reversal-potential "k" -85)) + (paint (region "soma") (ion-reversal-potential "na" 50 (scalar 1.0))) + (paint (region "soma") (ion-reversal-potential "k" -85 (scalar 1.0))) (paint (region "soma") (density (mechanism "BBP::NaTs2_t" ("gNaTs2_tbar" 0.98395500000000002)))) (paint (region "soma") (density (mechanism "BBP::SKv3_1" ("gSKv3_1bar" 0.30347200000000002)))) (paint (region "soma") (density (mechanism "BBP::SK_E2" ("gSK_E2bar" 0.0084069999999999995)))) @@ -15,8 +15,8 @@ (paint (region "soma") (density (mechanism "BBP::Ca_LVAst" ("gCa_LVAstbar" 0.00033300000000000002)))) (paint (region "soma") (density (mechanism "BBP::CaDynamics_E2" ("gamma" 0.00060899999999999995) ("decay" 210.48528400000001)))) (paint (region "soma") (density (mechanism "BBP::Ih" ("gIhbar" 8.0000000000000007e-05)))) - (paint (region "axon") (ion-reversal-potential "na" 50)) - (paint (region "axon") (ion-reversal-potential "k" -85)) + (paint (region "axon") (ion-reversal-potential "na" 50 (scalar 1.0))) + (paint (region "axon") (ion-reversal-potential "k" -85 (scalar 1.0))) (paint (region "axon") (density (mechanism "BBP::NaTa_t" ("gNaTa_tbar" 3.1379679999999999)))) (paint (region "axon") (density (mechanism "BBP::Nap_Et2" ("gNap_Et2bar" 0.0068269999999999997)))) (paint (region "axon") (density (mechanism "BBP::K_Pst" ("gK_Pstbar" 0.97353800000000001)))) @@ -26,11 +26,11 @@ (paint (region "axon") (density (mechanism "BBP::Ca_HVA" ("gCa_HVAbar" 0.00098999999999999999)))) (paint (region "axon") (density (mechanism "BBP::Ca_LVAst" ("gCa_LVAstbar" 0.0087519999999999994)))) (paint (region "axon") (density (mechanism "BBP::CaDynamics_E2" ("gamma" 0.0029099999999999998) ("decay" 287.19873100000001)))) - (paint (region "dend") (membrane-capacitance 0.02)) + (paint (region "dend") (membrane-capacitance 0.02 (scalar 1.0))) (paint (region "dend") (density (mechanism "BBP::Ih" ("gIhbar" 8.0000000000000007e-05)))) - (paint (region "apic") (ion-reversal-potential "na" 50)) - (paint (region "apic") (ion-reversal-potential "k" -85)) - (paint (region "apic") (membrane-capacitance 0.02)) + (paint (region "apic") (ion-reversal-potential "na" 50 (scalar 1.0))) + (paint (region "apic") (ion-reversal-potential "k" -85 (scalar 1.0))) + (paint (region "apic") (membrane-capacitance 0.02 (scalar 1.0))) (paint (region "apic") (density (mechanism "BBP::NaTs2_t" ("gNaTs2_tbar" 0.026145000000000002)))) (paint (region "apic") (density (mechanism "BBP::SKv3_1" ("gSKv3_1bar" 0.0042259999999999997)))) (paint (region "apic") (density (mechanism "BBP::Im" ("gImbar" 0.00014300000000000001)))) diff --git a/bluepyopt/tests/test_ephys/testdata/acc/l5pc_py37/l5pc_decor.acc b/bluepyopt/tests/test_ephys/testdata/acc/l5pc_py37/l5pc_decor.acc index ba168a6f..449a04f2 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/l5pc_py37/l5pc_decor.acc +++ b/bluepyopt/tests/test_ephys/testdata/acc/l5pc_py37/l5pc_decor.acc @@ -1,13 +1,13 @@ (arbor-component (meta-data (version "0.9-dev")) (decor - (default (membrane-potential -65)) - (default (temperature-kelvin 307.14999999999998)) - (default (membrane-capacitance 0.01)) - (default (axial-resistivity 100)) + (default (membrane-potential -65 (scalar 1.0))) + (default (temperature-kelvin 307.14999999999998 (scalar 1.0))) + (default (membrane-capacitance 0.01 (scalar 1.0))) + (default (axial-resistivity 100 (scalar 1.0))) (paint (region "all") (density (mechanism "default::pas/e=-75" ("g" 3.0000000000000001e-05)))) - (paint (region "soma") (ion-reversal-potential "na" 50)) - (paint (region "soma") (ion-reversal-potential "k" -85)) + (paint (region "soma") (ion-reversal-potential "na" 50 (scalar 1.0))) + (paint (region "soma") (ion-reversal-potential "k" -85 (scalar 1.0))) (paint (region "soma") (density (mechanism "BBP::NaTs2_t" ("gNaTs2_tbar" 0.98395500000000002)))) (paint (region "soma") (density (mechanism "BBP::SKv3_1" ("gSKv3_1bar" 0.30347200000000002)))) (paint (region "soma") (density (mechanism "BBP::SK_E2" ("gSK_E2bar" 0.0084069999999999995)))) @@ -15,8 +15,8 @@ (paint (region "soma") (density (mechanism "BBP::Ca_LVAst" ("gCa_LVAstbar" 0.00033300000000000002)))) (paint (region "soma") (density (mechanism "BBP::CaDynamics_E2" ("gamma" 0.00060899999999999995) ("decay" 210.48528400000001)))) (paint (region "soma") (density (mechanism "BBP::Ih" ("gIhbar" 8.0000000000000007e-05)))) - (paint (region "axon") (ion-reversal-potential "na" 50)) - (paint (region "axon") (ion-reversal-potential "k" -85)) + (paint (region "axon") (ion-reversal-potential "na" 50 (scalar 1.0))) + (paint (region "axon") (ion-reversal-potential "k" -85 (scalar 1.0))) (paint (region "axon") (density (mechanism "BBP::NaTa_t" ("gNaTa_tbar" 3.1379679999999999)))) (paint (region "axon") (density (mechanism "BBP::Nap_Et2" ("gNap_Et2bar" 0.0068269999999999997)))) (paint (region "axon") (density (mechanism "BBP::K_Pst" ("gK_Pstbar" 0.97353800000000001)))) @@ -26,11 +26,11 @@ (paint (region "axon") (density (mechanism "BBP::Ca_HVA" ("gCa_HVAbar" 0.00098999999999999999)))) (paint (region "axon") (density (mechanism "BBP::Ca_LVAst" ("gCa_LVAstbar" 0.0087519999999999994)))) (paint (region "axon") (density (mechanism "BBP::CaDynamics_E2" ("gamma" 0.0029099999999999998) ("decay" 287.19873100000001)))) - (paint (region "dend") (membrane-capacitance 0.02)) + (paint (region "dend") (membrane-capacitance 0.02 (scalar 1.0))) (paint (region "dend") (density (mechanism "BBP::Ih" ("gIhbar" 8.0000000000000007e-05)))) - (paint (region "apic") (ion-reversal-potential "na" 50)) - (paint (region "apic") (ion-reversal-potential "k" -85)) - (paint (region "apic") (membrane-capacitance 0.02)) + (paint (region "apic") (ion-reversal-potential "na" 50 (scalar 1.0))) + (paint (region "apic") (ion-reversal-potential "k" -85 (scalar 1.0))) + (paint (region "apic") (membrane-capacitance 0.02 (scalar 1.0))) (paint (region "apic") (density (mechanism "BBP::NaTs2_t" ("gNaTs2_tbar" 0.026145000000000002)))) (paint (region "apic") (density (mechanism "BBP::SKv3_1" ("gSKv3_1bar" 0.0042259999999999997)))) (paint (region "apic") (density (mechanism "BBP::Im" ("gImbar" 0.00014300000000000001)))) diff --git a/bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_cell_decor.acc b/bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_cell_decor.acc index 62686463..e1361030 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_cell_decor.acc +++ b/bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_cell_decor.acc @@ -1,5 +1,5 @@ (arbor-component (meta-data (version "0.9-dev")) (decor - (paint (region "soma") (membrane-capacitance 0.01)) + (paint (region "soma") (membrane-capacitance 0.01 (scalar 1.0))) (paint (region "soma") (density (mechanism "default::hh" ("gnabar" 0.10299326453483033) ("gkbar" 0.027124836082684685)))))) \ No newline at end of file diff --git a/bluepyopt/tests/test_ephys/testdata/acc/templates/decor_acc_template.jinja2 b/bluepyopt/tests/test_ephys/testdata/acc/templates/decor_acc_template.jinja2 index 60d1dc8c..4f5a33c9 100644 --- a/bluepyopt/tests/test_ephys/testdata/acc/templates/decor_acc_template.jinja2 +++ b/bluepyopt/tests/test_ephys/testdata/acc/templates/decor_acc_template.jinja2 @@ -11,7 +11,7 @@ {%- endif %} {%- else %} {%- for param in params %} - (default ({{ param.name }} {{ param.value }})) + (default ({{ param.name }} {{ param.value }} (scalar 1.0))) {%- endfor %} {%- endif %} {%- endfor %} @@ -26,7 +26,7 @@ {%- endif %} {%- else %} {%- for param in params %} - (paint {{loc.ref}} ({{ param.name }} {{ param.value }})) + (paint {{loc.ref}} ({{ param.name }} {{ param.value }} (scalar 1.0))) {%- endfor %} {%- endif %} {%- endfor %} From 86e2c145be847aa079fa9f7cafb8605c96799005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Tue, 20 Aug 2024 16:13:17 +0200 Subject: [PATCH 5/9] update codecov action version to v4 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 55559313..a0414e03 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,7 +34,7 @@ jobs: run: tox - name: "Upload coverage to Codecov" - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: false From 5ad7f4d5ebd8dfcb2d287971f175656f689491c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Wed, 21 Aug 2024 16:03:37 +0200 Subject: [PATCH 6/9] add test for load_component using iexpr --- .../tests/test_ephys/test_parameterscalers.py | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/bluepyopt/tests/test_ephys/test_parameterscalers.py b/bluepyopt/tests/test_ephys/test_parameterscalers.py index 846bf023..12202796 100644 --- a/bluepyopt/tests/test_ephys/test_parameterscalers.py +++ b/bluepyopt/tests/test_ephys/test_parameterscalers.py @@ -1,7 +1,9 @@ """Test ephys.parameterscalers""" import json - +import pathlib +import tempfile +import arbor import pytest @@ -143,3 +145,42 @@ def test_parameterscalers_iexpr_generator_unsupported_attr(): 'unsupported attribute tau.'): iexpr = value_scaler.acc_scale_iexpr( value=value, constant_formatter=lambda v: '%.9g' % v) + + +@pytest.mark.unit +def test_parameterscalers_iexpr(): + """ephys.parameterscalers: Test iexpr""" + # iexpr from bluepyopt/tests/test_ephys/test_parameterscalers.py + iexpr = '(sub (scalar 0.62109375) ' \ + '(mul (log (pi) ) ' \ + '(exp (div (distance (region "soma")) ' \ + '(scalar 0.421875) ) ) ) )' + + # modified decor as in + # bluepyopt/tests/test_ephys/testdata/acc/simplecell/simple_cell_decor.acc + simple_cell_decor_with_iexpr = \ + '(arbor-component\n' \ + ' (meta-data (version "0.9-dev"))\n' \ + ' (decor\n' \ + ' (paint (region "soma") ' \ + '(membrane-capacitance 0.01 (scalar 1.0)))\n' \ + ' (paint (region "soma") ' \ + '(scaled-mechanism (density (mechanism "default::hh" ' \ + '("gnabar" 0.10299326453483033) ("gkbar" 0.027124836082684685))) ' \ + f'("gkbar" {iexpr})))))' + + with tempfile.TemporaryDirectory() as test_dir: + decor_filename = pathlib.Path(test_dir).joinpath("decor.acc") + with open(decor_filename, "w") as f: + f.write(simple_cell_decor_with_iexpr) + test_decor = arbor.load_component(decor_filename).component + assert test_decor.defaults() == [] + assert str(test_decor.paintings()) == \ + """[('(region "soma")', Cm=0.01), """ \ + """('(region "soma")', """ \ + "(mechanism('default::hh', " \ + '{"gkbar": 0.0271248, "gnabar": 0.102993}), ' \ + '{"gkbar": (sub (scalar 0.621094) (mul (log (scalar 3.14159)) ' \ + '(exp (div (distance 1 (region "soma")) ' \ + '(scalar 0.421875)))))})>)]' + assert test_decor.placements() == [] From 5778cd5ee1e46e1288bc54c8ad0ef9bd6295e2bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Wed, 21 Aug 2024 17:30:03 +0200 Subject: [PATCH 7/9] fix iexpr test --- .../tests/test_ephys/test_parameterscalers.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/bluepyopt/tests/test_ephys/test_parameterscalers.py b/bluepyopt/tests/test_ephys/test_parameterscalers.py index 12202796..f444b48e 100644 --- a/bluepyopt/tests/test_ephys/test_parameterscalers.py +++ b/bluepyopt/tests/test_ephys/test_parameterscalers.py @@ -175,12 +175,16 @@ def test_parameterscalers_iexpr(): f.write(simple_cell_decor_with_iexpr) test_decor = arbor.load_component(decor_filename).component assert test_decor.defaults() == [] - assert str(test_decor.paintings()) == \ - """[('(region "soma")', Cm=0.01), """ \ - """('(region "soma")', """ \ - "(mechanism('default::hh', " \ - '{"gkbar": 0.0271248, "gnabar": 0.102993}), ' \ + assert test_decor.placements() == [] + assert len(test_decor.paintings()) == 2 + assert test_decor.paintings()[0][0] == '(region "soma")' + assert str(test_decor.paintings()[0][1]) == 'Cm=0.01' + assert test_decor.paintings()[1][0] == '(region "soma")' + scaled_mech_str = " " \ + "(mechanism('default::hh', %s), " \ '{"gkbar": (sub (scalar 0.621094) (mul (log (scalar 3.14159)) ' \ '(exp (div (distance 1 (region "soma")) ' \ - '(scalar 0.421875)))))})>)]' - assert test_decor.placements() == [] + '(scalar 0.421875)))))})>' + str1 = scaled_mech_str % '{"gkbar": 0.0271248, "gnabar": 0.102993}' + str2 = scaled_mech_str % '{"gnabar": 0.102993, "gkbar": 0.0271248}' + assert str(test_decor.paintings()[1][1]) in [str1, str2] From f9ac053737026830c290b69c87a7f2f191fbd18a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Thu, 22 Aug 2024 09:47:57 +0200 Subject: [PATCH 8/9] arbor-related code improvement --- bluepyopt/ephys/morphologies.py | 2 +- bluepyopt/ephys/protocols.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bluepyopt/ephys/morphologies.py b/bluepyopt/ephys/morphologies.py index 9acd7dda..27cbc1ec 100644 --- a/bluepyopt/ephys/morphologies.py +++ b/bluepyopt/ephys/morphologies.py @@ -308,7 +308,7 @@ def load(morpho_filename, replace_axon): elif morpho_suffix == '.swc': morpho = arbor.load_swc_arbor(morpho_filename) # turn loaded_morphology into morphology type - morpho = arbor.morphology(morpho.segment_tree) + morpho = morpho.morphology elif morpho_suffix == '.asc': morpho = arbor.load_asc(morpho_filename).morphology else: diff --git a/bluepyopt/ephys/protocols.py b/bluepyopt/ephys/protocols.py index 1b101ba6..aa742bca 100644 --- a/bluepyopt/ephys/protocols.py +++ b/bluepyopt/ephys/protocols.py @@ -636,7 +636,7 @@ def instantiate_recordings(self, cell_model, use_labels=False): """Instantiate recordings""" # Attach voltage probe sampling at 10 kHz (every 0.1 ms) - for _, rec in enumerate(self.recordings): + for i, rec in enumerate(self.recordings): # alternatively arbor.cable_probe_membrane_voltage arb_loc = rec.location.acc_label() if isinstance(arb_loc, list) and len(arb_loc) != 1: @@ -653,7 +653,7 @@ def instantiate_recordings(self, cell_model, use_labels=False): cell_model.probe('voltage', arb_loc.ref if use_labels else arb_loc.loc, - "0", # tag: default is '0' + f"probe-{i}", # frequency could be a parameter frequency=10 * arbor.units.kHz) From d1758bac600425369f9b73b0eb67aa9b7a4ae928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Fri, 23 Aug 2024 10:05:27 +0200 Subject: [PATCH 9/9] add load_component test --- bluepyopt/tests/test_ephys/test_create_acc.py | 4 ++++ .../tests/test_ephys/test_parameterscalers.py | 17 ++--------------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/bluepyopt/tests/test_ephys/test_create_acc.py b/bluepyopt/tests/test_ephys/test_create_acc.py index a2d2dd37..367ef22a 100644 --- a/bluepyopt/tests/test_ephys/test_create_acc.py +++ b/bluepyopt/tests/test_ephys/test_create_acc.py @@ -665,6 +665,10 @@ def check_acc_dir(test_dir, ref_dir): with open(ref_dir_file / file) as f: ref_file = f.read() assert ref_file == test_file + # check that load_component is not raising any error here + fpath = pathlib.Path(test_dir) / file + if fpath.suffix == "acc": + arbor.load_component(fpath).component @pytest.mark.unit diff --git a/bluepyopt/tests/test_ephys/test_parameterscalers.py b/bluepyopt/tests/test_ephys/test_parameterscalers.py index f444b48e..877cac90 100644 --- a/bluepyopt/tests/test_ephys/test_parameterscalers.py +++ b/bluepyopt/tests/test_ephys/test_parameterscalers.py @@ -173,18 +173,5 @@ def test_parameterscalers_iexpr(): decor_filename = pathlib.Path(test_dir).joinpath("decor.acc") with open(decor_filename, "w") as f: f.write(simple_cell_decor_with_iexpr) - test_decor = arbor.load_component(decor_filename).component - assert test_decor.defaults() == [] - assert test_decor.placements() == [] - assert len(test_decor.paintings()) == 2 - assert test_decor.paintings()[0][0] == '(region "soma")' - assert str(test_decor.paintings()[0][1]) == 'Cm=0.01' - assert test_decor.paintings()[1][0] == '(region "soma")' - scaled_mech_str = " " \ - "(mechanism('default::hh', %s), " \ - '{"gkbar": (sub (scalar 0.621094) (mul (log (scalar 3.14159)) ' \ - '(exp (div (distance 1 (region "soma")) ' \ - '(scalar 0.421875)))))})>' - str1 = scaled_mech_str % '{"gkbar": 0.0271248, "gnabar": 0.102993}' - str2 = scaled_mech_str % '{"gnabar": 0.102993, "gkbar": 0.0271248}' - assert str(test_decor.paintings()[1][1]) in [str1, str2] + # check that load_component is not raising any error here + arbor.load_component(decor_filename).component