From b650233bac6a092396cc486d248910b4de4b776e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 19:27:52 +0000 Subject: [PATCH 1/3] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-clang-format: v19.1.7 → v20.1.0](https://github.com/pre-commit/mirrors-clang-format/compare/v19.1.7...v20.1.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 904071a2b6..f484e6bd51 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -66,7 +66,7 @@ repos: # clang-format v13 # to run manually, use .github/workflows/clang-format/clang-format.sh - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v19.1.7 + rev: v20.1.0 hooks: - id: clang-format # By default, the clang-format hook configures: From 65fd71ec9459fa686caa58f66c44b0cbf37a2a75 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 19:28:02 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- examples/7_extended_write_serial.cpp | 5 +- include/openPMD/IO/IOTask.hpp | 108 +++++++++--------- include/openPMD/backend/Attribute.hpp | 11 +- include/openPMD/backend/BaseRecord.hpp | 48 ++++---- .../benchmark/mpi/MPIBenchmarkReport.hpp | 5 +- include/openPMD/binding/python/Pickle.hpp | 92 +++++++-------- include/openPMD/snapshots/ContainerTraits.hpp | 5 +- src/IO/ADIOS/ADIOS2IOHandler.cpp | 20 ++-- src/IO/FlushParams.cpp | 5 +- src/IO/HDF5/HDF5IOHandler.cpp | 6 +- src/Series.cpp | 10 +- src/backend/Attributable.cpp | 40 ++++--- src/binding/python/ChunkInfo.cpp | 33 +++--- src/binding/python/RecordComponent.cpp | 15 ++- test/CoreTest.cpp | 50 ++++---- test/ParallelIOTest.cpp | 15 ++- test/SerialIOTest.cpp | 17 +-- 17 files changed, 263 insertions(+), 222 deletions(-) diff --git a/examples/7_extended_write_serial.cpp b/examples/7_extended_write_serial.cpp index 63d9cb38ff..64972b2005 100644 --- a/examples/7_extended_write_serial.cpp +++ b/examples/7_extended_write_serial.cpp @@ -21,8 +21,9 @@ int main() f.setComment("This is fine and actually encouraged by the standard"); f.setAttribute( "custom_attribute_name", - std::string("This attribute is manually added and can contain " - "about any datatype you would want")); + std::string( + "This attribute is manually added and can contain " + "about any datatype you would want")); // note that removing attributes required by the standard typically // makes the file unusable for post-processing f.deleteAttribute("custom_attribute_name"); diff --git a/include/openPMD/IO/IOTask.hpp b/include/openPMD/IO/IOTask.hpp index 5dd3891ad8..67a6be50ab 100644 --- a/include/openPMD/IO/IOTask.hpp +++ b/include/openPMD/IO/IOTask.hpp @@ -151,8 +151,8 @@ struct OPENPMDAPI_EXPORT Parameter : public AbstractParameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -170,8 +170,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -197,8 +197,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -233,8 +233,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -250,8 +250,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -269,8 +269,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -288,8 +288,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -305,8 +305,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -324,8 +324,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -343,8 +343,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -363,8 +363,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter(Dataset const &ds) : extent(ds.extent) @@ -402,8 +402,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter(Extent e) : joinedDimension(Dataset::joinedDimension(e)) { @@ -430,8 +430,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -457,8 +457,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -476,8 +476,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; @@ -499,8 +499,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -521,8 +521,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -541,8 +541,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -572,8 +572,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -591,8 +591,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -625,8 +625,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -647,8 +647,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -679,8 +679,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -699,8 +699,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -736,8 +736,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter() = default; Parameter(Parameter &&) = default; @@ -756,8 +756,8 @@ struct OPENPMDAPI_EXPORT Parameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { Parameter(void const *ptr_in) : former_parent(ptr_in) {} @@ -796,8 +796,8 @@ struct OPENPMDAPI_EXPORT Parameter : public AbstractParameter }; template <> -struct OPENPMDAPI_EXPORT Parameter - : public AbstractParameter +struct OPENPMDAPI_EXPORT + Parameter : public AbstractParameter { explicit Parameter() = default; diff --git a/include/openPMD/backend/Attribute.hpp b/include/openPMD/backend/Attribute.hpp index e2ba7e1dd5..90ae80582b 100644 --- a/include/openPMD/backend/Attribute.hpp +++ b/include/openPMD/backend/Attribute.hpp @@ -122,9 +122,9 @@ namespace detail } else { - return { - std::runtime_error("getCast: cast from string to char only " - "possible if string has length 1.")}; + return {std::runtime_error( + "getCast: cast from string to char only " + "possible if string has length 1.")}; } } else if constexpr ( @@ -286,8 +286,9 @@ namespace detail { auto exception = std::get(conv); return {std::runtime_error( - std::string("getCast: no scalar to vector conversion " - "possible, recursive error: ") + + std::string( + "getCast: no scalar to vector conversion " + "possible, recursive error: ") + exception.what())}; } } diff --git a/include/openPMD/backend/BaseRecord.hpp b/include/openPMD/backend/BaseRecord.hpp index 87364b46f4..3eeca4d8d8 100644 --- a/include/openPMD/backend/BaseRecord.hpp +++ b/include/openPMD/backend/BaseRecord.hpp @@ -107,14 +107,16 @@ namespace internal ScalarIterator(T_BaseRecord *baseRecord) : m_baseRecordData(&baseRecord->get()) - , m_scalarTuple(std::make_pair( - RecordComponent::SCALAR, T_RecordComponent(*baseRecord))) + , m_scalarTuple( + std::make_pair( + RecordComponent::SCALAR, T_RecordComponent(*baseRecord))) , m_iterator(Right()) {} ScalarIterator(T_BaseRecord *baseRecord, Left iterator) : m_baseRecordData(&baseRecord->get()) - , m_scalarTuple(std::make_pair( - RecordComponent::SCALAR, T_RecordComponent(*baseRecord))) + , m_scalarTuple( + std::make_pair( + RecordComponent::SCALAR, T_RecordComponent(*baseRecord))) , m_iterator(std::move(iterator)) {} @@ -143,22 +145,24 @@ namespace internal : m_baseRecordData(other.m_baseRecordData) , m_scalarTuple( other.m_scalarTuple.has_value() - ? ScalarTuple(std::make_pair( - RecordComponent::SCALAR, - T_RecordComponent( - other.m_scalarTuple.value().second))) + ? ScalarTuple( + std::make_pair( + RecordComponent::SCALAR, + T_RecordComponent( + other.m_scalarTuple.value().second))) : ScalarTuple(std::nullopt)) - , m_iterator(std::visit( - auxiliary::overloaded{ - [](typename Other::Left const &left) { - // This converts the STL iterator to an - // STL const_iterator - return std::variant(left); - }, - [](typename Other::Right const &) { - return std::variant(Right()); - }}, - other.m_iterator)) + , m_iterator( + std::visit( + auxiliary::overloaded{ + [](typename Other::Left const &left) { + // This converts the STL iterator to an + // STL const_iterator + return std::variant(left); + }, + [](typename Other::Right const &) { + return std::variant(Right()); + }}, + other.m_iterator)) {} ScalarIterator &operator++() @@ -564,7 +568,8 @@ auto BaseRecord::operator[](key_type const &key) -> mapped_type & T_RecordComponent::get(); } mapped_type &ret = keyScalar ? static_cast(*this) - : T_Container::operator[](key); + : T_Container:: + operator[](key); return ret; } } @@ -606,7 +611,8 @@ auto BaseRecord::operator[](key_type &&key) -> mapped_type & T_RecordComponent::get(); } mapped_type &ret = keyScalar ? static_cast(*this) - : T_Container::operator[](std::move(key)); + : T_Container:: + operator[](std::move(key)); return ret; } } diff --git a/include/openPMD/benchmark/mpi/MPIBenchmarkReport.hpp b/include/openPMD/benchmark/mpi/MPIBenchmarkReport.hpp index 7ad18714f9..e16d4623a2 100644 --- a/include/openPMD/benchmark/mpi/MPIBenchmarkReport.hpp +++ b/include/openPMD/benchmark/mpi/MPIBenchmarkReport.hpp @@ -259,8 +259,9 @@ std::pair MPIBenchmarkReport::getReport( Datatype dt, Series::IterationIndex_t iterations) { - auto it = this->durations.find(std::make_tuple( - rank, jsonConfig, extension, threadSize, dt, iterations)); + auto it = this->durations.find( + std::make_tuple( + rank, jsonConfig, extension, threadSize, dt, iterations)); if (it == this->durations.end()) { throw std::runtime_error( diff --git a/include/openPMD/binding/python/Pickle.hpp b/include/openPMD/binding/python/Pickle.hpp index 02623dce79..43f92b1e0e 100644 --- a/include/openPMD/binding/python/Pickle.hpp +++ b/include/openPMD/binding/python/Pickle.hpp @@ -50,58 +50,60 @@ add_pickle(pybind11::class_ &cl, T_SeriesAccessor &&seriesAccessor) using PickledClass = typename std::tuple_element<0, std::tuple >::type; - cl.def(py::pickle( - // __getstate__ - [](const PickledClass &a) { - // Return a tuple that fully encodes the state of the object - Attributable::MyPath const myPath = a.myPath(); - return py::make_tuple(myPath.filePath(), myPath.group); - }, + cl.def( + py::pickle( + // __getstate__ + [](const PickledClass &a) { + // Return a tuple that fully encodes the state of the object + Attributable::MyPath const myPath = a.myPath(); + return py::make_tuple(myPath.filePath(), myPath.group); + }, - // __setstate__ - [&seriesAccessor](py::tuple const &t) { - // our tuple has exactly two elements: filePath & group - if (t.size() != 2) - throw std::runtime_error("Invalid state!"); + // __setstate__ + [&seriesAccessor](py::tuple const &t) { + // our tuple has exactly two elements: filePath & group + if (t.size() != 2) + throw std::runtime_error("Invalid state!"); - std::string const filename = t[0].cast(); - std::vector const group = - t[1].cast >(); + std::string const filename = t[0].cast(); + std::vector const group = + t[1].cast >(); - /* - * Cache the Series per thread. - */ - thread_local std::optional series; - bool re_initialize = [&]() { - try - { - return !series.has_value() || !series->operator bool() || - auxiliary::replace_all( - series->myPath().filePath(), "\\", "/") != - auxiliary::replace_all(filename, "\\", "/"); - } /* - * Better safe than sorry, if anything goes wrong because the - * Series is in a weird state, just reinitialize it. + * Cache the Series per thread. */ - catch (...) + thread_local std::optional series; + bool re_initialize = [&]() { + try + { + return !series.has_value() || + !series->operator bool() || + auxiliary::replace_all( + series->myPath().filePath(), "\\", "/") != + auxiliary::replace_all(filename, "\\", "/"); + } + /* + * Better safe than sorry, if anything goes wrong because + * the Series is in a weird state, just reinitialize it. + */ + catch (...) + { + return true; + } + }(); + if (re_initialize) { - return true; + /* + * Do NOT close the old Series, it might still be active in + * terms of handed-out handles. + */ + series = std::make_optional( + filename, + Access::READ_ONLY, + "defer_iteration_parsing = true"); } - }(); - if (re_initialize) - { - /* - * Do NOT close the old Series, it might still be active in - * terms of handed-out handles. - */ - series = std::make_optional( - filename, - Access::READ_ONLY, - "defer_iteration_parsing = true"); - } - return seriesAccessor(*series, group); - })); + return seriesAccessor(*series, group); + })); } } // namespace openPMD diff --git a/include/openPMD/snapshots/ContainerTraits.hpp b/include/openPMD/snapshots/ContainerTraits.hpp index 4bfe73b518..6a0542e5a4 100644 --- a/include/openPMD/snapshots/ContainerTraits.hpp +++ b/include/openPMD/snapshots/ContainerTraits.hpp @@ -29,8 +29,9 @@ class OpaqueSeriesIterator std::unique_ptr> m_internal_iterator; public: - OpaqueSeriesIterator(std::unique_ptr> - internal_iterator); + OpaqueSeriesIterator( + std::unique_ptr> + internal_iterator); OpaqueSeriesIterator(OpaqueSeriesIterator const &other); OpaqueSeriesIterator(OpaqueSeriesIterator &&other) noexcept; diff --git a/src/IO/ADIOS/ADIOS2IOHandler.cpp b/src/IO/ADIOS/ADIOS2IOHandler.cpp index 191729557a..472d90c636 100644 --- a/src/IO/ADIOS/ADIOS2IOHandler.cpp +++ b/src/IO/ADIOS/ADIOS2IOHandler.cpp @@ -360,8 +360,9 @@ ADIOS2IOHandlerImpl::getOperators(json::TracingJSON cfg) getCompressionOperator(type); if (adiosOperator) { - res.emplace_back(ParameterizedOperator{ - adiosOperator.value(), std::move(adiosParams)}); + res.emplace_back( + ParameterizedOperator{ + adiosOperator.value(), std::move(adiosParams)}); } } _operators.declareFullyRead(); @@ -2402,13 +2403,14 @@ ERROR: Variable ')"[1] + varName + if (allSteps) { auto allBlocks = var.AllStepsBlocksInfo(); - table.reserve(std::accumulate( - allBlocks.begin(), - allBlocks.end(), - size_t(0), - [](size_t acc, auto const &block) { - return acc + block.size(); - })); + table.reserve( + std::accumulate( + allBlocks.begin(), + allBlocks.end(), + size_t(0), + [](size_t acc, auto const &block) { + return acc + block.size(); + })); for (auto const &blocksInfo : allBlocks) { addBlocksInfo(blocksInfo); diff --git a/src/IO/FlushParams.cpp b/src/IO/FlushParams.cpp index d09018ef4f..1044b64b4b 100644 --- a/src/IO/FlushParams.cpp +++ b/src/IO/FlushParams.cpp @@ -25,7 +25,8 @@ namespace openPMD::internal { ParsedFlushParams::ParsedFlushParams(FlushParams const &flushParams) : flushLevel(flushParams.flushLevel) - , backendConfig(json::parseOptions( - flushParams.backendConfig, /* considerFiles = */ false)) + , backendConfig( + json::parseOptions( + flushParams.backendConfig, /* considerFiles = */ false)) {} } // namespace openPMD::internal diff --git a/src/IO/HDF5/HDF5IOHandler.cpp b/src/IO/HDF5/HDF5IOHandler.cpp index a66cc42703..010b66865c 100644 --- a/src/IO/HDF5/HDF5IOHandler.cpp +++ b/src/IO/HDF5/HDF5IOHandler.cpp @@ -2651,8 +2651,10 @@ void HDF5IOHandlerImpl::readAttribute( std::vector c(dims[0] * length); status = H5Aread(attr_id, attr_type, c.data()); for (hsize_t i = 0; i < dims[0]; ++i) - vs.push_back(auxiliary::strip( - std::string(c.data() + i * length, length), {'\0'})); + vs.push_back( + auxiliary::strip( + std::string(c.data() + i * length, length), + {'\0'})); } a = Attribute(vs); } diff --git a/src/Series.cpp b/src/Series.cpp index da443018e0..041fad8941 100644 --- a/src/Series.cpp +++ b/src/Series.cpp @@ -3294,8 +3294,9 @@ Series::snapshots(std::optional const snapshot_workflow) switch (usedSnapshotWorkflow) { case SnapshotWorkflow::RandomAccess: { - return Snapshots(std::shared_ptr{ - new RandomAccessIteratorContainer(series.iterations)}); + return Snapshots( + std::shared_ptr{ + new RandomAccessIteratorContainer(series.iterations)}); } case SnapshotWorkflow::Synchronous: { std::function begin; @@ -3308,8 +3309,9 @@ Series::snapshots(std::optional const snapshot_workflow) { begin = make_reading_stateful_iterator(*this, series); } - return Snapshots(std::shared_ptr( - new StatefulSnapshotsContainer(std::move(begin)))); + return Snapshots( + std::shared_ptr( + new StatefulSnapshotsContainer(std::move(begin)))); } } throw std::runtime_error("unreachable!"); diff --git a/src/backend/Attributable.cpp b/src/backend/Attributable.cpp index ade77e24d5..4fd2e7edb4 100644 --- a/src/backend/Attributable.cpp +++ b/src/backend/Attributable.cpp @@ -243,8 +243,9 @@ auto Attributable::myPath() const -> MyPath auto &seriesData = auxiliary::deref_dynamic_cast( findSeries->attributable); Series series; - series.setData(std::shared_ptr{ - &seriesData, [](auto const *) {}}); + series.setData( + std::shared_ptr{ + &seriesData, [](auto const *) {}}); res.seriesName = series.name(); res.seriesExtension = suffix(seriesData.m_format); res.directory = IOHandler()->directory; @@ -557,23 +558,24 @@ namespace internal * actual pointer and replace the old internal shared pointer by the new * one. */ - self.setData(std::shared_ptr{ - raw_ptr, - /* - * Here comes the main trick. - * The new shared pointer stores (and thus keeps alive) two items - * via lambda capture in its destructor: - * 1. The old shared pointer. - * 2. The Series. - * It's important to notice that these two items are only stored - * within the newly created handle, and not internally within the - * actual openPMD object model. This means that no reference cycles - * can occur. - */ - [s_lambda = std::move(s), - data_ptr_lambda = std::move(data_ptr)](auto const *) { - /* no-op, the lambda captures simply go out of scope */ - }}); + self.setData( + std::shared_ptr{ + raw_ptr, + /* + * Here comes the main trick. + * The new shared pointer stores (and thus keeps alive) two + * items via lambda capture in its destructor: + * 1. The old shared pointer. + * 2. The Series. + * It's important to notice that these two items are only stored + * within the newly created handle, and not internally within + * the actual openPMD object model. This means that no reference + * cycles can occur. + */ + [s_lambda = std::move(s), + data_ptr_lambda = std::move(data_ptr)](auto const *) { + /* no-op, the lambda captures simply go out of scope */ + }}); return self; } diff --git a/src/binding/python/ChunkInfo.cpp b/src/binding/python/ChunkInfo.cpp index a622c1f073..3d0837d504 100644 --- a/src/binding/python/ChunkInfo.cpp +++ b/src/binding/python/ChunkInfo.cpp @@ -55,25 +55,26 @@ void init_Chunk(py::module &m) .def_readwrite("extent", &WrittenChunkInfo::extent) .def_readwrite("source_id", &WrittenChunkInfo::sourceID) - .def(py::pickle( - // __getstate__ - [](const WrittenChunkInfo &w) { - return py::make_tuple(w.offset, w.extent, w.sourceID); - }, + .def( + py::pickle( + // __getstate__ + [](const WrittenChunkInfo &w) { + return py::make_tuple(w.offset, w.extent, w.sourceID); + }, - // __setstate__ - [](py::tuple const &t) { - // our state tuple has exactly three values - if (t.size() != 3) - throw std::runtime_error("Invalid state!"); + // __setstate__ + [](py::tuple const &t) { + // our state tuple has exactly three values + if (t.size() != 3) + throw std::runtime_error("Invalid state!"); - auto const offset = t[0].cast(); - auto const extent = t[1].cast(); - auto const sourceID = - t[2].cast(); + auto const offset = t[0].cast(); + auto const extent = t[1].cast(); + auto const sourceID = + t[2].cast(); - return WrittenChunkInfo(offset, extent, sourceID); - })); + return WrittenChunkInfo(offset, extent, sourceID); + })); py::enum_(m, "HostInfo") .value("POSIX_HOSTNAME", host_info::Method::POSIX_HOSTNAME) diff --git a/src/binding/python/RecordComponent.cpp b/src/binding/python/RecordComponent.cpp index 55fc62fc41..9fac7a8cfe 100644 --- a/src/binding/python/RecordComponent.cpp +++ b/src/binding/python/RecordComponent.cpp @@ -426,8 +426,9 @@ inline void store_chunk( if (size_t(a.ndim()) != r_shape.size()) throw py::index_error( std::string("dimension of chunk (") + std::to_string(a.ndim()) + - std::string("D) does not fit dimension of selection " - "in record component (") + + std::string( + "D) does not fit dimension of selection " + "in record component (") + std::to_string(r_shape.size()) + std::string("D)")); if (auto joined_dim = r.joinedDimension(); joined_dim.has_value()) @@ -522,8 +523,9 @@ struct PythonDynamicMemoryView DynamicMemoryView dynamicView, ShapeContainer arrayShape, ShapeContainer strides) - : m_dynamicView(std::shared_ptr( - new DynamicMemoryView(std::move(dynamicView)))) + : m_dynamicView( + std::shared_ptr( + new DynamicMemoryView(std::move(dynamicView)))) , m_arrayShape(std::move(arrayShape)) , m_strides(std::move(strides)) , m_datatype(determineDatatype()) @@ -766,8 +768,9 @@ inline void load_chunk( throw py::index_error( std::string("size of array (") + std::to_string(s_array) + std::string("; shape:") + str_array_shape + - std::string(") is smaller than size of selection " - "in record component (") + + std::string( + ") is smaller than size of selection " + "in record component (") + std::to_string(s_load) + std::string("; shape:") + str_extent_shape + std::string(")")); } diff --git a/test/CoreTest.cpp b/test/CoreTest.cpp index 0239e5bab9..92839ed131 100644 --- a/test/CoreTest.cpp +++ b/test/CoreTest.cpp @@ -869,8 +869,9 @@ TEST_CASE("wrapper_test", "[core]") // it once? value = 43.; mrc2.makeConstant(value); REQUIRE_THROWS_WITH( mrc2.makeConstant(value), - Catch::Equals("A recordComponent can not (yet) be made constant after " - "it has been written.")); + Catch::Equals( + "A recordComponent can not (yet) be made constant after " + "it has been written.")); std::array moreData = {{112233.}}; o.iterations[4].meshes["E"]["y"].loadChunkRaw(moreData.data(), {0}, {1}); o.flush(); @@ -889,8 +890,9 @@ TEST_CASE("wrapper_test", "[core]") int wrongData = 42; REQUIRE_THROWS_WITH( o.iterations[5].meshes["E"]["y"].storeChunkRaw(&wrongData, {0}, {1}), - Catch::Equals("Datatypes of chunk data (INT) and record component " - "(DOUBLE) do not match.")); + Catch::Equals( + "Datatypes of chunk data (INT) and record component " + "(DOUBLE) do not match.")); std::shared_ptr storeData = std::make_shared(44); o.iterations[5].meshes["E"]["y"].storeChunk(storeData, {0}, {1}); #if openPMD_USE_INVASIVE_TESTS @@ -1052,8 +1054,9 @@ TEST_CASE("empty_record_test", "[core]") "No assumption about contained RecordComponents will be made"); REQUIRE_THROWS_WITH( o.flush(), - Catch::Equals("A Record can not be written without any contained " - "RecordComponents: E")); + Catch::Equals( + "A Record can not be written without any contained " + "RecordComponents: E")); o.iterations[1].meshes["E"][RecordComponent::SCALAR].resetDataset( Dataset(Datatype::DOUBLE, {1})); auto B = o.iterations[1].meshes["B"]; @@ -1079,16 +1082,19 @@ TEST_CASE("no_file_ending", "[core]") { REQUIRE_THROWS_WITH( Series("./new_openpmd_output", Access::CREATE), - Catch::Equals("Unknown file format! Did you specify a file ending? " - "Specified file name was './new_openpmd_output'.")); + Catch::Equals( + "Unknown file format! Did you specify a file ending? " + "Specified file name was './new_openpmd_output'.")); REQUIRE_THROWS_WITH( Series("./new_openpmd_output_%T", Access::CREATE), - Catch::Equals("Unknown file format! Did you specify a file ending? " - "Specified file name was './new_openpmd_output_%T'.")); + Catch::Equals( + "Unknown file format! Did you specify a file ending? " + "Specified file name was './new_openpmd_output_%T'.")); REQUIRE_THROWS_WITH( Series("./new_openpmd_output_%05T", Access::CREATE), - Catch::Equals("Unknown file format! Did you specify a file ending? " - "Specified file name was './new_openpmd_output_%05T'.")); + Catch::Equals( + "Unknown file format! Did you specify a file ending? " + "Specified file name was './new_openpmd_output_%05T'.")); { Series( "../samples/no_extension_specified", @@ -1131,8 +1137,9 @@ TEST_CASE("backend_via_json", "[core]") Access::CREATE, R"({"adios2": {"engine": {"type": "file"}}})"); } - REQUIRE(auxiliary::directory_exists( - "../samples/optionsViaJsonOverwritesAutomaticDetectionFile.sst")); + REQUIRE( + auxiliary::directory_exists( + "../samples/optionsViaJsonOverwritesAutomaticDetectionFile.sst")); { /* @@ -1143,8 +1150,9 @@ TEST_CASE("backend_via_json", "[core]") Access::CREATE, R"({"adios2": {"engine": {"type": "bp4"}}})"); } - REQUIRE(auxiliary::directory_exists( - "../samples/optionsViaJsonOverwritesAutomaticDetectionBp4.sst")); + REQUIRE( + auxiliary::directory_exists( + "../samples/optionsViaJsonOverwritesAutomaticDetectionBp4.sst")); #endif std::string encodingFileBased = @@ -1186,8 +1194,9 @@ TEST_CASE("backend_via_json", "[core]") encodingGroupBased); REQUIRE(series.iterationEncoding() == IterationEncoding::groupBased); } - REQUIRE(auxiliary::file_exists( - "../samples/optionsViaJsonPseudoFilebased%T.json")); + REQUIRE( + auxiliary::file_exists( + "../samples/optionsViaJsonPseudoFilebased%T.json")); } TEST_CASE("wildcard_extension", "[core]") @@ -1445,8 +1454,9 @@ TEST_CASE("DoConvert_single_value_to_vector", "[core]") REQUIRE(attr.get>() == arrayint); REQUIRE_THROWS_WITH( (attr.get>()), - Catch::Equals("getCast: no vector to array conversion possible " - "(wrong requested array size).")); + Catch::Equals( + "getCast: no vector to array conversion possible " + "(wrong requested array size).")); REQUIRE( attr.get>() == std::vector{0, 1, 2, 3, 4, 5, 6}); diff --git a/test/ParallelIOTest.cpp b/test/ParallelIOTest.cpp index 5427b4f797..b3d93a9289 100644 --- a/test/ParallelIOTest.cpp +++ b/test/ParallelIOTest.cpp @@ -1370,10 +1370,12 @@ doshuffle = "BLOSC_BITSHUFFLE" MPI_Barrier(MPI_COMM_WORLD); // BP3 engine writes files, BP4 writes directories - REQUIRE(openPMD::auxiliary::file_exists( - "../samples/jsonConfiguredBP3Parallel.bp")); - REQUIRE(openPMD::auxiliary::directory_exists( - "../samples/jsonConfiguredBP4Parallel.bp")); + REQUIRE( + openPMD::auxiliary::file_exists( + "../samples/jsonConfiguredBP3Parallel.bp")); + REQUIRE( + openPMD::auxiliary::directory_exists( + "../samples/jsonConfiguredBP4Parallel.bp")); std::string readConfigBP3 = R"END( { @@ -1465,8 +1467,9 @@ void adios2_ssc() { auto iteration = iterations[i]; auto E_x = iteration.meshes["E"]["x"]; - E_x.resetDataset(openPMD::Dataset( - openPMD::Datatype::INT, {unsigned(local_size), extent})); + E_x.resetDataset( + openPMD::Dataset( + openPMD::Datatype::INT, {unsigned(local_size), extent})); std::vector data(extent, i); E_x.storeChunk(data, {unsigned(local_rank), 0}, {1, extent}); diff --git a/test/SerialIOTest.cpp b/test/SerialIOTest.cpp index b814eb0a9c..0fd2cf3c85 100644 --- a/test/SerialIOTest.cpp +++ b/test/SerialIOTest.cpp @@ -5059,8 +5059,9 @@ this = "should not warn" // BP3 engine writes files, BP4 writes directories REQUIRE(openPMD::auxiliary::file_exists("../samples/jsonConfiguredBP3.bp")); - REQUIRE(openPMD::auxiliary::directory_exists( - "../samples/jsonConfiguredBP4.bp")); + REQUIRE( + openPMD::auxiliary::directory_exists( + "../samples/jsonConfiguredBP4.bp")); std::string readConfigBP3 = R"END( { @@ -6796,8 +6797,9 @@ void deferred_parsing(std::string const &extension) } infix = padding.append(infix); std::ofstream file; - file.open(std::string(basename).append(infix).append(".").append( - extension)); + file.open( + std::string(basename).append(infix).append(".").append( + extension)); file.close(); } } @@ -7158,9 +7160,10 @@ TEST_CASE("late_setting_of_iterationencoding", "[serial]") REQUIRE_THROWS_WITH( series.setIterationEncoding( ::openPMD::IterationEncoding::fileBased), - Catch::Equals("Wrong API usage: For fileBased formats the " - "iteration expansion pattern %T must " - "be included in the file name")); + Catch::Equals( + "Wrong API usage: For fileBased formats the " + "iteration expansion pattern %T must " + "be included in the file name")); series.flush(); } { From ca734f1f31e16b21f14ba7c788645bdeb50a7e63 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Tue, 18 Mar 2025 10:04:56 -0700 Subject: [PATCH 3/3] More Clang-Format 20 Updates --- .github/workflows/clang-format/clang-format.sh | 4 ++-- environment.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/clang-format/clang-format.sh b/.github/workflows/clang-format/clang-format.sh index 3824f780f1..7c94700992 100755 --- a/.github/workflows/clang-format/clang-format.sh +++ b/.github/workflows/clang-format/clang-format.sh @@ -2,11 +2,11 @@ if (( $# > 0 )); then # received arguments, format those files - clang-format-18 -i "$@" + clang-format-20 -i "$@" else # received no arguments, find files on our own find include/ src/ test/ examples/ \ -regextype egrep \ -type f -regex '.*\.(hpp|cpp|hpp\.in)$' \ - | xargs clang-format-18 -i + | xargs clang-format-20 -i fi diff --git a/environment.yml b/environment.yml index 1840e99d59..0600b38727 100644 --- a/environment.yml +++ b/environment.yml @@ -3,5 +3,5 @@ name: openPMD-api-dev channels: - conda-forge dependencies: - - clang-format-18=18.1.2 + - clang-format-20=20.1.0 - bash=5