This repository was archived by the owner on Feb 26, 2025. It is now read-only.
This repository was archived by the owner on Feb 26, 2025. It is now read-only.
Mutable morphology copy constructor reindexes sections #416
Open
Description
import morphio
string = """
("CellBody"
(Color Red)
(CellBody)
( 0.1 0.1 0.0 0.1)
( 0.1 -0.1 0.0 0.1)
)
( (Color Cyan)
(Axon)
(0.0 0.0 0.0 2.0) ; section 0
(0.0 -4.0 1.0 2.0)
(
(0.0 -4.0 1.0 4.0) ; section 1
(0.0 -4.0 2.0 4.0)
(0.0 -4.0 3.0 4.0)
(
(6.0 -4.0 0.0 4.0) ; section 2
(7.0 -5.0 0.0 4.0)
(
(8.0 -4.0 0.0 4.0) ; section 3
(8.0 -5.0 0.0 4.0)
|
(8.0 -4.0 0.0 4.0) ; section 4
(8.0 -5.0 0.0 4.0)
)
|
(6.0 -4.0 0.0 4.0) ; section 5
(8.0 -4.0 0.0 4.0)
)
|
( 0.0 -4.0 1.0 4.0) ; section 6
(-5.0 -4.0 0.0 4.0)
(
(3.0 2.0 1.0 4.0) ; section 7
(3.0 2.0 0.0 4.0)
|
(2.0 3.0 1.0 4.0) ; section 8
(2.0 3.0 0.0 4.0)
)
)
)
"""
morph = morphio.Morphology(string, "asc").as_mutable()
morph.delete_section(morph.section(0), recursive=False)
morph.delete_section(morph.section(1), recursive=False)
morph.delete_section(morph.section(4), recursive=False)
morph.delete_section(morph.section(7), recursive=False)
expected_section_ids = [s.id for s in morph.iter()]
morph2 = morphio.mut.Morphology(morph)
section_ids = [s.id for s in morph2.iter()]
assert section_ids == expected_section_ids, f"{section_ids}, {expected_section_ids}"
Throws:
AssertionError: [0, 1, 2, 3, 4], [2, 3, 5, 6, 8]
Metadata
Metadata
Assignees
Labels
No labels