From 47b8a0734ddb9b3bf109f84f50656d5a002b2324 Mon Sep 17 00:00:00 2001 From: Hans Dembinski Date: Thu, 24 Jan 2019 20:53:33 +0100 Subject: [PATCH] CI fix --- examples/guide_stdlib_algorithms.cpp | 16 +++++++++------- include/boost/histogram/adaptive_storage.hpp | 4 ++-- include/boost/histogram/axis/iterator.hpp | 2 +- include/boost/histogram/indexed.hpp | 2 +- include/boost/histogram/storage_adaptor.hpp | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/examples/guide_stdlib_algorithms.cpp b/examples/guide_stdlib_algorithms.cpp index 8d2e226d..e2cba384 100644 --- a/examples/guide_stdlib_algorithms.cpp +++ b/examples/guide_stdlib_algorithms.cpp @@ -19,20 +19,22 @@ int main() { // make histogram and set all cells to 0.25, simulating a perfectly uniform PDF, // this includes underflow and overflow cells auto a = bh::make_histogram(bh::axis::regular<>(4, 1.0, 3.0)); - std::fill(a.begin(), a.end(), 0.25); // set all counters to 0.25 - // reset under- and overflow to zero + std::fill(a.begin(), a.end(), 0.25); // set all counters to 0.25, including *flow cells + // reset *flow cells to zero a.at(-1) = a.at(4) = 0; - // compute CDF, overriding histogram entries + // compute CDF, overriding cell values std::partial_sum(a.begin(), a.end(), a.begin()); + assert(a.at(-1) == 0.0); assert(a.at(0) == 0.25); assert(a.at(1) == 0.50); assert(a.at(2) == 0.75); assert(a.at(3) == 1.00); + assert(a.at(4) == 1.00); - // use any_of to check if any small elements are smaller than 0.1, - // and use indexed() to skip underflow and overflow bins + // use any_of to check if any cell values are smaller than 0.1, + // and use indexed() to skip underflow and overflow cells auto a_ind = indexed(a); const auto any_small = std::any_of(a_ind.begin(), a_ind.end(), [](const auto& x) { return *x < 0.1; }); @@ -40,11 +42,11 @@ int main() { // find maximum element const auto max_it = std::max_element(a.begin(), a.end()); - assert(*max_it == 1); + assert(max_it == a.end() - 2); // find minimum element const auto min_it = std::min_element(a.begin(), a.end()); - assert(*min_it == 0); + assert(min_it == a.begin()); // make second PDF auto b = bh::make_histogram(bh::axis::regular<>(4, 1.0, 4.0)); diff --git a/include/boost/histogram/adaptive_storage.hpp b/include/boost/histogram/adaptive_storage.hpp index 257a02b1..f1cbc761 100644 --- a/include/boost/histogram/adaptive_storage.hpp +++ b/include/boost/histogram/adaptive_storage.hpp @@ -344,8 +344,8 @@ private: template class iterator_t : public boost::iterator_adaptor, std::size_t, - Value, boost::random_access_traversal_tag, - Reference, std::ptrdiff_t> { + Value, std::random_access_iterator_tag, Reference, + std::ptrdiff_t> { public: iterator_t() = default; diff --git a/include/boost/histogram/axis/iterator.hpp b/include/boost/histogram/axis/iterator.hpp index 590c818e..b58c069b 100644 --- a/include/boost/histogram/axis/iterator.hpp +++ b/include/boost/histogram/axis/iterator.hpp @@ -20,7 +20,7 @@ template class iterator : public boost::iterator_adaptor, int, decltype(std::declval()[0]), - boost::random_access_traversal_tag, + std::random_access_iterator_tag, decltype(std::declval()[0]), int> { public: explicit iterator(const Axis& axis, int idx) diff --git a/include/boost/histogram/indexed.hpp b/include/boost/histogram/indexed.hpp index 8f58375f..e194cbff 100644 --- a/include/boost/histogram/indexed.hpp +++ b/include/boost/histogram/indexed.hpp @@ -101,7 +101,7 @@ public: class range_iterator : public boost::iterator_adaptor { + std::forward_iterator_tag, accessor> { public: accessor operator*() const noexcept { return {parent_, range_iterator::base()}; } diff --git a/include/boost/histogram/storage_adaptor.hpp b/include/boost/histogram/storage_adaptor.hpp index aedd78b0..70f22b0a 100644 --- a/include/boost/histogram/storage_adaptor.hpp +++ b/include/boost/histogram/storage_adaptor.hpp @@ -161,7 +161,7 @@ struct map_impl : T { template struct iterator_t : boost::iterator_adaptor, std::size_t, Value, - boost::random_access_traversal_tag, Reference, + std::random_access_iterator_tag, Reference, std::ptrdiff_t> { iterator_t() = default; template >