diff --git a/ci/check_clang_format.sh b/ci/check_clang_format.sh index 4ab659b..ae03f99 100755 --- a/ci/check_clang_format.sh +++ b/ci/check_clang_format.sh @@ -8,7 +8,7 @@ DIRS_TO_FORMAT='src include python' set -euo pipefail VENV=build/venv-clang-format -CLANG_FORMAT_VERSION=9.0.0 +CLANG_FORMAT_VERSION=20.1.5 if [[ ! -d $VENV ]]; then python3 -mvenv "$VENV" diff --git a/ci/check_generated_docstrings.sh b/ci/check_generated_docstrings.sh index a07f01e..2cfdde7 100755 --- a/ci/check_generated_docstrings.sh +++ b/ci/check_generated_docstrings.sh @@ -18,6 +18,7 @@ set -euo pipefail if [[ -z $LIBCLANG_PATH ]]; then echo "Expect a \$LIBCLANG_PATH in the environment, it should have the path to the libclang.so" + echo "see .github/workflows/docstring_check.yaml for the version currrently used" exit -1 fi diff --git a/include/bbp/sonata/config.h b/include/bbp/sonata/config.h index bf671e2..0cb5502 100644 --- a/include/bbp/sonata/config.h +++ b/include/bbp/sonata/config.h @@ -328,7 +328,8 @@ class SONATA_API SimulationConfig std::string name; }; - struct ModificationTTX: public ModificationBase {}; + struct ModificationTTX: public ModificationBase { + }; struct ModificationConfigureAllSections: public ModificationBase { /// For “ConfigureAllSections” manipulation, a snippet of python code to perform one or more diff --git a/python/bindings.cpp b/python/bindings.cpp index 14a13e3..9a7f632 100644 --- a/python/bindings.cpp +++ b/python/bindings.cpp @@ -326,13 +326,16 @@ py::class_ bindStorageClass(py::module& m, const char* clsName, const c namespace pybind11 { namespace detail { template -struct type_caster>: optional_caster> {}; +struct type_caster>: optional_caster> { +}; template <> -struct type_caster: public void_caster {}; +struct type_caster: public void_caster { +}; template -struct type_caster>: variant_caster> {}; +struct type_caster>: variant_caster> { +}; } // namespace detail } // namespace pybind11 @@ -345,17 +348,19 @@ void bindReportReader(py::module& m, const std::string& prefix) { // .ids, .data and .time members are owned by the c++ object. We can't do std::move. // To avoid copies, we must declare the owner of the data as the current Python // object. Numpy will adjust owner reference count according to returned arrays - .def_property_readonly("ids", [](const DataFrame& dframe) { - std::array dims { ssize_t(dframe.ids.size()) }; - return managedMemoryArray(dframe.ids.data(), dims, dframe); - }) - .def_property_readonly("data", [](const DataFrame& dframe) { - std::array dims {0l, ssize_t(dframe.ids.size())}; - if (dims[1] > 0) { - dims[0] = dframe.data.size() / dims[1]; - } - return managedMemoryArray(dframe.data.data(), dims, dframe); - }) + .def_property_readonly("ids", + [](const DataFrame& dframe) { + std::array dims{ssize_t(dframe.ids.size())}; + return managedMemoryArray(dframe.ids.data(), dims, dframe); + }) + .def_property_readonly("data", + [](const DataFrame& dframe) { + std::array dims{0l, ssize_t(dframe.ids.size())}; + if (dims[1] > 0) { + dims[0] = dframe.data.size() / dims[1]; + } + return managedMemoryArray(dframe.data.data(), dims, dframe); + }) .def_property_readonly("times", [](DataFrame& dframe) { return managedMemoryArray(dframe.times.data(), dframe.times.size(), dframe); }); diff --git a/src/common.cpp b/src/common.cpp index f837792..e7552cc 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -13,6 +13,6 @@ namespace bbp { namespace sonata { SonataError::SonataError(const std::string& what) - : std::runtime_error(what) {} + : std::runtime_error(what) { } } // namespace sonata } // namespace bbp diff --git a/src/config.cpp b/src/config.cpp index 2974d60..89227bd 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -341,7 +341,7 @@ template void raiseIfInvalidEnum(const char* /*unused*/, const Type& /*unused*/, const std::string& /*unused*/, - std::false_type /* tag */) {} + std::false_type /* tag */) { } template void parseMandatory(const nlohmann::json& it, @@ -923,10 +923,11 @@ class CircuitConfig::Parser "node", status, [&](NodePopulationProperties& popProperties, const nlohmann::json& popData) { - popProperties.spatialSegmentIndexDir = getJSONPath(popData, "spatial_segment_index_dir"); - popProperties.vasculatureFile = getOptionalJSONPath(popData, "vasculature_file"); - popProperties.vasculatureMesh = getOptionalJSONPath(popData, "vasculature_mesh"); - popProperties.microdomainsFile = getOptionalJSONPath(popData, "microdomains_file"); + popProperties.spatialSegmentIndexDir = getJSONPath(popData, + "spatial_segment_index_dir"); + popProperties.vasculatureFile = getOptionalJSONPath(popData, "vasculature_file"); + popProperties.vasculatureMesh = getOptionalJSONPath(popData, "vasculature_mesh"); + popProperties.microdomainsFile = getOptionalJSONPath(popData, "microdomains_file"); }); } @@ -936,10 +937,12 @@ class CircuitConfig::Parser "edge", status, [&](EdgePopulationProperties& popProperties, const nlohmann::json& popData) { - popProperties.spatialSynapseIndexDir = getJSONPath(popData, "spatial_synapse_index_dir"); - popProperties.endfeetMeshesFile = getOptionalJSONPath(popData, "endfeet_meshes_file"); - popProperties.spineMorphologiesDir = getOptionalJSONPath(popData, - "spine_morphologies_dir"); + popProperties.spatialSynapseIndexDir = getJSONPath(popData, + "spatial_synapse_index_dir"); + popProperties.endfeetMeshesFile = getOptionalJSONPath(popData, + "endfeet_meshes_file"); + popProperties.spineMorphologiesDir = getOptionalJSONPath(popData, + "spine_morphologies_dir"); }); } @@ -1458,13 +1461,13 @@ const nonstd::optional& SimulationConfig::getNodeSet() const noexce return _nodeSet; } -const std::unordered_map& SimulationConfig::getMetaData() const - noexcept { +const std::unordered_map& SimulationConfig::getMetaData() + const noexcept { return _metaData; } -const std::unordered_map& SimulationConfig::getBetaFeatures() const - noexcept { +const std::unordered_map& SimulationConfig::getBetaFeatures() + const noexcept { return _betaFeatures; } diff --git a/src/edges.cpp b/src/edges.cpp index 323fd47..9f3e047 100644 --- a/src/edges.cpp +++ b/src/edges.cpp @@ -37,13 +37,13 @@ namespace sonata { EdgePopulation::EdgePopulation(const std::string& h5FilePath, const std::string& csvFilePath, const std::string& name) - : Population(h5FilePath, csvFilePath, name, ELEMENT, Hdf5Reader()) {} + : Population(h5FilePath, csvFilePath, name, ELEMENT, Hdf5Reader()) { } EdgePopulation::EdgePopulation(const std::string& h5FilePath, const std::string& csvFilePath, const std::string& name, const Hdf5Reader& hdf5_reader) - : Population(h5FilePath, csvFilePath, name, ELEMENT, hdf5_reader) {} + : Population(h5FilePath, csvFilePath, name, ELEMENT, hdf5_reader) { } std::string EdgePopulation::source() const { diff --git a/src/hdf5_reader.cpp b/src/hdf5_reader.cpp index 4fd16ea..f063caf 100644 --- a/src/hdf5_reader.cpp +++ b/src/hdf5_reader.cpp @@ -8,11 +8,11 @@ namespace sonata { Hdf5Reader::Hdf5Reader() : impl(std::make_shared< - Hdf5PluginDefault>()) {} + Hdf5PluginDefault>()) { } Hdf5Reader::Hdf5Reader( std::shared_ptr> impl) - : impl(std::move(impl)) {} + : impl(std::move(impl)) { } HighFive::File Hdf5Reader::openFile(const std::string& filename) const { return impl->openFile(filename); diff --git a/src/node_sets.cpp b/src/node_sets.cpp index 2182c45..8ce0e5c 100644 --- a/src/node_sets.cpp +++ b/src/node_sets.cpp @@ -93,7 +93,7 @@ class NodeSets } explicit NodeSets(const fs::path& path) - : NodeSets(json::parse(std::ifstream(validate_path(path)))) {} + : NodeSets(json::parse(std::ifstream(validate_path(path)))) { } static std::unique_ptr fromFile(const std::string& path_) { fs::path path(path_); @@ -101,7 +101,7 @@ class NodeSets } explicit NodeSets(const std::string& content) - : NodeSets(json::parse(content)) {} + : NodeSets(json::parse(content)) { } Selection materialize(const std::string& name, const NodePopulation& population) const; @@ -168,7 +168,7 @@ class NodeSetBasicRule: public NodeSetRule public: NodeSetBasicRule(std::string attribute, const std::vector& values) : attribute_(std::move(attribute)) - , values_(values) {} + , values_(values) { } Selection materialize(const detail::NodeSets& /* unused */, const NodePopulation& np) const final { @@ -200,7 +200,7 @@ class NodeSetBasicPopulation: public NodeSetRule { public: explicit NodeSetBasicPopulation(const std::vector& values) - : values_(values) {} + : values_(values) { } Selection materialize(const detail::NodeSets& /* unused */, const NodePopulation& np) const final { @@ -228,7 +228,7 @@ class NodeSetBasicNodeIds: public NodeSetRule { public: explicit NodeSetBasicNodeIds(Selection::Values values) - : values_(std::move(values)) {} + : values_(std::move(values)) { } Selection materialize(const detail::NodeSets& /* unused */, const NodePopulation& np) const final { @@ -256,7 +256,7 @@ class NodeSetBasicMultiClause: public NodeSetRule { public: explicit NodeSetBasicMultiClause(std::vector&& clauses) - : clauses_(std::move(clauses)) {} + : clauses_(std::move(clauses)) { } Selection materialize(const detail::NodeSets& ns, const NodePopulation& np) const final { Selection ret = np.selectAll(); @@ -302,14 +302,14 @@ class NodeSetBasicOperatorString: public NodeSetRule std::string value) : op_(string2op(op)) , attribute_(std::move(attribute)) - , value_(std::move(value)) {} + , value_(std::move(value)) { } Selection materialize(const detail::NodeSets& /* unused */, const NodePopulation& np) const final { switch (op_) { case Op::regex: return np.regexMatch(attribute_, value_); - default: // LCOV_EXCL_LINE + default: // LCOV_EXCL_LINE LIBSONATA_THROW_IF_REACHED // LCOV_EXCL_LINE } } @@ -333,7 +333,7 @@ class NodeSetBasicOperatorString: public NodeSetRule switch (op) { case Op::regex: return "$regex"; - default: // LCOV_EXCL_LINE + default: // LCOV_EXCL_LINE LIBSONATA_THROW_IF_REACHED // LCOV_EXCL_LINE } } @@ -357,7 +357,7 @@ class NodeSetBasicOperatorNumeric: public NodeSetRule explicit NodeSetBasicOperatorNumeric(std::string name, const std::string& op, double value) : name_(std::move(name)) , value_(value) - , op_(string2op(op)) {} + , op_(string2op(op)) { } Selection materialize(const detail::NodeSets& /* unused */, const NodePopulation& np) const final { @@ -372,7 +372,7 @@ class NodeSetBasicOperatorNumeric: public NodeSetRule case Op::lte: return np.filterAttribute(name_, [this](const double v) { return v <= value_; }); - default: // LCOV_EXCL_LINE + default: // LCOV_EXCL_LINE LIBSONATA_THROW_IF_REACHED // LCOV_EXCL_LINE } } @@ -411,7 +411,7 @@ class NodeSetBasicOperatorNumeric: public NodeSetRule return "$gte"; case Op::lte: return "$lte"; - default: // LCOV_EXCL_LINE + default: // LCOV_EXCL_LINE LIBSONATA_THROW_IF_REACHED // LCOV_EXCL_LINE } } @@ -432,7 +432,7 @@ class NodeSetCompoundRule: public NodeSetRule public: NodeSetCompoundRule(std::string name, CompoundTargets targets) : name_(std::move(name)) - , targets_(std::move(targets)) {} + , targets_(std::move(targets)) { } Selection materialize(const detail::NodeSets& ns, const NodePopulation& np) const final { Selection ret{{}}; @@ -727,10 +727,10 @@ Selection NodeSets::materialize(const std::string& name, const NodePopulation& p } // namespace detail NodeSets::NodeSets(const std::string& content) - : impl_(new detail::NodeSets(content)) {} + : impl_(new detail::NodeSets(content)) { } NodeSets::NodeSets(std::unique_ptr&& impl) - : impl_(std::move(impl)) {} + : impl_(std::move(impl)) { } NodeSets::NodeSets(NodeSets&&) noexcept = default; NodeSets& NodeSets::operator=(NodeSets&&) noexcept = default; diff --git a/src/nodes.cpp b/src/nodes.cpp index cb38c1b..7790548 100644 --- a/src/nodes.cpp +++ b/src/nodes.cpp @@ -92,13 +92,13 @@ Selection _filterStringAttribute(const NodePopulation& population, NodePopulation::NodePopulation(const std::string& h5FilePath, const std::string& csvFilePath, const std::string& name) - : NodePopulation(h5FilePath, csvFilePath, name, Hdf5Reader()) {} + : NodePopulation(h5FilePath, csvFilePath, name, Hdf5Reader()) { } NodePopulation::NodePopulation(const std::string& h5FilePath, const std::string& csvFilePath, const std::string& name, const Hdf5Reader& hdf5_reader) - : Population(h5FilePath, csvFilePath, name, ELEMENT, hdf5_reader) {} + : Population(h5FilePath, csvFilePath, name, ELEMENT, hdf5_reader) { } Selection NodePopulation::regexMatch(const std::string& attribute, const std::string& regex) const { std::regex re(regex); diff --git a/src/population.cpp b/src/population.cpp index 0881e29..4a84513 100644 --- a/src/population.cpp +++ b/src/population.cpp @@ -64,7 +64,7 @@ Population::Population(const std::string& h5FilePath, : impl_([h5FilePath, csvFilePath, name, prefix, hdf5_reader] { HDF5_LOCK_GUARD return new Population::Impl(h5FilePath, csvFilePath, name, prefix, hdf5_reader); - }()) {} + }()) { } Population::Population(Population&&) noexcept = default; diff --git a/src/population.hpp b/src/population.hpp index fc6b1a5..6b6842f 100644 --- a/src/population.hpp +++ b/src/population.hpp @@ -169,10 +169,10 @@ struct Population::Impl { template struct PopulationStorage::Impl { Impl(const std::string& _h5FilePath) - : Impl(_h5FilePath, Hdf5Reader()) {} + : Impl(_h5FilePath, Hdf5Reader()) { } Impl(const std::string& _h5FilePath, const Hdf5Reader& hdf5_reader) - : Impl(_h5FilePath, std::string(), hdf5_reader) {} + : Impl(_h5FilePath, std::string(), hdf5_reader) { } Impl(const std::string& _h5FilePath, const std::string& _csvFilePath, @@ -196,17 +196,17 @@ struct PopulationStorage::Impl { template PopulationStorage::PopulationStorage(const std::string& h5FilePath) - : PopulationStorage(h5FilePath, Hdf5Reader()) {} + : PopulationStorage(h5FilePath, Hdf5Reader()) { } template PopulationStorage::PopulationStorage(const std::string& h5FilePath, const Hdf5Reader& hdf5_reader) - : PopulationStorage(h5FilePath, std::string(), hdf5_reader) {} + : PopulationStorage(h5FilePath, std::string(), hdf5_reader) { } template PopulationStorage::PopulationStorage(const std::string& h5FilePath, const std::string& csvFilePath) - : PopulationStorage(h5FilePath, csvFilePath, Hdf5Reader()) {} + : PopulationStorage(h5FilePath, csvFilePath, Hdf5Reader()) { } template PopulationStorage::PopulationStorage(const std::string& h5FilePath, @@ -215,7 +215,7 @@ PopulationStorage::PopulationStorage(const std::string& h5FilePath, : impl_([h5FilePath, csvFilePath, hdf5_reader] { HDF5_LOCK_GUARD return new PopulationStorage::Impl(h5FilePath, csvFilePath, hdf5_reader); - }()) {} + }()) { } template diff --git a/src/read_canonical_selection.hpp b/src/read_canonical_selection.hpp index 8d89e3f..df76040 100644 --- a/src/read_canonical_selection.hpp +++ b/src/read_canonical_selection.hpp @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include "read_bulk.hpp" diff --git a/src/report_reader.cpp b/src/report_reader.cpp index 2cd8349..fb0fca9 100644 --- a/src/report_reader.cpp +++ b/src/report_reader.cpp @@ -98,7 +98,7 @@ namespace bbp { namespace sonata { SpikeReader::SpikeReader(std::string filename) - : filename_(std::move(filename)) {} + : filename_(std::move(filename)) { } std::vector SpikeReader::getPopulationNames() const { HighFive::File file(filename_, HighFive::File::ReadOnly); @@ -248,7 +248,7 @@ void SpikeReader::Population::filterTimestamp(Spikes& spikes, double tstart, dou template ReportReader::ReportReader(const std::string& filename) - : file_(filename, HighFive::File::ReadOnly) {} + : file_(filename, HighFive::File::ReadOnly) { } template std::vector ReportReader::getPopulationNames() const { @@ -282,9 +282,9 @@ ReportReader::Population::Population(const HighFive::File& file, // Expand the pointers into tuples that define the range of each GID size_t element_ids_count = 0; for (size_t i = 0; i < node_ids_.size(); ++i) { - node_ranges_.push_back({index_pointers[i], index_pointers[i + 1]}); // Range of GID - node_offsets_.emplace_back(element_ids_count); // Offset in output - node_index_.emplace_back(i); // Index of previous + node_ranges_.push_back({index_pointers[i], index_pointers[i + 1]}); // Range of GID + node_offsets_.emplace_back(element_ids_count); // Offset in output + node_index_.emplace_back(i); // Index of previous element_ids_count += (index_pointers[i + 1] - index_pointers[i]); }