Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaquier Aurélien Tristan committed Oct 7, 2024
1 parent f572098 commit 571f5e2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion bluepymm/prepare_combos/prepare_emodel_dirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ def create_and_write_hoc_file(emodel, emodel_dir, hoc_dir, emodel_params,
model_name: used to name the .hoc file. If None, the e-model name is
used. Default is None.
"""
setup = tools.load_module('setup', emodel_dir)
setup = tools.load_module(
'setup', os.path.join(emodel_dir, 'setup/__init__.py')
)

with open(os.devnull, 'w') as devnull:
old_stdout = sys.stdout
Expand Down
4 changes: 3 additions & 1 deletion bluepymm/run_combos/calculate_scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ def run_emodel_morph(
print('Running e-model %s on morphology %s in %s' %
(emodel, morph_path, emodel_dir))

setup = tools.load_module('setup', os.path.join(emodel_dir, 'setup/__init__.py'))
setup = tools.load_module(
'setup', os.path.join(emodel_dir, 'setup/__init__.py')
)

print("Changing path to %s" % emodel_dir)
with tools.cd(emodel_dir):
Expand Down
2 changes: 1 addition & 1 deletion bluepymm/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def check_all_combos_have_run(database, description):
def load_module(name, path):
"""Try and load module `name` but *only* in `path`
from https://docs.python.org/3.6/library/importlib.html#importing-a-source-file-directly
from https://docs.python.org/3.6/library/importlib.html
"""
# Fast path: see if the module has already been imported.
try:
Expand Down
8 changes: 6 additions & 2 deletions tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,17 @@ def test_load_module():
"""bluepymm.tools: test load_module"""
# load module
module_dir = os.path.join(EXAMPLES, 'simple1/data/emodels_dir/subdir/')
setup = tools.load_module('setup', os.path.join(module_dir, 'setup/__init__.py'))
setup = tools.load_module(
'setup', os.path.join(module_dir, 'setup/__init__.py')
)
# try and execute something from loaded module
setup.evaluator.create('emodel1')

# load as file
setup_dir = os.path.join(module_dir, 'setup')
evaluator = tools.load_module('evaluator', os.path.join(setup_dir, 'evaluator.py'))
evaluator = tools.load_module(
'evaluator', os.path.join(setup_dir, 'evaluator.py')
)
evaluator.create('emodel1')


Expand Down

0 comments on commit 571f5e2

Please sign in to comment.