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

BlueBrain / MorphIO / 11255477262

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

Pull #476

github

mgeplf
comments
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

92.71
/src/properties.cpp
1
/* Copyright (c) 2013-2023, EPFL/Blue Brain Project
2
 *
3
 * SPDX-License-Identifier: Apache-2.0
4
 */
5

6
#include <morphio/errorMessages.h>
7
#include <morphio/properties.h>
8
#include <morphio/vector_types.h>
9

10
#include "point_utils.h"
11
#include "shared_utils.hpp"
12

13
namespace {
14

15
bool compare_section_structure(const std::vector<morphio::Property::Section::Type>& vec1,
16✔
16
                               const std::vector<morphio::Property::Section::Type>& vec2) {
17
    if (vec1.size() != vec2.size()) {
16✔
18
        return false;
12✔
19
    }
20

21
    for (unsigned int i = 1; i < vec1.size(); ++i) {
16✔
22
        if (vec1[i][0] - vec1[1][0] != vec2[i][0] - vec2[1][0] || vec1[i][1] != vec2[i][1]) {
12✔
23
            return false;
×
24
        }
25
    }
26

27
    return true;
4✔
28
}
29

30
}  // namespace
31

32

33
namespace morphio {
34
namespace Property {
35

36
PointLevel::PointLevel(std::vector<Point::Type> points,
2,258✔
37
                       std::vector<Diameter::Type> diameters,
38
                       std::vector<Perimeter::Type> perimeters)
2,258✔
39
    : _points(std::move(points))
2,258✔
40
    , _diameters(std::move(diameters))
2,258✔
41
    , _perimeters(std::move(perimeters)) {
2,276✔
42
    if (_points.size() != _diameters.size()) {
2,258✔
43
        throw SectionBuilderError(
44
            "Point vector have size: " + std::to_string(_points.size()) +
8✔
45
            " while Diameter vector has size: " + std::to_string(_diameters.size()));
12✔
46
    }
47

48
    if (!_perimeters.empty() && _points.size() != _perimeters.size()) {
2,254✔
49
        throw SectionBuilderError(
50
            "Point vector have size: " + std::to_string(_points.size()) +
4✔
51
            " while Perimeter vector has size: " + std::to_string(_perimeters.size()));
6✔
52
    }
53
}
2,252✔
54

55
PointLevel::PointLevel(const PointLevel& data)
2,246✔
56
    : PointLevel(data._points, data._diameters, data._perimeters) {}
2,246✔
57

58
PointLevel::PointLevel(const PointLevel& data, SectionRange range) {
300✔
59
    _points = copySpan<Property::Point>(data._points, range);
300✔
60
    _diameters = copySpan<Property::Diameter>(data._diameters, range);
300✔
61
    _perimeters = copySpan<Property::Perimeter>(data._perimeters, range);
300✔
62
}
300✔
63

64
PointLevel& PointLevel::operator=(const PointLevel& other) {
58✔
65
    if (&other == this) {
58✔
66
        return *this;
×
67
    }
68

69
    _points = other._points;
58✔
70
    _diameters = other._diameters;
58✔
71
    _perimeters = other._perimeters;
58✔
72

73
    return *this;
58✔
74
}
75

76
bool SectionLevel::diff(const SectionLevel& other) const {
10✔
77
    return !(this == &other || (compare_section_structure(_sections, other._sections) &&
14✔
78
                                morphio::property::compare(_sectionTypes, other._sectionTypes) &&
4✔
79
                                morphio::property::compare(_children, other._children)));
10✔
80
}
81

82
bool SectionLevel::operator==(const SectionLevel& other) const {
2✔
83
    return !diff(other);
2✔
84
}
85

86
bool SectionLevel::operator!=(const SectionLevel& other) const {
4✔
87
    return diff(other);
4✔
88
}
89

90
bool CellLevel::diff(const CellLevel& other) const {
12✔
91
    if (this == &other) {
12✔
92
        return false;
4✔
93
    }
94

95
    return !(_cellFamily == other._cellFamily && _somaType == other._somaType);
8✔
96
}
97

98
bool CellLevel::operator==(const CellLevel& other) const {
2✔
99
    return !diff(other);
2✔
100
}
101

102
bool CellLevel::operator!=(const CellLevel& other) const {
6✔
103
    return diff(other);
6✔
104
}
105

106
MitochondriaPointLevel::MitochondriaPointLevel(const MitochondriaPointLevel& data,
66✔
107
                                               const SectionRange& range) {
66✔
108
    _sectionIds = copySpan<Property::MitoNeuriteSectionId>(data._sectionIds, range);
66✔
109
    _relativePathLengths = copySpan<Property::MitoPathLength>(data._relativePathLengths, range);
66✔
110
    _diameters = copySpan<Property::MitoDiameter>(data._diameters, range);
66✔
111
}
66✔
112

113
MitochondriaPointLevel::MitochondriaPointLevel(
6✔
114
    std::vector<MitoNeuriteSectionId::Type> sectionIds,
115
    std::vector<MitoPathLength::Type> relativePathLengths,
116
    std::vector<MitoDiameter::Type> diameters)
6✔
117
    : _sectionIds(std::move(sectionIds))
6✔
118
    , _relativePathLengths(std::move(relativePathLengths))
6✔
119
    , _diameters(std::move(diameters)) {
18✔
120
    if (_sectionIds.size() != _relativePathLengths.size()) {
6✔
121
        throw SectionBuilderError(
122
            "While building MitochondriaPointLevel:\n"
123
            "section IDs vector have size: " +
2✔
124
            std::to_string(_sectionIds.size()) + " while relative path length vector has size: " +
6✔
125
            std::to_string(_relativePathLengths.size()));
6✔
126
    }
127

128
    if (_sectionIds.size() != _diameters.size()) {
4✔
129
        throw SectionBuilderError(
130
            "While building MitochondriaPointLevel:\n"
131
            "section IDs vector have size: " +
2✔
132
            std::to_string(_sectionIds.size()) +
6✔
133
            " while diameter vector has size: " + std::to_string(_diameters.size()));
6✔
134
    }
135
}
2✔
136

137
bool MitochondriaSectionLevel::diff(const MitochondriaSectionLevel& other) const {
10✔
138
    return !(this == &other || (compare_section_structure(this->_sections, other._sections) &&
10✔
139
                                morphio::property::compare(this->_children, other._children)));
10✔
140
}
141

142
bool MitochondriaSectionLevel::operator==(const MitochondriaSectionLevel& other) const {
2✔
143
    return !diff(other);
2✔
144
}
145

146
bool MitochondriaSectionLevel::operator!=(const MitochondriaSectionLevel& other) const {
4✔
147
    return diff(other);
4✔
148
}
149

150
bool MitochondriaPointLevel::diff(const MitochondriaPointLevel& other) const {
4✔
151
    return !(this == &other ||
4✔
NEW
152
             (morphio::property::compare(this->_sectionIds, other._sectionIds) &&
×
NEW
153
              morphio::property::compare(this->_relativePathLengths, other._relativePathLengths) &&
×
154
              morphio::property::compare(this->_diameters, other._diameters)));
4✔
155
}
156

157
bool MitochondriaPointLevel::operator==(const MitochondriaPointLevel& other) const {
2✔
158
    return !diff(other);
2✔
159
}
160

161
bool MitochondriaPointLevel::operator!=(const MitochondriaPointLevel& other) const {
2✔
162
    return diff(other);
2✔
163
}
164

165
std::ostream& operator<<(std::ostream& os, const PointLevel& pointLevel) {
4✔
166
    os << "Point level properties:\n"
167
       << "Point Diameter"
168
       << (pointLevel._perimeters.size() == pointLevel._points.size() ? " Perimeter\n" : "\n");
4✔
169
    for (unsigned int i = 0; i < pointLevel._points.size(); ++i) {
12✔
170
        os << dumpPoint(pointLevel._points[i]) << ' ' << pointLevel._diameters[i];
8✔
171
        if (pointLevel._perimeters.size() == pointLevel._points.size()) {
8✔
172
            os << ' ' << pointLevel._perimeters[i];
8✔
173
        }
174
        os << '\n';
8✔
175
    }
176
    return os;
4✔
177
}
178

179
std::ostream& operator<<(std::ostream& os, const Properties& properties) {
×
180
    os << properties._pointLevel << '\n';
×
181
    // os << _sectionLevel << '\n';
182
    // os << _cellLevel << '\n';
183
    return os;
×
184
}
185

186
}  // namespace Property
187
}  // 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