This repository was archived by the owner on Feb 26, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
load_morphology(path).sections throws error #1097
Copy link
Copy link
Open
Description
path = "tests/data/valid_set/Neuron.swc"
# this works as expected
m = load_morphology(path)
m.sections[0]
# these work as expected
load_morphology(path).points
load_morphology(path).neurites
load_morphology(path).soma.center
load_morphology(path).section(0)
# this fails
load_morphology(path).sections
Out[16]: ---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/Projects/BBP/NEUROM/venv310/lib/python3.10/site-packages/IPython/core/formatters.py:707, in PlainTextFormatter.__call__(self, obj)
700 stream = StringIO()
701 printer = pretty.RepresentationPrinter(stream, self.verbose,
702 self.max_width, self.newline,
703 max_seq_length=self.max_seq_length,
704 singleton_pprinters=self.singleton_printers,
705 type_pprinters=self.type_printers,
706 deferred_pprinters=self.deferred_printers)
--> 707 printer.pretty(obj)
708 printer.flush()
709 return stream.getvalue()
File ~/Projects/BBP/NEUROM/venv310/lib/python3.10/site-packages/IPython/lib/pretty.py:410, in RepresentationPrinter.pretty(self, obj)
407 return meth(obj, self, cycle)
408 if cls is not object \
409 and callable(cls.__dict__.get('__repr__')):
--> 410 return _repr_pprint(obj, self, cycle)
412 return _default_pprint(obj, self, cycle)
413 finally:
File ~/Projects/BBP/NEUROM/venv310/lib/python3.10/site-packages/IPython/lib/pretty.py:778, in _repr_pprint(obj, p, cycle)
776 """A pprint that just redirects to the normal repr function."""
777 # Find newlines and replace them with p.break_()
--> 778 output = repr(obj)
779 lines = output.splitlines()
780 with p.group():
File ~/Projects/BBP/NEUROM/NeuroM/neurom/core/morphology.py:199, in Section.__repr__(self)
197 def __repr__(self):
198 """Text representation."""
--> 199 parent_id = None if self.parent is None else self.parent.id
200 return (f'Section(id={self.id}, type={self.type}, n_points={len(self.points)})'
201 f'<parent: Section(id={parent_id}), nchildren: {len(self.children)}>')
File ~/Projects/BBP/NEUROM/NeuroM/neurom/core/morphology.py:59, in Section.parent(self)
56 @property
57 def parent(self):
58 """Returns the parent section if non root section else None."""
---> 59 if self.morphio_section.is_root:
60 return None
61 return Section(self.morphio_section.parent)
RuntimeError: Section does not belong to a morphology, impossible operationMetadata
Metadata
Assignees
Labels
No labels