Skip to content

Commit

Permalink
Some proposals (#1119)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-berchet authored May 1, 2024
1 parent 5193780 commit bd0d51a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions neurom/core/morphology.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def graft_morphology(section):
class Neurite:
"""Class representing a neurite tree."""

def __init__(self, root_node, process_subtrees=False):
def __init__(self, root_node, *, process_subtrees=False):
"""Constructor.
Args:
Expand Down Expand Up @@ -538,7 +538,7 @@ def __repr__(self):
class Morphology:
"""Class representing a simple morphology."""

def __init__(self, morphio_morph, name=None, process_subtrees=False):
def __init__(self, morphio_morph, name=None, *, process_subtrees=False):
"""Morphology constructor.
Args:
Expand Down
9 changes: 8 additions & 1 deletion neurom/core/population.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ class Population:
"""

def __init__(
self, files, name='Population', ignored_exceptions=(), cache=False, process_subtrees=False
self,
files,
name='Population',
ignored_exceptions=(),
*,
cache=False,
process_subtrees=False,
):
"""Construct a morphology population.
Expand All @@ -67,6 +73,7 @@ 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.
process_subtrees (bool): enable mixed tree processing if set to True
Notes:
symlinks in paths are not resolved.
Expand Down
14 changes: 9 additions & 5 deletions neurom/io/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def _get_file(stream, extension):
return temp_file


def load_morphology(morph, reader=None, mutable=None, process_subtrees=False):
def load_morphology(morph, reader=None, *, mutable=None, process_subtrees=False):
"""Build section trees from a morphology or a h5, swc or asc file.
Args:
Expand All @@ -132,11 +132,12 @@ def load_morphology(morph, reader=None, mutable=None, process_subtrees=False):
- a morphio mutable or immutable Morphology object
- a stream that can be put into a io.StreamIO object. In this case, the READER argument
must be passed with the corresponding file format (asc, swc and h5)
reader (str): Optional, must be provided if morphology is a stream to
specify the file format (asc, swc, h5)
mutable (bool|None): Whether to enforce mutability. If None and a morphio/neurom object is
passed, the initial mutability will be maintained. If None and the
morphology is loaded, then it will be immutable by default.
reader (str): Optional, must be provided if morphology is a stream to
specify the file format (asc, swc, h5)
process_subtrees (bool): enable mixed tree processing if set to True
Returns:
A Morphology object
Expand Down Expand Up @@ -181,7 +182,7 @@ def load_morphology(morph, reader=None, mutable=None, process_subtrees=False):


def load_morphologies(
morphs, name=None, ignored_exceptions=(), cache=False, process_subtrees=False
morphs, name=None, ignored_exceptions=(), *, cache=False, process_subtrees=False
):
"""Create a population object.
Expand All @@ -195,6 +196,7 @@ 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
process_subtrees (bool): enable mixed tree processing if set to True
Returns:
Population: population object
Expand All @@ -205,4 +207,6 @@ def load_morphologies(
else:
files = morphs
name = name or 'Population'
return Population(files, name, ignored_exceptions, cache, process_subtrees=process_subtrees)
return Population(
files, name, ignored_exceptions, cache=cache, process_subtrees=process_subtrees
)

0 comments on commit bd0d51a

Please sign in to comment.