• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

BlueBrain / MorphIO / 11254817533

09 Oct 2024 12:20PM UTC coverage: 77.697% (+0.08%) from 77.615%
11254817533

Pull #476

github

mgeplf
Merge remote-tracking branch 'origin/master' into efficient-swc-build
Pull Request #476: Efficient swc build

286 of 321 new or added lines in 10 files covered. (89.1%)

9 existing lines in 4 files now uncovered.

2125 of 2735 relevant lines covered (77.7%)

901.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.93
/src/mut/writer_utils.cpp
1
/* Copyright (c) 2013-2023, EPFL/Blue Brain Project
2
 *
3
 * SPDX-License-Identifier: Apache-2.0
4
 */
5
#include <morphio/errorMessages.h>
6

7
#include "../error_message_generation.h"
8
#include "morphio/warning_handling.h"
9
#include "writer_utils.h"
10

11
namespace morphio {
12
namespace mut {
13
namespace writer {
14
namespace details {
15

16
using morphio::details::ErrorMessages;
17

18
void checkSomaHasSameNumberPointsDiameters(const Soma& soma) {
18✔
19
    const size_t n_points = soma.points().size();
18✔
20
    const size_t n_diameters = soma.diameters().size();
18✔
21

22
    if (n_points != n_diameters) {
18✔
23
        throw morphio::WriterError(ErrorMessages().ERROR_VECTOR_LENGTH_MISMATCH(
4✔
24
            "soma points", n_points, "soma diameters", n_diameters));
6✔
25
    }
26
}
16✔
27

28
bool hasPerimeterData(const morphio::mut::Morphology& morph) {
24✔
29
    return !morph.rootSections().empty() && !morph.rootSections().front()->perimeters().empty();
24✔
30
}
31

32
std::string version_string() {
16✔
33
    return std::string("Created by MorphIO v") + getVersionString();
32✔
34
}
35

36
bool emptyMorphology(const morphio::mut::Morphology& morph,
24✔
37
                     std::shared_ptr<morphio::WarningHandler> handler) {
38
    if (morph.soma()->points().empty() && morph.rootSections().empty()) {
24✔
39
        handler->emit(std::make_shared<morphio::WriteEmptyMorphology>());
2✔
40
        return true;
2✔
41
    }
42
    return false;
22✔
43
}
44

45
void validateContourSoma(const morphio::mut::Morphology& morph,
4✔
46
                         std::shared_ptr<morphio::WarningHandler> handler) {
47
    const std::shared_ptr<Soma>& soma = morph.soma();
4✔
48
    const std::vector<Point>& somaPoints = soma->points();
4✔
49

50
    if (somaPoints.empty()) {
4✔
51
        handler->emit(std::make_shared<morphio::WriteNoSoma>());
×
52
    } else if (soma->type() == SOMA_UNDEFINED) {
4✔
53
        handler->emit(std::make_shared<morphio::WriteUndefinedSoma>());
×
54
    } else if (soma->type() != SomaType::SOMA_SIMPLE_CONTOUR) {
4✔
55
        handler->emit(std::make_shared<morphio::SomaNonContour>());
×
56
    } else if (somaPoints.size() < 3) {
4✔
57
        throw WriterError(ErrorMessages().ERROR_SOMA_INVALID_CONTOUR());
×
58
    }
59
}
4✔
60

61
void validateHasNoPerimeterData(const morphio::mut::Morphology& morph) {
14✔
62
    if (details::hasPerimeterData(morph)) {
14✔
63
        throw WriterError(ErrorMessages().ERROR_PERIMETER_DATA_NOT_WRITABLE());
×
64
    }
65
}
14✔
66

67
void validateHasNoMitochondria(const morphio::mut::Morphology& morph,
14✔
68
                               std::shared_ptr<morphio::WarningHandler> handler) {
69
    if (!morph.mitochondria().rootSections().empty()) {
14✔
70
        handler->emit(std::make_shared<morphio::MitochondriaWriteNotSupported>());
×
71
    }
72
}
14✔
73

74
void validateRootPointsHaveTwoOrMorePoints(const morphio::mut::Morphology& morph) {
4✔
75
    for (const auto& root : morph.rootSections()) {
12✔
76
        if (root->points().size() < 2) {
8✔
NEW
77
            throw morphio::RawDataError("Root sections must have at least 2 points");
×
78
        }
79
    }
80

81
}
4✔
82

83
}  // namespace details
84
}  // namespace writer
85
}  // namespace mut
86
}  // namespace morphio
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc