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

reloading neuron mechanisms in _load_hoc_and_mod_files #133

Closed
wants to merge 2 commits into from
Closed
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
1 change: 1 addition & 0 deletions bluecellulab/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def print_header(neuron: ModuleType, mod_lib_path: str) -> None:
@run_once
def _load_hoc_and_mod_files() -> None:
"""Import hoc and mod files."""
neuron.load_mechanisms(".")
logger.info("Loading the mod files.")
mod_lib_paths = import_mod_lib(neuron)
logger.info("Loading the hoc files.")
Expand Down
18 changes: 18 additions & 0 deletions tests/test_import_directory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""This test file is to ensure mechanisms are loaded where Cell is created."""
import os
from pathlib import Path


def test_import_vs_first_call_neuron_mechanisms_dir():
"""Test if the neuron import directory is set at import or at the first call."""
os.chdir("tests") # there are no mechanisms here

# intentionally imported in the directory without compiled mechanisms
from bluecellulab import Cell # noqa: E402

examples_dir = Path(__file__).resolve().parent / "examples"

os.chdir("..") # mechanisms at .. should be loaded
hoc_path = examples_dir / "bpo_cell" / "0_cADpyr_L5TPC_a6e707a_1_sNone.hoc"
morph_path = examples_dir / "bpo_cell" / "C060114A5.asc"
_ = Cell(hoc_path, morph_path, template_format="bluepyopt")
Loading