diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index 01a4b612..3ef15460 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -124,6 +124,7 @@ foreach(SRC IN ITEMS ${TEST_SOURCES}) else() if(SRC MATCHES "/([_a-zA-Z0-9]+)\\.cpp") add_executable(${CMAKE_MATCH_1} ${SRC}) + add_dependencies(${CMAKE_MATCH_1} sync_examples) target_link_libraries(${CMAKE_MATCH_1} ${LIBRARIES}) add_test(${CMAKE_MATCH_1} ${CMAKE_MATCH_1}) endif() diff --git a/doc/guide.qbk b/doc/guide.qbk index de2bd795..8028826a 100644 --- a/doc/guide.qbk +++ b/doc/guide.qbk @@ -60,7 +60,7 @@ namespace bh = boost::histogram; int main() { // create a 1d-histogram for dice throws, eyes are always between 1 and 6 - auto h = bh::make_static_histogram(bh::axis::integer(1, 6, "eyes", false)); + auto h = bh::make_static_histogram(bh::axis::integer<>(1, 6, "eyes", bh::axis::without_uoflow)); // do something with h } `` diff --git a/examples/create_dynamic_histogram.cpp b/examples/create_dynamic_histogram.cpp index de7fadfa..276ff9b0 100644 --- a/examples/create_dynamic_histogram.cpp +++ b/examples/create_dynamic_histogram.cpp @@ -26,7 +26,7 @@ int main(int argc, char** argv) { ++argi; auto b = std::atoi(argv[argi]); ++argi; - v.push_back(bh::axis::integer(a, b)); + v.push_back(bh::axis::integer<>(a, b)); } break; case 'r': { diff --git a/examples/guide_listing_3.cpp b/examples/guide_listing_3.cpp index 97c9936b..5dc2ee02 100644 --- a/examples/guide_listing_3.cpp +++ b/examples/guide_listing_3.cpp @@ -4,6 +4,6 @@ namespace bh = boost::histogram; int main() { // create a 1d-histogram for dice throws, eyes are always between 1 and 6 - auto h = bh::make_static_histogram(bh::axis::integer(1, 6, "eyes", false)); + auto h = bh::make_static_histogram(bh::axis::integer<>(1, 6, "eyes", bh::axis::without_uoflow)); // do something with h } diff --git a/examples/guide_listing_4.cpp b/examples/guide_listing_4.cpp index 6b78e7b3..02d9333b 100644 --- a/examples/guide_listing_4.cpp +++ b/examples/guide_listing_4.cpp @@ -8,7 +8,7 @@ int main() { using hist_type = bh::histogram; auto v = std::vector(); v.push_back(bh::axis::regular<>(100, -1, 1)); - v.push_back(bh::axis::integer(1, 6)); + v.push_back(bh::axis::integer<>(1, 6)); auto h = hist_type(v.begin(), v.end()); // do something with h } diff --git a/examples/guide_listing_6.cpp b/examples/guide_listing_6.cpp index 0a5a1e5b..719804da 100644 --- a/examples/guide_listing_6.cpp +++ b/examples/guide_listing_6.cpp @@ -6,7 +6,7 @@ namespace bh = boost::histogram; int main() { - auto h = bh::make_static_histogram(bh::axis::integer(0, 9)); + auto h = bh::make_static_histogram(bh::axis::integer<>(0, 9)); std::vector v{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; std::for_each(v.begin(), v.end(), [&h](int x) { h.fill(x, bh::weight(2.0)); }); // h is now filled diff --git a/include/boost/histogram/axis.hpp b/include/boost/histogram/axis.hpp index 1f0c9648..d98c16de 100644 --- a/include/boost/histogram/axis.hpp +++ b/include/boost/histogram/axis.hpp @@ -38,6 +38,11 @@ namespace boost { namespace histogram { namespace axis { +enum { + with_uoflow = true, + without_uoflow = false +}; + template struct bin { int idx; Value value; @@ -94,7 +99,7 @@ private: template class axis_base; /// Specialization with overflow/underflow bins. -template <> class axis_base { +template <> class axis_base { public: /// Returns the number of bins, excluding overflow/underflow. inline int bins() const { return size_; } @@ -150,7 +155,7 @@ private: }; /// Specialization without overflow/underflow bins. -template <> class axis_base { +template <> class axis_base { public: /// Returns the number of bins, excluding overflow/underflow. inline int bins() const { return size_; } @@ -224,7 +229,7 @@ template struct sqrt { */ template class Transform = transform::identity> -class regular : public axis_base, +class regular : public axis_base, boost::operators> { public: using value_type = RealType; @@ -240,7 +245,7 @@ public: */ regular(unsigned n, value_type min, value_type max, string_view label = string_view(), bool uoflow = true) - : axis_base(n, label, uoflow), + : axis_base(n, label, uoflow), min_(Transform::forward(min)), delta_((Transform::forward(max) - min_) / n) { if (!(min < max)) { @@ -277,7 +282,7 @@ public: } bool operator==(const regular &o) const { - return axis_base::operator==(o) && min_ == o.min_ && + return axis_base::operator==(o) && min_ == o.min_ && delta_ == o.delta_; } @@ -303,7 +308,7 @@ private: * bins for this axis. Binning is a O(1) operation. */ template -class circular : public axis_base, boost::operators> { +class circular : public axis_base, boost::operators> { public: using value_type = RealType; using const_iterator = axis_iterator; @@ -318,7 +323,7 @@ public: explicit circular(unsigned n, value_type phase = 0.0, value_type perimeter = math::double_constants::two_pi, string_view label = string_view()) - : axis_base(n, label), phase_(phase), perimeter_(perimeter) {} + : axis_base(n, label), phase_(phase), perimeter_(perimeter) {} circular() = default; circular(const circular &) = default; @@ -340,7 +345,7 @@ public: } bool operator==(const circular &o) const { - return axis_base::operator==(o) && phase_ == o.phase_ && + return axis_base::operator==(o) && phase_ == o.phase_ && perimeter_ == o.perimeter_; } @@ -364,7 +369,7 @@ private: * and the problem domain allows it, prefer a regular. */ template -class variable : public axis_base, boost::operators> { +class variable : public axis_base, boost::operators> { public: using value_type = RealType; using const_iterator = axis_iterator; @@ -377,7 +382,7 @@ public: */ variable(const std::initializer_list &x, string_view label = string_view(), bool uoflow = true) - : axis_base(x.size() - 1, label, uoflow), + : axis_base(x.size() - 1, label, uoflow), x_(new value_type[x.size()]) { if (x.size() < 2) { throw std::logic_error("at least two values required"); @@ -389,7 +394,7 @@ public: template variable(Iterator begin, Iterator end, string_view label = string_view(), bool uoflow = true) - : axis_base(std::distance(begin, end) - 1, label, uoflow), + : axis_base(std::distance(begin, end) - 1, label, uoflow), x_(new value_type[std::distance(begin, end)]) { std::copy(begin, end, x_.get()); std::sort(x_.get(), x_.get() + bins() + 1); @@ -397,12 +402,12 @@ public: variable() = default; variable(const variable &o) - : axis_base(o), x_(new value_type[bins() + 1]) { + : axis_base(o), x_(new value_type[bins() + 1]) { std::copy(o.x_.get(), o.x_.get() + bins() + 1, x_.get()); } variable &operator=(const variable &o) { if (this != &o) { - axis_base::operator=(o); + axis_base::operator=(o); x_.reset(new value_type[bins() + 1]); std::copy(o.x_.get(), o.x_.get() + bins() + 1, x_.get()); } @@ -428,7 +433,7 @@ public: } bool operator==(const variable &o) const { - if (!axis_base::operator==(o)) { + if (!axis_base::operator==(o)) { return false; } return std::equal(x_.get(), x_.get() + bins() + 1, o.x_.get()); @@ -454,9 +459,10 @@ private: * Binning is a O(1) operation. This axis operates * faster than a regular. */ -class integer : public axis_base, boost::operators { +template +class integer : public axis_base, boost::operators> { public: - using value_type = int; + using value_type = IntType; using const_iterator = axis_iterator; /** Construct axis over integer range [min, max]. @@ -466,7 +472,7 @@ public: */ integer(value_type min, value_type max, string_view label = string_view(), bool uoflow = true) - : axis_base(max + 1 - min, label, uoflow), min_(min) { + : axis_base(max + 1 - min, label, uoflow), min_(min) { if (min > max) { throw std::logic_error("min <= max required"); } @@ -488,7 +494,7 @@ public: value_type operator[](int idx) const { return min_ + idx; } bool operator==(const integer &o) const { - return axis_base::operator==(o) && min_ == o.min_; + return axis_base::operator==(o) && min_ == o.min_; } const_iterator begin() const { @@ -513,7 +519,7 @@ private: * There are no underflow/overflow bins for this axis. * Binning is a O(1) operation. */ -class category : public axis_base, boost::operators { +class category : public axis_base, boost::operators { public: using value_type = string_view; using const_iterator = axis_iterator; @@ -521,7 +527,7 @@ public: template category(Iterator begin, Iterator end, string_view label = string_view()) - : axis_base(std::distance(begin, end), label), + : axis_base(std::distance(begin, end), label), ptr_(new std::string[bins()]) { std::copy(begin, end, ptr_.get()); } @@ -541,7 +547,7 @@ public: other.label()) {} category &operator=(const category &other) { if (this != &other) { - axis_base::operator=(other); + axis_base::operator=(other); ptr_.reset(new std::string[other.bins()]); std::copy(other.ptr_.get(), other.ptr_.get() + other.bins(), ptr_.get()); } @@ -549,11 +555,11 @@ public: } category(category &&other) - : axis_base(std::move(other)), ptr_(std::move(other.ptr_)) {} + : axis_base(std::move(other)), ptr_(std::move(other.ptr_)) {} category &operator=(category &&other) { if (this != &other) { - axis_base::operator=(std::move(other)); + axis_base::operator=(std::move(other)); ptr_ = std::move(other.ptr_); } return *this; @@ -574,7 +580,7 @@ public: } bool operator==(const category &other) const { - return axis_base::operator==(other) && + return axis_base::operator==(other) && std::equal(ptr_.get(), ptr_.get() + bins(), other.ptr_.get()); } @@ -592,8 +598,8 @@ private: } // namespace axis using builtin_axes = - mpl::vector, axis::circular, - axis::variable, axis::integer, axis::category>; + mpl::vector, axis::circular<>, + axis::variable<>, axis::integer<>, axis::category>; } // namespace histogram } // namespace boost diff --git a/include/boost/histogram/axis_ostream_operators.hpp b/include/boost/histogram/axis_ostream_operators.hpp index b8c8ed3c..494ab135 100644 --- a/include/boost/histogram/axis_ostream_operators.hpp +++ b/include/boost/histogram/axis_ostream_operators.hpp @@ -64,7 +64,8 @@ inline std::ostream &operator<<(std::ostream &os, const variable &a) { return os; } -inline std::ostream &operator<<(std::ostream &os, const integer &a) { +template +inline std::ostream &operator<<(std::ostream &os, const integer &a) { os << "integer(" << a[0] << ", " << a[a.bins() - 1]; if (!a.label().empty()) { os << ", label="; diff --git a/include/boost/histogram/histogram_fwd.hpp b/include/boost/histogram/histogram_fwd.hpp index e52ba469..15a636ef 100644 --- a/include/boost/histogram/histogram_fwd.hpp +++ b/include/boost/histogram/histogram_fwd.hpp @@ -53,9 +53,9 @@ inline auto keep(mpl::int_, Rest...) -> detail::unique_sorted; -inline void insert(std::set&) {} // end recursion +inline void insert(keep_dynamic&) {} // end recursion template -inline void insert(std::set& s, First f, Rest... rest) { +inline void insert(keep_dynamic& s, First f, Rest... rest) { s.insert(static_cast(f)); insert(s, rest...); } diff --git a/include/boost/histogram/serialization.hpp b/include/boost/histogram/serialization.hpp index 71167f5a..85ec19a1 100644 --- a/include/boost/histogram/serialization.hpp +++ b/include/boost/histogram/serialization.hpp @@ -159,8 +159,9 @@ void variable::serialize(Archive &ar, unsigned /* version */) { ar &boost::serialization::make_array(x_.get(), bins() + 1); } +template template -void integer::serialize(Archive &ar, unsigned /* version */) { +void integer::serialize(Archive &ar, unsigned /* version */) { ar &boost::serialization::base_object>(*this); ar &min_; } diff --git a/src/python/axis.cpp b/src/python/axis.cpp index c0517270..d3b3cd0f 100644 --- a/src/python/axis.cpp +++ b/src/python/axis.cpp @@ -142,7 +142,7 @@ struct axis_suite : public python::def_visitor> { cl.def("__len__", axis_len, ":returns: number of bins for this axis", python::arg("self")); cl.def("__getitem__", axis_getitem, - is_same::value + is_same>::value ? ":returns: integer mapped to passed bin index" : is_same::value ? ":returns: category mapped to passed bin index" @@ -193,7 +193,7 @@ void register_axis_types() { .def(init &>()) .def(axis_suite>()); - class_("integer", + class_>("integer", "An axis for a contiguous range of integers." "\nThere are no underflow/overflow bins for this axis." "\nBinning is a O(1) operation.", @@ -201,7 +201,7 @@ void register_axis_types() { .def(init( (arg("self"), arg("min"), arg("max"), arg("label") = std::string(), arg("uoflow") = true))) - .def(axis_suite()); + .def(axis_suite>()); class_("category", "An axis for enumerated categories. The axis stores the" diff --git a/src/python/histogram.cpp b/src/python/histogram.cpp index 2cee814a..bf3a0d1c 100644 --- a/src/python/histogram.cpp +++ b/src/python/histogram.cpp @@ -200,7 +200,7 @@ python::object histogram_init(python::tuple args, python::dict kwargs) { axes.push_back(ev()); continue; } - python::extract ei(pa); + python::extract> ei(pa); if (ei.check()) { axes.push_back(ei()); continue; diff --git a/test/axis_test.cpp b/test/axis_test.cpp index 49c7f0fd..d4628292 100644 --- a/test/axis_test.cpp +++ b/test/axis_test.cpp @@ -52,7 +52,7 @@ int main() { BOOST_TEST_THROWS(axis::circular<>(0), std::logic_error); BOOST_TEST_THROWS(axis::variable<>({}), std::logic_error); BOOST_TEST_THROWS(axis::variable<>({1.0}), std::logic_error); - BOOST_TEST_THROWS(axis::integer(1, -1), std::logic_error); + BOOST_TEST_THROWS(axis::integer<>(1, -1), std::logic_error); BOOST_TEST_THROWS(axis::category({}), std::logic_error); } @@ -166,17 +166,17 @@ int main() { // axis::integer { - axis::integer a{-1, 1}; - axis::integer b; + axis::integer<> a{-1, 1}; + axis::integer<> b; BOOST_TEST_NOT(a == b); b = a; BOOST_TEST_EQ(a, b); b = b; BOOST_TEST_EQ(a, b); - axis::integer c = std::move(b); + axis::integer<> c = std::move(b); BOOST_TEST(c == a); BOOST_TEST_NOT(b == a); - axis::integer d; + axis::integer<> d; BOOST_TEST_NOT(c == d); d = std::move(c); BOOST_TEST_EQ(d, a); @@ -217,8 +217,8 @@ int main() { test_real_axis_iterator(axis::circular<>(5, 0, 1, ""), 0, 5); test_real_axis_iterator(axis::variable<>({1, 2, 3}, "", false), 0, 2); test_real_axis_iterator(axis::variable<>({1, 2, 3}, "", true), -1, 3); - test_axis_iterator(axis::integer(0, 4, "", false), 0, 5); - test_axis_iterator(axis::integer(0, 4, "", true), -1, 6); + test_axis_iterator(axis::integer<>(0, 4, "", false), 0, 5); + test_axis_iterator(axis::integer<>(0, 4, "", true), -1, 6); test_axis_iterator(axis::category({"A", "B", "C"}), 0, 3); } @@ -252,7 +252,7 @@ int main() { axes.push_back(axis::circular<>{4, 0.1, 1.0, "polar"}); axes.push_back(axis::variable<>{{-1, 0, 1}, "variable", false}); axes.push_back(axis::category{{"A", "B", "C"}, "category"}); - axes.push_back(axis::integer{-1, 1, "integer", false}); + axes.push_back(axis::integer<>{-1, 1, "integer", false}); std::ostringstream os; for (const auto &a : axes) { os << a; @@ -272,7 +272,7 @@ int main() { axes.push_back(axis::circular<>{4}); axes.push_back(axis::variable<>{-1, 0, 1}); axes.push_back(axis::category{"A", "B", "C"}); - axes.push_back(axis::integer{-1, 1}); + axes.push_back(axis::integer<>{-1, 1}); for (const auto &a : axes) { BOOST_TEST(!(a == axis_t())); BOOST_TEST_EQ(a, a); @@ -284,7 +284,7 @@ int main() { // sequence equality { std::vector, axis::variable<>, - axis::category, axis::integer>> + axis::category, axis::integer<>>> std_vector1 = {axis::regular<>{2, -1, 1}, axis::variable<>{-1, 0, 1}, axis::category{"A", "B", "C"}}; @@ -324,7 +324,7 @@ int main() { // sequence assign { std::vector, axis::variable<>, - axis::category, axis::integer>> + axis::category, axis::integer<>>> std_vector1 = {axis::regular<>{2, -1, 1}, axis::variable<>{-1, 0, 1}, axis::category{"A", "B", "C"}}; diff --git a/test/histogram_test.cpp b/test/histogram_test.cpp index 2ca675ac..16f7176a 100644 --- a/test/histogram_test.cpp +++ b/test/histogram_test.cpp @@ -50,10 +50,10 @@ template void run_tests() { // init_0 { auto h = - histogram, adaptive_storage<>>(); + histogram>, adaptive_storage<>>(); BOOST_TEST_EQ(h.dim(), 1); BOOST_TEST_EQ(h.size(), 0); - auto h2 = histogram, + auto h2 = histogram>, array_storage>(); BOOST_TEST(h2 == h); auto h3 = @@ -77,25 +77,25 @@ template void run_tests() { // init_2 { auto h = make_histogram>( - Type(), axis::regular<>{3, -1, 1}, axis::integer{-1, 1}); + Type(), axis::regular<>{3, -1, 1}, axis::integer<>{-1, 1}); BOOST_TEST_EQ(h.dim(), 2); BOOST_TEST_EQ(h.size(), 25); BOOST_TEST_EQ(shape(h.axis(0_c)), 5); BOOST_TEST_EQ(shape(h.axis(1_c)), 5); auto h2 = make_histogram>( - Type(), axis::regular<>{3, -1, 1}, axis::integer{-1, 1}); + Type(), axis::regular<>{3, -1, 1}, axis::integer<>{-1, 1}); BOOST_TEST(h2 == h); } // init_3 { auto h = make_histogram>( - Type(), axis::regular<>{3, -1, 1}, axis::integer{-1, 1}, + Type(), axis::regular<>{3, -1, 1}, axis::integer<>{-1, 1}, axis::circular<>{3}); BOOST_TEST_EQ(h.dim(), 3); BOOST_TEST_EQ(h.size(), 75); auto h2 = make_histogram>( - Type(), axis::regular<>{3, -1, 1}, axis::integer{-1, 1}, + Type(), axis::regular<>{3, -1, 1}, axis::integer<>{-1, 1}, axis::circular<>{3}); BOOST_TEST(h2 == h); } @@ -103,12 +103,12 @@ template void run_tests() { // init_4 { auto h = make_histogram>( - Type(), axis::regular<>{3, -1, 1}, axis::integer{-1, 1}, + Type(), axis::regular<>{3, -1, 1}, axis::integer<>{-1, 1}, axis::circular<>{3}, axis::variable<>{-1, 0, 1}); BOOST_TEST_EQ(h.dim(), 4); BOOST_TEST_EQ(h.size(), 300); auto h2 = make_histogram>( - Type(), axis::regular<>{3, -1, 1}, axis::integer{-1, 1}, + Type(), axis::regular<>{3, -1, 1}, axis::integer<>{-1, 1}, axis::circular<>{3}, axis::variable<>{-1, 0, 1}); BOOST_TEST(h2 == h); } @@ -116,13 +116,13 @@ template void run_tests() { // init_5 { auto h = make_histogram>( - Type(), axis::regular<>{3, -1, 1}, axis::integer{-1, 1}, + Type(), axis::regular<>{3, -1, 1}, axis::integer<>{-1, 1}, axis::circular<>{3}, axis::variable<>{-1, 0, 1}, axis::category{"A", "B", "C"}); BOOST_TEST_EQ(h.dim(), 5); BOOST_TEST_EQ(h.size(), 900); auto h2 = make_histogram>( - Type(), axis::regular<>{3, -1, 1}, axis::integer{-1, 1}, + Type(), axis::regular<>{3, -1, 1}, axis::integer<>{-1, 1}, axis::circular<>{3}, axis::variable<>{-1, 0, 1}, axis::category{"A", "B", "C"}); BOOST_TEST(h2 == h); @@ -130,20 +130,20 @@ template void run_tests() { // copy_ctor { - auto h = make_histogram>(Type(), axis::integer(0, 1), - axis::integer(0, 2)); + auto h = make_histogram>(Type(), axis::integer<>(0, 1), + axis::integer<>(0, 2)); h.fill(0, 0); auto h2 = decltype(h)(h); BOOST_TEST(h2 == h); - auto h3 = histogram, + auto h3 = histogram, axis::integer<>>, array_storage>(h); BOOST_TEST(h3 == h); } // copy_assign { - auto h = make_histogram>(Type(), axis::integer(0, 1), - axis::integer(0, 2)); + auto h = make_histogram>(Type(), axis::integer<>(0, 1), + axis::integer<>(0, 2)); h.fill(0, 0); auto h2 = decltype(h)(); BOOST_TEST(h != h2); @@ -152,7 +152,7 @@ template void run_tests() { // test self-assign h2 = h2; BOOST_TEST(h == h2); - auto h3 = histogram, + auto h3 = histogram, axis::integer<>>, array_storage>(); h3 = h; BOOST_TEST(h == h3); @@ -160,8 +160,8 @@ template void run_tests() { // move { - auto h = make_histogram>(Type(), axis::integer(0, 1), - axis::integer(0, 2)); + auto h = make_histogram>(Type(), axis::integer<>(0, 1), + axis::integer<>(0, 2)); h.fill(0, 0); const auto href = h; decltype(h) h2(std::move(h)); @@ -190,7 +190,7 @@ template void run_tests() { BOOST_TEST_EQ(right(a.axis(), 0), 2.0); BOOST_TEST_EQ(center(a.axis(), 0), 1.5); - auto b = make_histogram>(Type(), axis::integer(1, 2)); + auto b = make_histogram>(Type(), axis::integer<>(1, 2)); BOOST_TEST_EQ(bins(a.axis()), 1); BOOST_TEST_EQ(shape(a.axis()), 3); BOOST_TEST_EQ(index(a.axis(), 1.0), 0); @@ -201,12 +201,12 @@ template void run_tests() { // equal_compare { - auto a = make_histogram>(Type(), axis::integer(0, 1)); - auto b = make_histogram>(Type(), axis::integer(0, 1), - axis::integer(0, 2)); + auto a = make_histogram>(Type(), axis::integer<>(0, 1)); + auto b = make_histogram>(Type(), axis::integer<>(0, 1), + axis::integer<>(0, 2)); BOOST_TEST(a != b); BOOST_TEST(b != a); - auto c = make_histogram>(Type(), axis::integer(0, 1)); + auto c = make_histogram>(Type(), axis::integer<>(0, 1)); BOOST_TEST(b != c); BOOST_TEST(c != b); BOOST_TEST(a == c); @@ -228,7 +228,7 @@ template void run_tests() { // d1 { - auto h = make_histogram>(Type(), axis::integer(0, 1)); + auto h = make_histogram>(Type(), axis::integer<>(0, 1)); h.fill(0); h.fill(0); h.fill(-1); @@ -257,7 +257,7 @@ template void run_tests() { // d1_2 { auto h = make_histogram>(Type(), - axis::integer(0, 1, "", false)); + axis::integer<>(0, 1, "", false)); h.fill(0); h.fill(-0); h.fill(-1); @@ -323,7 +323,7 @@ template void run_tests() { // d2 { auto h = make_histogram>( - Type(), axis::regular<>(2, -1, 1), axis::integer(-1, 1, "", false)); + Type(), axis::regular<>(2, -1, 1), axis::integer<>(-1, 1, "", false)); h.fill(-1, -1); h.fill(-1, 0); h.fill(-1, -10); @@ -372,7 +372,7 @@ template void run_tests() { // d2w { auto h = make_histogram>( - Type(), axis::regular<>(2, -1, 1), axis::integer(-1, 1, "", false)); + Type(), axis::regular<>(2, -1, 1), axis::integer<>(-1, 1, "", false)); h.fill(-1, 0); // -> 0, 1 h.fill(weight(10), -1, -1); // -> 0, 0 h.fill(weight(5), -1, -10); // is ignored @@ -416,7 +416,7 @@ template void run_tests() { // d3w { auto h = make_histogram>( - Type(), axis::integer(0, 3), axis::integer(0, 4), axis::integer(0, 5)); + Type(), axis::integer<>(0, 3), axis::integer<>(0, 4), axis::integer<>(0, 5)); for (auto i = 0; i < bins(h.axis(0_c)); ++i) { for (auto j = 0; j < bins(h.axis(1_c)); ++j) { for (auto k = 0; k < bins(h.axis(2_c)); ++k) { @@ -436,9 +436,9 @@ template void run_tests() { // add_1 { - auto a = make_histogram>(Type(), axis::integer(-1, 1)); + auto a = make_histogram>(Type(), axis::integer<>(-1, 1)); auto b = - make_histogram>(Type(), axis::integer(-1, 1)); + make_histogram>(Type(), axis::integer<>(-1, 1)); a.fill(-1); b.fill(1); auto c = a; @@ -459,8 +459,8 @@ template void run_tests() { // add_2 { - auto a = make_histogram>(Type(), axis::integer(0, 1)); - auto b = make_histogram>(Type(), axis::integer(0, 1)); + auto a = make_histogram>(Type(), axis::integer<>(0, 1)); + auto b = make_histogram>(Type(), axis::integer<>(0, 1)); a.fill(0); BOOST_TEST_EQ(a.variance(0), 1); @@ -486,9 +486,9 @@ template void run_tests() { // add_3 { - auto a = make_histogram>(Type(), axis::integer(-1, 1)); + auto a = make_histogram>(Type(), axis::integer<>(-1, 1)); auto b = - make_histogram>(Type(), axis::integer(-1, 1)); + make_histogram>(Type(), axis::integer<>(-1, 1)); a.fill(-1); b.fill(1); auto c = a; @@ -509,14 +509,14 @@ template void run_tests() { // bad_add { - auto a = make_histogram>(Type(), axis::integer(0, 1)); - auto b = make_histogram>(Type(), axis::integer(0, 2)); + auto a = make_histogram>(Type(), axis::integer<>(0, 1)); + auto b = make_histogram>(Type(), axis::integer<>(0, 2)); BOOST_TEST_THROWS(a += b, std::logic_error); } // bad_index { - auto a = make_histogram>(Type(), axis::integer(0, 1)); + auto a = make_histogram>(Type(), axis::integer<>(0, 1)); BOOST_TEST_THROWS(a.value(5), std::out_of_range); BOOST_TEST_THROWS(a.variance(5), std::out_of_range); } @@ -524,7 +524,7 @@ template void run_tests() { // functional programming { auto v = std::vector{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - auto h = make_histogram>(Type(), axis::integer(0, 9)); + auto h = make_histogram>(Type(), axis::integer<>(0, 9)); std::for_each(v.begin(), v.end(), [&h](int x) { h.fill(weight(2.0), x); }); BOOST_TEST_EQ(h.sum(), 20.0); } @@ -536,7 +536,7 @@ template void run_tests() { axis::circular<>(4, 0.0, 1.0, "p"), axis::regular(3, 1, 100, "lr"), axis::variable<>({0.1, 0.2, 0.3, 0.4, 0.5}, "v"), - axis::category{"A", "B", "C"}, axis::integer(0, 1, "i")); + axis::category{"A", "B", "C"}, axis::integer<>(0, 1, "i")); a.fill(0.5, 20, 0.1, 0.25, 1, 0); std::string buf; { @@ -558,7 +558,7 @@ template void run_tests() { // histogram_ostream { auto a = make_histogram>( - Type(), axis::regular<>(3, -1, 1, "r"), axis::integer(0, 1, "i")); + Type(), axis::regular<>(3, -1, 1, "r"), axis::integer<>(0, 1, "i")); std::ostringstream os; os << a; BOOST_TEST_EQ(os.str(), "histogram(" @@ -570,7 +570,7 @@ template void run_tests() { // histogram_reset { auto a = make_histogram>(Type(), - axis::integer(0, 1, "", false)); + axis::integer<>(0, 1, "", false)); a.fill(0); a.fill(1); BOOST_TEST_EQ(a.value(0), 1); @@ -582,8 +582,8 @@ template void run_tests() { // reduce { - auto h1 = make_histogram>(Type(), axis::integer(0, 1), - axis::integer(0, 2)); + auto h1 = make_histogram>(Type(), axis::integer<>(0, 1), + axis::integer<>(0, 2)); h1.fill(0, 0); h1.fill(0, 1); h1.fill(1, 0); @@ -608,7 +608,7 @@ template void run_tests() { BOOST_TEST(axis_equal(Type(), h1_1.axis(), h1.axis(1_c))); auto h2 = make_histogram>( - Type(), axis::integer(0, 1), axis::integer(0, 2), axis::integer(0, 3)); + Type(), axis::integer<>(0, 1), axis::integer<>(0, 2), axis::integer<>(0, 3)); h2.fill(0, 0, 0); h2.fill(0, 1, 0); h2.fill(0, 1, 1); @@ -620,14 +620,14 @@ template void run_tests() { BOOST_TEST_EQ(h2_0.sum(), 5); BOOST_TEST_EQ(h2_0.value(0), 4); BOOST_TEST_EQ(h2_0.value(1), 1); - BOOST_TEST(axis_equal(Type(), h2_0.axis(), axis::integer(0, 1))); + BOOST_TEST(axis_equal(Type(), h2_0.axis(), axis::integer<>(0, 1))); auto h2_1 = reduce(h2, keep(1_c)); BOOST_TEST_EQ(h2_1.dim(), 1); BOOST_TEST_EQ(h2_1.sum(), 5); BOOST_TEST_EQ(h2_1.value(0), 3); BOOST_TEST_EQ(h2_1.value(1), 2); - BOOST_TEST(axis_equal(Type(), h2_1.axis(), axis::integer(0, 2))); + BOOST_TEST(axis_equal(Type(), h2_1.axis(), axis::integer<>(0, 2))); auto h2_2 = reduce(h2, keep(2_c)); BOOST_TEST_EQ(h2_2.dim(), 1); @@ -635,7 +635,7 @@ template void run_tests() { BOOST_TEST_EQ(h2_2.value(0), 2); BOOST_TEST_EQ(h2_2.value(1), 1); BOOST_TEST_EQ(h2_2.value(2), 2); - BOOST_TEST(axis_equal(Type(), h2_2.axis(), axis::integer(0, 3))); + BOOST_TEST(axis_equal(Type(), h2_2.axis(), axis::integer<>(0, 3))); auto h2_01 = reduce(h2, keep(0_c, 1_c)); BOOST_TEST_EQ(h2_01.dim(), 2); @@ -643,8 +643,8 @@ template void run_tests() { BOOST_TEST_EQ(h2_01.value(0, 0), 2); BOOST_TEST_EQ(h2_01.value(0, 1), 2); BOOST_TEST_EQ(h2_01.value(1, 0), 1); - BOOST_TEST(axis_equal(Type(), h2_01.axis(0_c), axis::integer(0, 1))); - BOOST_TEST(axis_equal(Type(), h2_01.axis(1_c), axis::integer(0, 2))); + BOOST_TEST(axis_equal(Type(), h2_01.axis(0_c), axis::integer<>(0, 1))); + BOOST_TEST(axis_equal(Type(), h2_01.axis(1_c), axis::integer<>(0, 2))); auto h2_02 = reduce(h2, keep(0_c, 2_c)); BOOST_TEST_EQ(h2_02.dim(), 2); @@ -653,8 +653,8 @@ template void run_tests() { BOOST_TEST_EQ(h2_02.value(0, 1), 1); BOOST_TEST_EQ(h2_02.value(0, 2), 1); BOOST_TEST_EQ(h2_02.value(1, 2), 1); - BOOST_TEST(axis_equal(Type(), h2_02.axis(0_c), axis::integer(0, 1))); - BOOST_TEST(axis_equal(Type(), h2_02.axis(1_c), axis::integer(0, 3))); + BOOST_TEST(axis_equal(Type(), h2_02.axis(0_c), axis::integer<>(0, 1))); + BOOST_TEST(axis_equal(Type(), h2_02.axis(1_c), axis::integer<>(0, 3))); auto h2_12 = reduce(h2, keep(1_c, 2_c)); BOOST_TEST_EQ(h2_12.dim(), 2); @@ -663,8 +663,8 @@ template void run_tests() { BOOST_TEST_EQ(h2_12.value(1, 0), 1); BOOST_TEST_EQ(h2_12.value(1, 1), 1); BOOST_TEST_EQ(h2_12.value(0, 2), 2); - BOOST_TEST(axis_equal(Type(), h2_12.axis(0_c), axis::integer(0, 2))); - BOOST_TEST(axis_equal(Type(), h2_12.axis(1_c), axis::integer(0, 3))); + BOOST_TEST(axis_equal(Type(), h2_12.axis(0_c), axis::integer<>(0, 2))); + BOOST_TEST(axis_equal(Type(), h2_12.axis(1_c), axis::integer<>(0, 3))); } } @@ -673,24 +673,24 @@ template void run_mixed_tests() { // compare { auto a = make_histogram>(T1{}, axis::regular<>{3, 0, 3}, - axis::integer(0, 1)); + axis::integer<>(0, 1)); auto b = make_histogram>(T2{}, axis::regular<>{3, 0, 3}, - axis::integer(0, 1)); + axis::integer<>(0, 1)); BOOST_TEST_EQ(a, b); - auto b2 = make_histogram>(T2{}, axis::integer{0, 3}, - axis::integer(0, 1)); + auto b2 = make_histogram>(T2{}, axis::integer<>{0, 3}, + axis::integer<>(0, 1)); BOOST_TEST_NE(a, b2); auto b3 = make_histogram>(T2{}, axis::regular<>(3, 0, 4), - axis::integer(0, 1)); + axis::integer<>(0, 1)); BOOST_TEST_NE(a, b3); } // copy_assign { auto a = make_histogram>(T1{}, axis::regular<>{3, 0, 3}, - axis::integer(0, 1)); + axis::integer<>(0, 1)); auto b = make_histogram>(T2{}, axis::regular<>{3, 0, 3}, - axis::integer(0, 1)); + axis::integer<>(0, 1)); a.fill(1, 1); BOOST_TEST_NE(a, b); b = a; @@ -710,7 +710,7 @@ int main() { { auto v = std::vector::axis_type>(); v.push_back(axis::regular<>(100, -1, 1)); - v.push_back(axis::integer(1, 6)); + v.push_back(axis::integer<>(1, 6)); auto h = histogram(v.begin(), v.end()); BOOST_TEST_EQ(h.axis(0_c), v[0]); BOOST_TEST_EQ(h.axis(1_c), v[1]); @@ -728,8 +728,8 @@ int main() { // reduce { - auto h1 = make_dynamic_histogram(axis::integer(0, 1), - axis::integer(0, 2)); + auto h1 = make_dynamic_histogram(axis::integer<>(0, 1), + axis::integer<>(0, 2)); h1.fill(0, 0); h1.fill(0, 1); h1.fill(1, 0);