Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

work around libsonata refactor #254

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion tests/test_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ 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")
15 changes: 12 additions & 3 deletions tests/test_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import libsonata
import pytest
from libsonata import SonataError

import bluepysnap.simulation as test_module
from bluepysnap.exceptions import BluepySnapError
Expand All @@ -20,6 +19,15 @@

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
Expand All @@ -40,7 +48,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
Expand All @@ -51,7 +60,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

Expand Down
9 changes: 8 additions & 1 deletion tests/test_spike_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@

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):
Expand All @@ -34,7 +41,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"
Expand Down
Loading