From ba348da82f1c3e384f6291f4581f7fc8d3954d1d Mon Sep 17 00:00:00 2001 From: Mike Gevaert Date: Thu, 1 Feb 2024 14:35:10 +0100 Subject: [PATCH 1/2] work around libsonata refactor * see https://github.com/BlueBrain/libsonata/pull/345 --- tests/test_input.py | 9 ++++++++- tests/test_simulation.py | 14 +++++++++++--- tests/test_spike_report.py | 8 +++++++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/tests/test_input.py b/tests/test_input.py index 67104770..ad923cca 100644 --- a/tests/test_input.py +++ b/tests/test_input.py @@ -40,7 +40,14 @@ def test_get_simulation_inputs(): assert inputs.keys() == {"spikes_1", "current_clamp_1"} assert isinstance(inputs["spikes_1"], test_module.SynapseReplay) - assert isinstance(inputs["current_clamp_1"], libsonata._libsonata.Linear) + + try: + Linear = libsonata._libsonata.Linear + except AttributeError: + from libsonata._libsonata import SimulationConfig + Linear = SimulationConfig.Linear + + assert isinstance(inputs["current_clamp_1"], Linear) with pytest.raises(BluepySnapError, match="Unexpected type for 'simulation': str"): test_module.get_simulation_inputs("fail_me") diff --git a/tests/test_simulation.py b/tests/test_simulation.py index 56a2bf99..4f48554d 100644 --- a/tests/test_simulation.py +++ b/tests/test_simulation.py @@ -5,7 +5,6 @@ import libsonata import pytest -from libsonata import SonataError import bluepysnap.simulation as test_module from bluepysnap.exceptions import BluepySnapError @@ -20,6 +19,14 @@ from utils import PICKLED_SIZE_ADJUSTMENT, TEST_DATA_DIR, copy_test_data, edit_config +try: + Run = libsonata._libsonata.Run + Conditions = libsonata._libsonata.Conditions +except AttributeError: + from libsonata._libsonata import SimulationConfig + Run = SimulationConfig.Run + Conditions = SimulationConfig.Conditions + def test__warn_on_overwritten_node_sets(): # No warnings if no overwritten @@ -40,7 +47,8 @@ def test_all(): assert set(simulation.circuit.nodes) == {"default", "default2"} assert set(simulation.circuit.edges) == {"default", "default2"} - assert isinstance(simulation.run, libsonata._libsonata.Run) + assert isinstance(simulation.run, Run) + assert simulation.run.tstop == 1000.0 assert simulation.run.dt == 0.01 assert simulation.run.spike_threshold == -15 @@ -51,7 +59,7 @@ def test_all(): assert simulation.time_units == "ms" assert simulation.simulator == "CORENEURON" - assert isinstance(simulation.conditions, libsonata._libsonata.Conditions) + assert isinstance(simulation.conditions, Conditions) assert simulation.conditions.celsius == 34.0 assert simulation.conditions.v_init == -80 diff --git a/tests/test_spike_report.py b/tests/test_spike_report.py index c97c5f09..0cab43fd 100644 --- a/tests/test_spike_report.py +++ b/tests/test_spike_report.py @@ -17,6 +17,12 @@ from utils import TEST_DATA_DIR, copy_test_data, edit_config +try: + Output = libsonata._libsonata.Output +except AttributeError: + from libsonata._libsonata import SimulationConfig + Output = SimulationConfig.Output + def _create_series(node_ids, index, name="ids"): def _get_index(ids): @@ -34,7 +40,7 @@ def setup_method(self): self.test_obj = test_module.SpikeReport(self.simulation) def test_config(self): - assert isinstance(self.test_obj.config, libsonata._libsonata.Output) + assert isinstance(self.test_obj.config, Output) assert self.test_obj.config.output_dir == str(TEST_DATA_DIR / "reporting") assert self.test_obj.config.log_file == "log_spikes.log" assert self.test_obj.config.spikes_file == "spikes.h5" From 67b7d3aa46749df1cbabf3f142439406cd4c8c52 Mon Sep 17 00:00:00 2001 From: Mike Gevaert Date: Fri, 2 Feb 2024 13:49:54 +0100 Subject: [PATCH 2/2] format --- tests/test_input.py | 1 + tests/test_simulation.py | 1 + tests/test_spike_report.py | 1 + 3 files changed, 3 insertions(+) diff --git a/tests/test_input.py b/tests/test_input.py index ad923cca..342e1ffd 100644 --- a/tests/test_input.py +++ b/tests/test_input.py @@ -45,6 +45,7 @@ def test_get_simulation_inputs(): Linear = libsonata._libsonata.Linear except AttributeError: from libsonata._libsonata import SimulationConfig + Linear = SimulationConfig.Linear assert isinstance(inputs["current_clamp_1"], Linear) diff --git a/tests/test_simulation.py b/tests/test_simulation.py index 4f48554d..90a3fa99 100644 --- a/tests/test_simulation.py +++ b/tests/test_simulation.py @@ -24,6 +24,7 @@ Conditions = libsonata._libsonata.Conditions except AttributeError: from libsonata._libsonata import SimulationConfig + Run = SimulationConfig.Run Conditions = SimulationConfig.Conditions diff --git a/tests/test_spike_report.py b/tests/test_spike_report.py index 0cab43fd..5b59e7c1 100644 --- a/tests/test_spike_report.py +++ b/tests/test_spike_report.py @@ -21,6 +21,7 @@ Output = libsonata._libsonata.Output except AttributeError: from libsonata._libsonata import SimulationConfig + Output = SimulationConfig.Output