diff --git a/bluepysnap/morph.py b/bluepysnap/morph.py index 4a690633..0f200c90 100644 --- a/bluepysnap/morph.py +++ b/bluepysnap/morph.py @@ -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: @@ -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`. diff --git a/tests/test_morph.py b/tests/test_morph.py index bf222338..5ede964e 100644 --- a/tests/test_morph.py +++ b/tests/test_morph.py @@ -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" @@ -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(