Skip to content

Commit

Permalink
Fix annototations not being copied in morphio.mut.Morphology ctor (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoit Coste authored Jun 27, 2019
1 parent 2731ea7 commit a32173b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/mut/morphology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Morphology::Morphology(const morphio::Morphology& morphology, unsigned int optio
_cellProperties = std::make_shared<morphio::Property::CellLevel>(
morphology._properties->_cellLevel);

_annotations = morphology.annotations();
for (const morphio::Section& root : morphology.rootSections()) {
appendRootSection(root, true);
}
Expand Down
24 changes: 23 additions & 1 deletion tests/test_5_mut.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
from numpy.testing import assert_array_equal
from nose.tools import assert_equal, assert_raises, ok_, assert_not_equal

import morphio
from morphio.mut import Morphology, Soma
from morphio import ostream_redirect, MitochondriaPointLevel, PointLevel, SectionType, MorphioError, SectionBuilderError, Morphology as ImmutableMorphology, upstream, depth_first, breadth_first, diff
from contextlib import contextmanager
import sys
from io import StringIO
from utils import assert_substring, captured_output
from utils import assert_substring, captured_output, tmp_asc_file

_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data")

Expand Down Expand Up @@ -426,3 +427,24 @@ def test_non_C_nparray():
non_standard_stride = np.asfortranarray(points)
section.points = non_standard_stride
assert_array_equal(section.points, points)

def test_annotation():
with captured_output() as (_, err):
with ostream_redirect(stdout=True, stderr=True):
with tmp_asc_file('''((Dendrite)
(3 -4 0 2)
(3 -6 0 2)
(3 -8 0 2)
(3 -10 0 2)
(
(3 -10 0 2)
(0 -10 0 2)
(-3 -10 0 2)
| ; <-- empty sibling but still works !
)
)
''') as tmp_file:
n = Morphology(tmp_file.name)
assert_equal(len(n.annotations), 1)
annotation = n.annotations[0]
assert_equal(annotation.type, morphio.AnnotationType.single_child)

0 comments on commit a32173b

Please sign in to comment.