Skip to content

Commit

Permalink
Remove mutability from Population
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-berchet committed Apr 25, 2024
1 parent f6a01ef commit 0c31119
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
17 changes: 2 additions & 15 deletions neurom/core/population.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Population:
"""

def __init__(
self, files, name='Population', ignored_exceptions=(), cache=False, mutable=None, process_subtrees=False
self, files, name='Population', ignored_exceptions=(), cache=False, process_subtrees=False
):
"""Construct a morphology population.
Expand All @@ -67,8 +67,6 @@ def __init__(
will be loaded everytime it is accessed within the population. Which is good when
population is big. If true then all morphs will be loaded upon the construction
and kept in memory.
mutable (bool): Can force mutability/immutability by setting it to True or False, while
None uses the default behavior.
process_subtrees (bool): enable mixed tree processing if set to True
Notes:
Expand All @@ -79,7 +77,6 @@ def __init__(

self._files = _resolve_if_morphology_paths(files)

self._mutable = mutable
self._process_subtrees = process_subtrees

if cache:
Expand All @@ -89,16 +86,6 @@ def _reset_cache(self):
"""Reset the internal cache."""
self._files = [self._load_file(f) for f in self._files if f is not None]

@property
def mutable(self):
"""The mutability status of the morphologies."""
return self._mutable

@mutable.setter
def mutable(self, value):
self._mutable = value
self._reset_cache()

@property
def process_subtrees(self):
"""Enable mixed tree processing if set to True."""
Expand Down Expand Up @@ -130,7 +117,7 @@ def _load_file(self, f):
new_morph.process_subtrees = self.process_subtrees
return new_morph
try:
return neurom.load_morphology(f, mutable=self.mutable, process_subtrees=self.process_subtrees)
return neurom.load_morphology(f, process_subtrees=self.process_subtrees)
except (NeuroMError, MorphioError) as e:
if isinstance(e, self._ignored_exceptions):
L.info('Ignoring exception "%s" for file %s', e, f.name)
Expand Down
6 changes: 2 additions & 4 deletions neurom/io/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def load_morphology(morph, reader=None, *, mutable=None, process_subtrees=False)


def load_morphologies(
morphs, name=None, ignored_exceptions=(), cache=False, mutable=None, process_subtrees=False
morphs, name=None, ignored_exceptions=(), cache=False, process_subtrees=False
):
"""Create a population object.
Expand All @@ -196,8 +196,6 @@ def load_morphologies(
ignored_exceptions (tuple): NeuroM and MorphIO exceptions that you want to ignore when
loading morphologies
cache (bool): whether to cache the loaded morphologies in memory
mutable (bool): Can force mutability/immutability by setting it to True or False, while
None uses the default behavior.
process_subtrees (bool): enable mixed tree processing if set to True
Returns:
Expand All @@ -209,4 +207,4 @@ def load_morphologies(
else:
files = morphs
name = name or 'Population'
return Population(files, name, ignored_exceptions, cache, mutable=mutable, process_subtrees=process_subtrees)
return Population(files, name, ignored_exceptions, cache, process_subtrees=process_subtrees)

0 comments on commit 0c31119

Please sign in to comment.