Skip to content

Commit

Permalink
Change getting morph directory public (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
joni-herttuainen authored Feb 14, 2024
1 parent 0a12630 commit 4a64964
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions bluepysnap/morph.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, morph_dir, population, alternate_morphologies=None):
self._alternate_morphologies = alternate_morphologies or {}
self._population = population

def _get_morph_dir(self, extension):
def get_morphology_dir(self, extension):
"""Return morphology directory based on a given extension."""
if extension == "swc":
if not self._morph_dir:
Expand Down Expand Up @@ -79,7 +79,7 @@ def get_filepath(self, node_id, extension="swc"):
raise BluepySnapError("node_id must be a int or a CircuitNodeId")
name = self._population.get(node_id, Node.MORPHOLOGY)

return Path(self._get_morph_dir(extension), f"{name}.{extension}")
return Path(self.get_morphology_dir(extension), f"{name}.{extension}")

def get(self, node_id, transform=False, extension="swc"):
"""Return MorphIO morphology object corresponding to `node_id`.
Expand Down
19 changes: 11 additions & 8 deletions tests/test_morph.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ def test_biophysical_in_library(self):
circuit = Circuit(str(config_copy_path))
assert isinstance(circuit.nodes["default"].morph, test_module.MorphHelper)

def test_get_morphology_dir(self):
with pytest.raises(
BluepySnapError, match="'neurolucida-asc' is not defined in 'alternate_morphologies'"
):
self.test_obj.get_morphology_dir("asc")

with pytest.raises(BluepySnapError, match="Unsupported extension: fake"):
self.test_obj.get_morphology_dir("fake")

assert self.test_obj.get_morphology_dir("swc") == str(TEST_DATA_DIR / "morphologies")

def test_get_filepath(self):
node_id = 0
assert self.nodes.get(node_id, properties="morphology") == "morph-A"
Expand Down Expand Up @@ -75,14 +86,6 @@ def test_get_filepath(self):
with pytest.raises(BluepySnapError, match="node_id must be a int or a CircuitNodeId"):
self.test_obj.get_filepath([0, 1])

with pytest.raises(
BluepySnapError, match="'neurolucida-asc' is not defined in 'alternate_morphologies'"
):
self.test_obj.get_filepath(0, "asc")

with pytest.raises(BluepySnapError, match="Unsupported extension: fake"):
self.test_obj.get_filepath(0, "fake")

def test_alternate_morphology(self):
alternate_morphs = {"h5v1": str(self.morph_path)}
test_obj = test_module.MorphHelper(
Expand Down

0 comments on commit 4a64964

Please sign in to comment.