From c1dd45f48f916155b648d655fa8c73b42ecc67ae Mon Sep 17 00:00:00 2001 From: Adrien Berchet Date: Fri, 25 Nov 2022 19:30:46 +0100 Subject: [PATCH] Apply clang-format --- include/morphio/enums.h | 16 ++-- include/morphio/errorMessages.h | 3 +- src/errorMessages.cpp | 3 +- src/readers/morphologyASC.cpp | 24 ++---- src/readers/morphologySWC.cpp | 13 +--- tests/test_reader_options.cpp | 129 ++++++++++++-------------------- 6 files changed, 69 insertions(+), 119 deletions(-) diff --git a/include/morphio/enums.h b/include/morphio/enums.h index 5c4784823..97fff85f3 100644 --- a/include/morphio/enums.h +++ b/include/morphio/enums.h @@ -11,14 +11,14 @@ enum LogLevel { ERROR, WARNING, INFO, DEBUG }; /** The list of modifier flags that can be passed when loading a morphology * See morphio::mut::modifiers for more information **/ enum Option { - NO_MODIFIER = 0b0000000000000000, //!< Read morphology as is without any modification - TWO_POINTS_SECTIONS = 0b0000000000000001, //!< Keep only the first and last points of sections - SOMA_SPHERE = 0b0000000000000010, //!< Interpret morphology soma as a sphere - NO_DUPLICATES = 0b0000000000000100, //!< Skip duplicating points - NRN_ORDER = 0b0000000000001000, //!< Order of neurites will be the same as in NEURON simulator - ALLOW_ROOT_BIFURCATIONS = 0b0000000000010000, //!< Bifurcations at first point are allowed - ALLOW_SOMA_BIFURCATIONS = 0b0000000000100000, //!< Bifurcations in soma are allowed - ALLOW_MULTIPLE_SOMATA = 0b0000000001000000 //!< Multiple somata are allowed + NO_MODIFIER = 0b0000000000000000, //!< Read morphology as is without any modification + TWO_POINTS_SECTIONS = 0b0000000000000001, //!< Keep only the first and last points of sections + SOMA_SPHERE = 0b0000000000000010, //!< Interpret morphology soma as a sphere + NO_DUPLICATES = 0b0000000000000100, //!< Skip duplicating points + NRN_ORDER = 0b0000000000001000, //!< Order of neurites will be the same as in NEURON simulator + ALLOW_ROOT_BIFURCATIONS = 0b0000000000010000, //!< Bifurcations at first point are allowed + ALLOW_SOMA_BIFURCATIONS = 0b0000000000100000, //!< Bifurcations in soma are allowed + ALLOW_MULTIPLE_SOMATA = 0b0000000001000000 //!< Multiple somata are allowed }; /** diff --git a/include/morphio/errorMessages.h b/include/morphio/errorMessages.h index c4e7d36dc..033030b75 100644 --- a/include/morphio/errorMessages.h +++ b/include/morphio/errorMessages.h @@ -236,7 +236,8 @@ class ErrorMessages std::string WARNING_WRONG_DUPLICATE(const std::shared_ptr& current, const std::shared_ptr& parent) const; /** Writing empty section warning message */ - std::string WARNING_APPENDING_EMPTY_SECTION(const std::shared_ptr& section) const; + std::string WARNING_APPENDING_EMPTY_SECTION( + const std::shared_ptr& section) const; /** Writing single child section warning message */ std::string WARNING_ONLY_CHILD(const DebugInfo& info, unsigned int parentId, diff --git a/src/errorMessages.cpp b/src/errorMessages.cpp index f928fd53b..534588ff9 100644 --- a/src/errorMessages.cpp +++ b/src/errorMessages.cpp @@ -301,7 +301,8 @@ std::string ErrorMessages::WARNING_APPENDING_EMPTY_SECTION( std::string ErrorMessages::WARNING_ROOT_BIFURCATION(const Sample& sample) const { return errorMsg(sample.lineNumber, ErrorLevel::WARNING, - "Warning: root bifurcation kept for point with id: " + std::to_string(sample.id)); + "Warning: root bifurcation kept for point with id: " + + std::to_string(sample.id)); } std::string ErrorMessages::WARNING_WRONG_DUPLICATE( diff --git a/src/readers/morphologyASC.cpp b/src/readers/morphologyASC.cpp index 562bf6aba..dc846cd51 100644 --- a/src/readers/morphologyASC.cpp +++ b/src/readers/morphologyASC.cpp @@ -126,8 +126,7 @@ class NeurolucidaParser int32_t _create_soma_or_section(const Header& header, std::vector& points, std::vector& diameters, - unsigned int& options - ) { + unsigned int& options) { int32_t return_id = -1; morphio::Property::PointLevel properties; properties._points = points; @@ -143,28 +142,19 @@ class NeurolucidaParser } else if (header.token == Token::CELLBODY) { if (!nb_.soma()->points().empty()) { if (options & ALLOW_SOMA_BIFURCATIONS) { - printError( - Warning::SOMA_BIFURCATION, - err_.WARNING_SOMA_BIFURCATION() - ); + printError(Warning::SOMA_BIFURCATION, err_.WARNING_SOMA_BIFURCATION()); } else if (options & ALLOW_MULTIPLE_SOMATA) { - printError( - Warning::MULTIPLE_SOMATA, - err_.WARNING_MULTIPLE_SOMATA() - ); + printError(Warning::MULTIPLE_SOMATA, err_.WARNING_MULTIPLE_SOMATA()); } else { throw SomaError(err_.ERROR_SOMA_ALREADY_DEFINED(lex_.line_num())); } - nb_.soma()->properties()._points.insert( - nb_.soma()->properties()._points.end(), - properties._points.begin(), - properties._points.end() - ); + nb_.soma()->properties()._points.insert(nb_.soma()->properties()._points.end(), + properties._points.begin(), + properties._points.end()); nb_.soma()->properties()._diameters.insert( nb_.soma()->properties()._diameters.end(), properties._diameters.begin(), - properties._diameters.end() - ); + properties._diameters.end()); } else { nb_.soma()->properties() = properties; } diff --git a/src/readers/morphologySWC.cpp b/src/readers/morphologySWC.cpp index 0ba9f25c7..1ff1562e0 100644 --- a/src/readers/morphologySWC.cpp +++ b/src/readers/morphologySWC.cpp @@ -129,10 +129,7 @@ class SWCBuilder if (soma_bifurcations.size() > 1) { if (options & ALLOW_SOMA_BIFURCATIONS) { - printError( - Warning::SOMA_BIFURCATION, - err.WARNING_SOMA_BIFURCATION() - ); + printError(Warning::SOMA_BIFURCATION, err.WARNING_SOMA_BIFURCATION()); } else { throw morphio::SomaError(err.ERROR_SOMA_BIFURCATION(sample, soma_bifurcations)); } @@ -340,12 +337,8 @@ class SWCBuilder // Bifurcation right at the start if (isRootPoint(sample) && isSectionEnd(sample)) { if (options & ALLOW_ROOT_BIFURCATIONS) { - printError( - Warning::ROOT_BIFURCATION, - err.WARNING_ROOT_BIFURCATION(sample) - ); - } - else { + printError(Warning::ROOT_BIFURCATION, err.WARNING_ROOT_BIFURCATION(sample)); + } else { continue; } } diff --git a/tests/test_reader_options.cpp b/tests/test_reader_options.cpp index bc8b2a09f..de4b06b13 100644 --- a/tests/test_reader_options.cpp +++ b/tests/test_reader_options.cpp @@ -6,32 +6,28 @@ TEST_CASE("root bifurcation", "[loader_edge_cases]") { std::vector exts{"asc", "h5", "swc"}; - for (auto&& ext : exts) - { - SECTION( "Testing mutable morphology with " + ext + " extension" ) - { - auto mutable_morph_default_opts = morphio::mut::Morphology("data/edge_cases/root_bifurcation." + ext); + for (auto&& ext : exts) { + SECTION("Testing mutable morphology with " + ext + " extension") { + auto mutable_morph_default_opts = morphio::mut::Morphology( + "data/edge_cases/root_bifurcation." + ext); if (ext == "swc") { // By default, root bifurcations can be not loaded from SWC files REQUIRE(mutable_morph_default_opts.rootSections().size() == 1); REQUIRE(mutable_morph_default_opts.rootSections()[0]->points().size() == 3); - } - else if (ext == "asc" || ext == "h5") { + } else if (ext == "asc" || ext == "h5") { // By default, root bifurcations can be loaded from ASC and H5 files REQUIRE(mutable_morph_default_opts.rootSections().size() == 3); REQUIRE(mutable_morph_default_opts.rootSections()[0]->points().size() == 1); REQUIRE(mutable_morph_default_opts.rootSections()[1]->points().size() == 1); REQUIRE(mutable_morph_default_opts.rootSections()[2]->points().size() == 3); - } - else { - throw std::invalid_argument( "Unknown extension: " + ext ); + } else { + throw std::invalid_argument("Unknown extension: " + ext); } - auto mutable_morph = morphio::mut::Morphology( - "data/edge_cases/root_bifurcation." + ext, - morphio::enums::Option::ALLOW_ROOT_BIFURCATIONS - ); + auto mutable_morph = + morphio::mut::Morphology("data/edge_cases/root_bifurcation." + ext, + morphio::enums::Option::ALLOW_ROOT_BIFURCATIONS); REQUIRE(mutable_morph.rootSections().size() == 3); REQUIRE(mutable_morph.rootSections()[0]->points().size() == 1); @@ -39,30 +35,27 @@ TEST_CASE("root bifurcation", "[loader_edge_cases]") { REQUIRE(mutable_morph.rootSections()[2]->points().size() == 3); } - SECTION( "Testing immutable morphology with " + ext + " extension" ) - { - auto immutable_morph_default_opts = morphio::Morphology("data/edge_cases/root_bifurcation." + ext); + SECTION("Testing immutable morphology with " + ext + " extension") { + auto immutable_morph_default_opts = morphio::Morphology( + "data/edge_cases/root_bifurcation." + ext); if (ext == "swc") { // By default, root bifurcations can be not loaded from SWC files REQUIRE(immutable_morph_default_opts.rootSections().size() == 1); REQUIRE(immutable_morph_default_opts.rootSections()[0].points().size() == 3); - } - else if (ext == "asc" || ext == "h5") { + } else if (ext == "asc" || ext == "h5") { // By default, root bifurcations can be loaded from ASC and H5 files REQUIRE(immutable_morph_default_opts.rootSections().size() == 3); REQUIRE(immutable_morph_default_opts.rootSections()[0].points().size() == 1); REQUIRE(immutable_morph_default_opts.rootSections()[1].points().size() == 1); REQUIRE(immutable_morph_default_opts.rootSections()[2].points().size() == 3); - } - else { - throw std::invalid_argument( "Unknown extension: " + ext ); + } else { + throw std::invalid_argument("Unknown extension: " + ext); } - auto immutable_morph = morphio::Morphology( - "data/edge_cases/root_bifurcation." + ext, - morphio::enums::Option::ALLOW_ROOT_BIFURCATIONS - ); + auto immutable_morph = + morphio::Morphology("data/edge_cases/root_bifurcation." + ext, + morphio::enums::Option::ALLOW_ROOT_BIFURCATIONS); REQUIRE(immutable_morph.rootSections().size() == 3); REQUIRE(immutable_morph.rootSections()[0].points().size() == 1); @@ -75,109 +68,81 @@ TEST_CASE("root bifurcation", "[loader_edge_cases]") { TEST_CASE("soma bifurcation", "[loader_edge_cases]") { std::vector exts{"asc", "swc"}; - for (auto&& ext : exts) - { - SECTION( "testing mutable morphology with " + ext + " extension" ) - { + for (auto&& ext : exts) { + SECTION("testing mutable morphology with " + ext + " extension") { // By default, bifurcations in soma are considered as errors in ASC and SWC files REQUIRE_THROWS(morphio::mut::Morphology("data/edge_cases/soma_bifurcation." + ext)); // Bifurcations in soma can optionaly be loaded from ASC and SWC files - auto mutable_morph = morphio::mut::Morphology( - "data/edge_cases/soma_bifurcation." + ext, - morphio::enums::Option::ALLOW_SOMA_BIFURCATIONS - ); + auto mutable_morph = + morphio::mut::Morphology("data/edge_cases/soma_bifurcation." + ext, + morphio::enums::Option::ALLOW_SOMA_BIFURCATIONS); REQUIRE(mutable_morph.soma()->points().size() == 8); REQUIRE(mutable_morph.rootSections().size() == 1); } - SECTION( "testing immutable morphology with " + ext + " extension" ) - { + SECTION("testing immutable morphology with " + ext + " extension") { // By default, bifurcations in soma are considered as errors in ASC and SWC files REQUIRE_THROWS(morphio::Morphology("data/edge_cases/soma_bifurcation." + ext)); // Bifurcations in soma can optionaly be loaded from ASC and SWC files - auto immutable_morph = morphio::Morphology( - "data/edge_cases/soma_bifurcation." + ext, - morphio::enums::Option::ALLOW_SOMA_BIFURCATIONS - ); + auto immutable_morph = + morphio::Morphology("data/edge_cases/soma_bifurcation." + ext, + morphio::enums::Option::ALLOW_SOMA_BIFURCATIONS); REQUIRE(immutable_morph.soma().points().size() == 8); REQUIRE(immutable_morph.rootSections().size() == 1); } } - SECTION( "testing mutable morphology with h5 extension") - { + SECTION("testing mutable morphology with h5 extension") { // Bifurcations in soma are always considered as errors in H5 files REQUIRE_THROWS(morphio::mut::Morphology("data/soma_bifurcation.h5")); - REQUIRE_THROWS( - morphio::mut::Morphology( - "data/soma_bifurcation.h5", - morphio::enums::Option::ALLOW_SOMA_BIFURCATIONS - ) - ); + REQUIRE_THROWS(morphio::mut::Morphology("data/soma_bifurcation.h5", + morphio::enums::Option::ALLOW_SOMA_BIFURCATIONS)); REQUIRE_THROWS(morphio::Morphology("data/soma_bifurcation.h5")); - REQUIRE_THROWS( - morphio::Morphology( - "data/soma_bifurcation.h5", - morphio::enums::Option::ALLOW_SOMA_BIFURCATIONS - ) - ); + REQUIRE_THROWS(morphio::Morphology("data/soma_bifurcation.h5", + morphio::enums::Option::ALLOW_SOMA_BIFURCATIONS)); } } TEST_CASE("multiple somata", "[loader_edge_cases]") { std::vector exts{"asc", "swc"}; - for (auto&& ext : exts) - { - SECTION( "testing mutable morphology with " + ext + " extension") - { + for (auto&& ext : exts) { + SECTION("testing mutable morphology with " + ext + " extension") { // By default, multiple somata are considered as errors in ASC and SWC files REQUIRE_THROWS(morphio::mut::Morphology("data/multiple_soma." + ext)); // Multiple somata can optionaly be loaded from ASC and SWC files - auto mutable_morph = morphio::mut::Morphology( - "data/multiple_soma." + ext, - morphio::enums::Option::ALLOW_MULTIPLE_SOMATA - ); + auto mutable_morph = + morphio::mut::Morphology("data/multiple_soma." + ext, + morphio::enums::Option::ALLOW_MULTIPLE_SOMATA); REQUIRE(mutable_morph.soma()->points().size() == 2); REQUIRE(mutable_morph.rootSections().size() == 2); } - SECTION( "testing immutable morphology with " + ext + " extension" ) - { + SECTION("testing immutable morphology with " + ext + " extension") { // By default, multiple somata are considered as errors in ASC and SWC files REQUIRE_THROWS(morphio::Morphology("data/multiple_soma." + ext)); // Multiple somata can optionaly be loaded from ASC and SWC files - auto immutable_morph = morphio::Morphology( - "data/multiple_soma." + ext, - morphio::enums::Option::ALLOW_MULTIPLE_SOMATA - ); + auto immutable_morph = + morphio::Morphology("data/multiple_soma." + ext, + morphio::enums::Option::ALLOW_MULTIPLE_SOMATA); REQUIRE(immutable_morph.soma().points().size() == 2); REQUIRE(immutable_morph.rootSections().size() == 2); } } - SECTION( "testing mutable morphology with h5 extension") - { + SECTION("testing mutable morphology with h5 extension") { // Multiple somata are always considered as errors in H5 files REQUIRE_THROWS(morphio::mut::Morphology("data/multiple_soma.h5")); - REQUIRE_THROWS( - morphio::mut::Morphology( - "data/multiple_soma.h5", - morphio::enums::Option::ALLOW_MULTIPLE_SOMATA - ) - ); + REQUIRE_THROWS(morphio::mut::Morphology("data/multiple_soma.h5", + morphio::enums::Option::ALLOW_MULTIPLE_SOMATA)); REQUIRE_THROWS(morphio::Morphology("data/multiple_soma.h5")); - REQUIRE_THROWS( - morphio::Morphology( - "data/multiple_soma.h5", - morphio::enums::Option::ALLOW_MULTIPLE_SOMATA - ) - ); + REQUIRE_THROWS(morphio::Morphology("data/multiple_soma.h5", + morphio::enums::Option::ALLOW_MULTIPLE_SOMATA)); } }