Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit c1dd45f

Browse files
Apply clang-format
1 parent 12b5fb9 commit c1dd45f

6 files changed

Lines changed: 69 additions & 119 deletions

File tree

include/morphio/enums.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ enum LogLevel { ERROR, WARNING, INFO, DEBUG };
1111
/** The list of modifier flags that can be passed when loading a morphology
1212
* See morphio::mut::modifiers for more information **/
1313
enum Option {
14-
NO_MODIFIER = 0b0000000000000000, //!< Read morphology as is without any modification
15-
TWO_POINTS_SECTIONS = 0b0000000000000001, //!< Keep only the first and last points of sections
16-
SOMA_SPHERE = 0b0000000000000010, //!< Interpret morphology soma as a sphere
17-
NO_DUPLICATES = 0b0000000000000100, //!< Skip duplicating points
18-
NRN_ORDER = 0b0000000000001000, //!< Order of neurites will be the same as in NEURON simulator
19-
ALLOW_ROOT_BIFURCATIONS = 0b0000000000010000, //!< Bifurcations at first point are allowed
20-
ALLOW_SOMA_BIFURCATIONS = 0b0000000000100000, //!< Bifurcations in soma are allowed
21-
ALLOW_MULTIPLE_SOMATA = 0b0000000001000000 //!< Multiple somata are allowed
14+
NO_MODIFIER = 0b0000000000000000, //!< Read morphology as is without any modification
15+
TWO_POINTS_SECTIONS = 0b0000000000000001, //!< Keep only the first and last points of sections
16+
SOMA_SPHERE = 0b0000000000000010, //!< Interpret morphology soma as a sphere
17+
NO_DUPLICATES = 0b0000000000000100, //!< Skip duplicating points
18+
NRN_ORDER = 0b0000000000001000, //!< Order of neurites will be the same as in NEURON simulator
19+
ALLOW_ROOT_BIFURCATIONS = 0b0000000000010000, //!< Bifurcations at first point are allowed
20+
ALLOW_SOMA_BIFURCATIONS = 0b0000000000100000, //!< Bifurcations in soma are allowed
21+
ALLOW_MULTIPLE_SOMATA = 0b0000000001000000 //!< Multiple somata are allowed
2222
};
2323

2424
/**

include/morphio/errorMessages.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ class ErrorMessages
236236
std::string WARNING_WRONG_DUPLICATE(const std::shared_ptr<morphio::mut::Section>& current,
237237
const std::shared_ptr<morphio::mut::Section>& parent) const;
238238
/** Writing empty section warning message */
239-
std::string WARNING_APPENDING_EMPTY_SECTION(const std::shared_ptr<morphio::mut::Section>& section) const;
239+
std::string WARNING_APPENDING_EMPTY_SECTION(
240+
const std::shared_ptr<morphio::mut::Section>& section) const;
240241
/** Writing single child section warning message */
241242
std::string WARNING_ONLY_CHILD(const DebugInfo& info,
242243
unsigned int parentId,

src/errorMessages.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ std::string ErrorMessages::WARNING_APPENDING_EMPTY_SECTION(
301301
std::string ErrorMessages::WARNING_ROOT_BIFURCATION(const Sample& sample) const {
302302
return errorMsg(sample.lineNumber,
303303
ErrorLevel::WARNING,
304-
"Warning: root bifurcation kept for point with id: " + std::to_string(sample.id));
304+
"Warning: root bifurcation kept for point with id: " +
305+
std::to_string(sample.id));
305306
}
306307

307308
std::string ErrorMessages::WARNING_WRONG_DUPLICATE(

src/readers/morphologyASC.cpp

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ class NeurolucidaParser
126126
int32_t _create_soma_or_section(const Header& header,
127127
std::vector<Point>& points,
128128
std::vector<morphio::floatType>& diameters,
129-
unsigned int& options
130-
) {
129+
unsigned int& options) {
131130
int32_t return_id = -1;
132131
morphio::Property::PointLevel properties;
133132
properties._points = points;
@@ -143,28 +142,19 @@ class NeurolucidaParser
143142
} else if (header.token == Token::CELLBODY) {
144143
if (!nb_.soma()->points().empty()) {
145144
if (options & ALLOW_SOMA_BIFURCATIONS) {
146-
printError(
147-
Warning::SOMA_BIFURCATION,
148-
err_.WARNING_SOMA_BIFURCATION()
149-
);
145+
printError(Warning::SOMA_BIFURCATION, err_.WARNING_SOMA_BIFURCATION());
150146
} else if (options & ALLOW_MULTIPLE_SOMATA) {
151-
printError(
152-
Warning::MULTIPLE_SOMATA,
153-
err_.WARNING_MULTIPLE_SOMATA()
154-
);
147+
printError(Warning::MULTIPLE_SOMATA, err_.WARNING_MULTIPLE_SOMATA());
155148
} else {
156149
throw SomaError(err_.ERROR_SOMA_ALREADY_DEFINED(lex_.line_num()));
157150
}
158-
nb_.soma()->properties()._points.insert(
159-
nb_.soma()->properties()._points.end(),
160-
properties._points.begin(),
161-
properties._points.end()
162-
);
151+
nb_.soma()->properties()._points.insert(nb_.soma()->properties()._points.end(),
152+
properties._points.begin(),
153+
properties._points.end());
163154
nb_.soma()->properties()._diameters.insert(
164155
nb_.soma()->properties()._diameters.end(),
165156
properties._diameters.begin(),
166-
properties._diameters.end()
167-
);
157+
properties._diameters.end());
168158
} else {
169159
nb_.soma()->properties() = properties;
170160
}

src/readers/morphologySWC.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,7 @@ class SWCBuilder
129129

130130
if (soma_bifurcations.size() > 1) {
131131
if (options & ALLOW_SOMA_BIFURCATIONS) {
132-
printError(
133-
Warning::SOMA_BIFURCATION,
134-
err.WARNING_SOMA_BIFURCATION()
135-
);
132+
printError(Warning::SOMA_BIFURCATION, err.WARNING_SOMA_BIFURCATION());
136133
} else {
137134
throw morphio::SomaError(err.ERROR_SOMA_BIFURCATION(sample, soma_bifurcations));
138135
}
@@ -340,12 +337,8 @@ class SWCBuilder
340337
// Bifurcation right at the start
341338
if (isRootPoint(sample) && isSectionEnd(sample)) {
342339
if (options & ALLOW_ROOT_BIFURCATIONS) {
343-
printError(
344-
Warning::ROOT_BIFURCATION,
345-
err.WARNING_ROOT_BIFURCATION(sample)
346-
);
347-
}
348-
else {
340+
printError(Warning::ROOT_BIFURCATION, err.WARNING_ROOT_BIFURCATION(sample));
341+
} else {
349342
continue;
350343
}
351344
}

tests/test_reader_options.cpp

Lines changed: 47 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -6,63 +6,56 @@
66

77
TEST_CASE("root bifurcation", "[loader_edge_cases]") {
88
std::vector<std::string> exts{"asc", "h5", "swc"};
9-
for (auto&& ext : exts)
10-
{
11-
SECTION( "Testing mutable morphology with " + ext + " extension" )
12-
{
13-
auto mutable_morph_default_opts = morphio::mut::Morphology("data/edge_cases/root_bifurcation." + ext);
9+
for (auto&& ext : exts) {
10+
SECTION("Testing mutable morphology with " + ext + " extension") {
11+
auto mutable_morph_default_opts = morphio::mut::Morphology(
12+
"data/edge_cases/root_bifurcation." + ext);
1413

1514
if (ext == "swc") {
1615
// By default, root bifurcations can be not loaded from SWC files
1716
REQUIRE(mutable_morph_default_opts.rootSections().size() == 1);
1817
REQUIRE(mutable_morph_default_opts.rootSections()[0]->points().size() == 3);
19-
}
20-
else if (ext == "asc" || ext == "h5") {
18+
} else if (ext == "asc" || ext == "h5") {
2119
// By default, root bifurcations can be loaded from ASC and H5 files
2220
REQUIRE(mutable_morph_default_opts.rootSections().size() == 3);
2321
REQUIRE(mutable_morph_default_opts.rootSections()[0]->points().size() == 1);
2422
REQUIRE(mutable_morph_default_opts.rootSections()[1]->points().size() == 1);
2523
REQUIRE(mutable_morph_default_opts.rootSections()[2]->points().size() == 3);
26-
}
27-
else {
28-
throw std::invalid_argument( "Unknown extension: " + ext );
24+
} else {
25+
throw std::invalid_argument("Unknown extension: " + ext);
2926
}
3027

31-
auto mutable_morph = morphio::mut::Morphology(
32-
"data/edge_cases/root_bifurcation." + ext,
33-
morphio::enums::Option::ALLOW_ROOT_BIFURCATIONS
34-
);
28+
auto mutable_morph =
29+
morphio::mut::Morphology("data/edge_cases/root_bifurcation." + ext,
30+
morphio::enums::Option::ALLOW_ROOT_BIFURCATIONS);
3531

3632
REQUIRE(mutable_morph.rootSections().size() == 3);
3733
REQUIRE(mutable_morph.rootSections()[0]->points().size() == 1);
3834
REQUIRE(mutable_morph.rootSections()[1]->points().size() == 1);
3935
REQUIRE(mutable_morph.rootSections()[2]->points().size() == 3);
4036
}
4137

42-
SECTION( "Testing immutable morphology with " + ext + " extension" )
43-
{
44-
auto immutable_morph_default_opts = morphio::Morphology("data/edge_cases/root_bifurcation." + ext);
38+
SECTION("Testing immutable morphology with " + ext + " extension") {
39+
auto immutable_morph_default_opts = morphio::Morphology(
40+
"data/edge_cases/root_bifurcation." + ext);
4541

4642
if (ext == "swc") {
4743
// By default, root bifurcations can be not loaded from SWC files
4844
REQUIRE(immutable_morph_default_opts.rootSections().size() == 1);
4945
REQUIRE(immutable_morph_default_opts.rootSections()[0].points().size() == 3);
50-
}
51-
else if (ext == "asc" || ext == "h5") {
46+
} else if (ext == "asc" || ext == "h5") {
5247
// By default, root bifurcations can be loaded from ASC and H5 files
5348
REQUIRE(immutable_morph_default_opts.rootSections().size() == 3);
5449
REQUIRE(immutable_morph_default_opts.rootSections()[0].points().size() == 1);
5550
REQUIRE(immutable_morph_default_opts.rootSections()[1].points().size() == 1);
5651
REQUIRE(immutable_morph_default_opts.rootSections()[2].points().size() == 3);
57-
}
58-
else {
59-
throw std::invalid_argument( "Unknown extension: " + ext );
52+
} else {
53+
throw std::invalid_argument("Unknown extension: " + ext);
6054
}
6155

62-
auto immutable_morph = morphio::Morphology(
63-
"data/edge_cases/root_bifurcation." + ext,
64-
morphio::enums::Option::ALLOW_ROOT_BIFURCATIONS
65-
);
56+
auto immutable_morph =
57+
morphio::Morphology("data/edge_cases/root_bifurcation." + ext,
58+
morphio::enums::Option::ALLOW_ROOT_BIFURCATIONS);
6659

6760
REQUIRE(immutable_morph.rootSections().size() == 3);
6861
REQUIRE(immutable_morph.rootSections()[0].points().size() == 1);
@@ -75,109 +68,81 @@ TEST_CASE("root bifurcation", "[loader_edge_cases]") {
7568

7669
TEST_CASE("soma bifurcation", "[loader_edge_cases]") {
7770
std::vector<std::string> exts{"asc", "swc"};
78-
for (auto&& ext : exts)
79-
{
80-
SECTION( "testing mutable morphology with " + ext + " extension" )
81-
{
71+
for (auto&& ext : exts) {
72+
SECTION("testing mutable morphology with " + ext + " extension") {
8273
// By default, bifurcations in soma are considered as errors in ASC and SWC files
8374
REQUIRE_THROWS(morphio::mut::Morphology("data/edge_cases/soma_bifurcation." + ext));
8475

8576
// Bifurcations in soma can optionaly be loaded from ASC and SWC files
86-
auto mutable_morph = morphio::mut::Morphology(
87-
"data/edge_cases/soma_bifurcation." + ext,
88-
morphio::enums::Option::ALLOW_SOMA_BIFURCATIONS
89-
);
77+
auto mutable_morph =
78+
morphio::mut::Morphology("data/edge_cases/soma_bifurcation." + ext,
79+
morphio::enums::Option::ALLOW_SOMA_BIFURCATIONS);
9080

9181
REQUIRE(mutable_morph.soma()->points().size() == 8);
9282
REQUIRE(mutable_morph.rootSections().size() == 1);
9383
}
9484

95-
SECTION( "testing immutable morphology with " + ext + " extension" )
96-
{
85+
SECTION("testing immutable morphology with " + ext + " extension") {
9786
// By default, bifurcations in soma are considered as errors in ASC and SWC files
9887
REQUIRE_THROWS(morphio::Morphology("data/edge_cases/soma_bifurcation." + ext));
9988

10089
// Bifurcations in soma can optionaly be loaded from ASC and SWC files
101-
auto immutable_morph = morphio::Morphology(
102-
"data/edge_cases/soma_bifurcation." + ext,
103-
morphio::enums::Option::ALLOW_SOMA_BIFURCATIONS
104-
);
90+
auto immutable_morph =
91+
morphio::Morphology("data/edge_cases/soma_bifurcation." + ext,
92+
morphio::enums::Option::ALLOW_SOMA_BIFURCATIONS);
10593

10694
REQUIRE(immutable_morph.soma().points().size() == 8);
10795
REQUIRE(immutable_morph.rootSections().size() == 1);
10896
}
10997
}
110-
SECTION( "testing mutable morphology with h5 extension")
111-
{
98+
SECTION("testing mutable morphology with h5 extension") {
11299
// Bifurcations in soma are always considered as errors in H5 files
113100
REQUIRE_THROWS(morphio::mut::Morphology("data/soma_bifurcation.h5"));
114-
REQUIRE_THROWS(
115-
morphio::mut::Morphology(
116-
"data/soma_bifurcation.h5",
117-
morphio::enums::Option::ALLOW_SOMA_BIFURCATIONS
118-
)
119-
);
101+
REQUIRE_THROWS(morphio::mut::Morphology("data/soma_bifurcation.h5",
102+
morphio::enums::Option::ALLOW_SOMA_BIFURCATIONS));
120103
REQUIRE_THROWS(morphio::Morphology("data/soma_bifurcation.h5"));
121-
REQUIRE_THROWS(
122-
morphio::Morphology(
123-
"data/soma_bifurcation.h5",
124-
morphio::enums::Option::ALLOW_SOMA_BIFURCATIONS
125-
)
126-
);
104+
REQUIRE_THROWS(morphio::Morphology("data/soma_bifurcation.h5",
105+
morphio::enums::Option::ALLOW_SOMA_BIFURCATIONS));
127106
}
128107
}
129108

130109

131110
TEST_CASE("multiple somata", "[loader_edge_cases]") {
132111
std::vector<std::string> exts{"asc", "swc"};
133-
for (auto&& ext : exts)
134-
{
135-
SECTION( "testing mutable morphology with " + ext + " extension")
136-
{
112+
for (auto&& ext : exts) {
113+
SECTION("testing mutable morphology with " + ext + " extension") {
137114
// By default, multiple somata are considered as errors in ASC and SWC files
138115
REQUIRE_THROWS(morphio::mut::Morphology("data/multiple_soma." + ext));
139116

140117
// Multiple somata can optionaly be loaded from ASC and SWC files
141-
auto mutable_morph = morphio::mut::Morphology(
142-
"data/multiple_soma." + ext,
143-
morphio::enums::Option::ALLOW_MULTIPLE_SOMATA
144-
);
118+
auto mutable_morph =
119+
morphio::mut::Morphology("data/multiple_soma." + ext,
120+
morphio::enums::Option::ALLOW_MULTIPLE_SOMATA);
145121

146122
REQUIRE(mutable_morph.soma()->points().size() == 2);
147123
REQUIRE(mutable_morph.rootSections().size() == 2);
148124
}
149125

150-
SECTION( "testing immutable morphology with " + ext + " extension" )
151-
{
126+
SECTION("testing immutable morphology with " + ext + " extension") {
152127
// By default, multiple somata are considered as errors in ASC and SWC files
153128
REQUIRE_THROWS(morphio::Morphology("data/multiple_soma." + ext));
154129

155130
// Multiple somata can optionaly be loaded from ASC and SWC files
156-
auto immutable_morph = morphio::Morphology(
157-
"data/multiple_soma." + ext,
158-
morphio::enums::Option::ALLOW_MULTIPLE_SOMATA
159-
);
131+
auto immutable_morph =
132+
morphio::Morphology("data/multiple_soma." + ext,
133+
morphio::enums::Option::ALLOW_MULTIPLE_SOMATA);
160134

161135
REQUIRE(immutable_morph.soma().points().size() == 2);
162136
REQUIRE(immutable_morph.rootSections().size() == 2);
163137
}
164138
}
165-
SECTION( "testing mutable morphology with h5 extension")
166-
{
139+
SECTION("testing mutable morphology with h5 extension") {
167140
// Multiple somata are always considered as errors in H5 files
168141
REQUIRE_THROWS(morphio::mut::Morphology("data/multiple_soma.h5"));
169-
REQUIRE_THROWS(
170-
morphio::mut::Morphology(
171-
"data/multiple_soma.h5",
172-
morphio::enums::Option::ALLOW_MULTIPLE_SOMATA
173-
)
174-
);
142+
REQUIRE_THROWS(morphio::mut::Morphology("data/multiple_soma.h5",
143+
morphio::enums::Option::ALLOW_MULTIPLE_SOMATA));
175144
REQUIRE_THROWS(morphio::Morphology("data/multiple_soma.h5"));
176-
REQUIRE_THROWS(
177-
morphio::Morphology(
178-
"data/multiple_soma.h5",
179-
morphio::enums::Option::ALLOW_MULTIPLE_SOMATA
180-
)
181-
);
145+
REQUIRE_THROWS(morphio::Morphology("data/multiple_soma.h5",
146+
morphio::enums::Option::ALLOW_MULTIPLE_SOMATA));
182147
}
183148
}

0 commit comments

Comments
 (0)