Skip to content

Commit

Permalink
add chunked test
Browse files Browse the repository at this point in the history
  • Loading branch information
Helveg committed Feb 8, 2024
1 parent 0a6102b commit c19503d
Showing 1 changed file with 33 additions and 35 deletions.
68 changes: 33 additions & 35 deletions tests/test_neuron.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
import importlib
from copy import copy

import numpy as np
import unittest

from arborize import define_model
from bsb.simulation import get_simulation_adapter
from scipy.signal import find_peaks
from arborize import Schematic, define_model
from bsb_test import (
ConfigFixture,
MorphologiesFixture,
NetworkFixture,
RandomStorageFixture,
)

from bsb.config import from_file
from bsb.core import Scaffold
from bsb_test import get_config_path, RandomStorageFixture
from bsb_neuron.cell import ArborizedModel
from bsb_neuron.connection import TransceiverModel


def neuron_installed():
Expand Down Expand Up @@ -49,12 +46,9 @@ def test_minimal(self):
def test_double_sim_minimal(self):
from neuron import h

config = from_file(min_nrn_config)
scaffold = Scaffold(config, self.storage)
scaffold.compile()
sim = scaffold.simulations.test
scaffold = Scaffold(copy(config), self.storage)
sim2 = scaffold.simulations.test
scaffold_copy = Scaffold(copy(self.cfg), self.storage)
sim = self.network.simulations.test
sim2 = scaffold_copy.simulations.test
sim2.duration *= 2
adapter = get_simulation_adapter(sim.simulator)
adapter.simulate(sim, sim2)
Expand All @@ -69,39 +63,43 @@ class TestNeuronMultichunk(
NetworkFixture,
MorphologiesFixture,
unittest.TestCase,
config="neuron_minimal",
config="chunked",
morpho_filters=["2comp"],
engine_name="hdf5",
):
def setUp(self):
super().setUp()
self.cfg.cell_types.add("A", {"spatial": {"count": 10}})
for ct in self.network.cell_types.values():
ct.spatial.morphologies = ["2comp"]
hh_soma = {
"cable_types": {
"soma": {
"cable": {"Ra": 10, "cm": 1},
"mechanisms": {"pas": {}, "hh": {}},
}
}
}
self.network.simulations.add(
"test",
simulator="neuron",
duration=1000,
resolution=0.1,
temperature=32,
cell_models=dict(
A=ArborizedModel(model=hh_soma),
B=ArborizedModel(model=hh_soma),
C=ArborizedModel(model=hh_soma),
),
connection_models=dict(
A_to_B=TransceiverModel(synapses=[dict(synapse="ExpSyn")])
),
devices=dict(),
)
self.network.compile()

def test_minimal(self):
from neuron import h

sim = self.network.simulations.test
self.network.run_simulation("test")
self.assertAlmostEqual(h.t, sim.duration, msg="sim duration incorrect")

def test_4ch_all_to_all(self):
"""
Tests runnability of the NEURON adapter with 4 chunks filled with 100 single
compartment HH cells and ExpSyn synapses connected all to all
"""
hh_soma = define_model(
{
"cable_types": {
"soma": {
"cable": {"Ra": 10, "cm": 1},
"mechanisms": {"pas": {}, "hh": {}},
}
}
}
)
schematic = Schematic("single_comp")
schematic.create_location((0, 0), (0, 0, 0), 1, ["soma"])
schematic.create_location((0, 1), (100, 0, 0), 1, ["soma"])
schematic.definition = hh_soma
ArborizedModel(model=hh_soma)
self.network.run_simulation("test")

0 comments on commit c19503d

Please sign in to comment.