From e8bd056d8ecdc32dfafb5dda2d0dbca5f8e6e379 Mon Sep 17 00:00:00 2001 From: Hans Dembinski Date: Tue, 31 Jul 2018 22:30:03 +0200 Subject: [PATCH] fixed all tests --- include/boost/histogram/serialization.hpp | 29 ++- .../histogram/storage/adaptive_storage.hpp | 32 ++-- src/python/histogram.cpp | 41 +++-- test/histogram_test.cpp | 170 +++++++++++------- test/python_suite_test.py | 2 +- test/speed_cpp.cpp | 19 +- 6 files changed, 186 insertions(+), 107 deletions(-) diff --git a/include/boost/histogram/serialization.hpp b/include/boost/histogram/serialization.hpp index c97ebb39..8cc92d6b 100644 --- a/include/boost/histogram/serialization.hpp +++ b/include/boost/histogram/serialization.hpp @@ -29,14 +29,28 @@ namespace histogram { namespace detail { template -struct serialize_helper { +struct serialize_t { Archive& ar_; - explicit serialize_helper(Archive& ar) : ar_(ar) {} + explicit serialize_t(Archive& ar) : ar_(ar) {} template void operator()(T& t) const { ar_& t; } }; + +struct serializer { + template + void operator()(T*, Buffer& b, Archive& ar) { + if (Archive::is_loading::value) { create(tag(), b); } + ar& boost::serialization::make_array(reinterpret_cast(b.ptr), b.size); + } + + template + void operator()(void*, Buffer& b, Archive&) { + if (Archive::is_loading::value) { b.ptr = nullptr; } + } +}; + } // namespace detail template @@ -55,8 +69,13 @@ void serialize(Archive& ar, array_storage& store, template template -void adaptive_storage::serialize(Archive&, unsigned /* version */) { - // TODO +void adaptive_storage::serialize(Archive& ar, unsigned /* version */) { + if (Archive::is_loading::value) { + detail::apply(detail::destroyer(), buffer_); + } + ar& buffer_.type; + ar& buffer_.size; + detail::apply(detail::serializer(), buffer_, ar); } namespace axis { @@ -129,7 +148,7 @@ template template void histogram::serialize(Archive& ar, unsigned /* version */) { - detail::serialize_helper sh(ar); + detail::serialize_t sh(ar); mp11::tuple_for_each(axes_, sh); ar& storage_; } diff --git a/include/boost/histogram/storage/adaptive_storage.hpp b/include/boost/histogram/storage/adaptive_storage.hpp index 648e6e2a..5fa838d7 100644 --- a/include/boost/histogram/storage/adaptive_storage.hpp +++ b/include/boost/histogram/storage/adaptive_storage.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -86,9 +87,11 @@ constexpr char type_index() { template bool safe_increase(T& t) { - if (t == std::numeric_limits::max()) return false; - ++t; - return true; + if (t < std::numeric_limits::max()) { + ++t; + return true; + } + return false; } template @@ -154,6 +157,7 @@ void create(tag, Buffer& b, const U* init = nullptr) { template void create(tag, Buffer& b, const U* init = nullptr) { + boost::ignore_unused(init); BOOST_ASSERT(!init); b.ptr = nullptr; b.type = type_index(); @@ -295,12 +299,7 @@ struct adder { struct buffer_adder { template void operator()(T* tp, const OBuffer&, Buffer& b) { - for (std::size_t i = 0; i < b.size; ++i) { - // make copy in case we are self-adding, since adder() may - // invalidate tp pointer - const T x = tp[i]; - apply(adder(), b, i, x); - } + for (std::size_t i = 0; i < b.size; ++i) { apply(adder(), b, i, tp[i]); } } template @@ -399,6 +398,7 @@ public: adaptive_storage(adaptive_storage&& o) : buffer_(std::move(o.buffer_)) { o.buffer_.type = 0; + o.buffer_.size = 0; o.buffer_.ptr = nullptr; } @@ -471,7 +471,19 @@ public: // precondition: storages have same size adaptive_storage& operator+=(const adaptive_storage& o) { BOOST_ASSERT(o.size() == size()); - detail::apply(detail::buffer_adder(), o.buffer_, buffer_); + if (this == &o) { + /* + Self-adding needs to be special-cased, because the source buffer ptr + may be invalided by growth. We avoid this by making a copy of the + source. This is a simple, but expensive solution. This is ok, because + self-adding is mostly used in the unit-tests to grow a histogram + quickly. It does not occur frequently in real applications. + */ + const auto o_copy = o; + detail::apply(detail::buffer_adder(), o_copy.buffer_, buffer_); + } else { + detail::apply(detail::buffer_adder(), o.buffer_, buffer_); + } return *this; } diff --git a/src/python/histogram.cpp b/src/python/histogram.cpp index cc0b8ad2..83f1bc26 100644 --- a/src/python/histogram.cpp +++ b/src/python/histogram.cpp @@ -40,26 +40,27 @@ class access { public: using mp_int = bh::detail::mp_int; using wcount = bh::detail::wcount; - template - using array = bh::detail::array; - struct dtype_visitor : public boost::static_visitor { + struct dtype_visitor { list &shapes, &strides; dtype_visitor(list& sh, list& st) : shapes(sh), strides(st) {} - template - str operator()(const array& /*unused*/) const { + template + str operator()(T*, const Buffer&) { strides.append(sizeof(T)); return dtype_typestr(); } - str operator()(const array& /*unused*/) const { + template + str operator()(void*, const Buffer&) { strides.append(sizeof(uint8_t)); return dtype_typestr(); } - str operator()(const array& /*unused*/) const { + template + str operator()(mp_int*, const Buffer&) { strides.append(sizeof(double)); return dtype_typestr(); } - str operator()(const array& /*unused*/) const { + template + str operator()(wcount*, const Buffer&) { strides.append(sizeof(double)); strides.append(strides[-1] * 2); shapes.append(2); @@ -67,28 +68,32 @@ public: } }; - struct data_visitor : public boost::static_visitor { + struct data_visitor { const list& shapes; const list& strides; data_visitor(const list& sh, const list& st) : shapes(sh), strides(st) {} - template - object operator()(const Array& b) const { - return make_tuple(reinterpret_cast(b.begin()), true); + template + object operator()(T* tp, const Buffer&) const { + return make_tuple(reinterpret_cast(tp), true); } - object operator()(const array& /* unused */) const { + template + object operator()(void*, const Buffer&) const { // cannot pass non-existent memory to numpy; make new // zero-initialized uint8 array, and pass it return np::zeros(tuple(shapes), np::dtype::get_builtin()); } - object operator()(const array& b) const { + template + object operator()(mp_int* tp, const Buffer& b) const { // cannot pass cpp_int to numpy; make new // double array, fill it and pass it auto a = np::empty(tuple(shapes), np::dtype::get_builtin()); - for (auto i = 0l, n = bp::len(shapes); i < n; ++i) + for (std::size_t i = 0, n = bp::len(shapes); i < n; ++i) const_cast(a.get_strides())[i] = bp::extract(strides[i]); auto* buf = (double*)a.get_data(); - for (auto i = 0ul; i < b.size; ++i) buf[i] = static_cast(b[i]); + for (std::size_t i = 0; i < b.size; ++i) { + buf[i] = static_cast(tp[i]); + } return a; } }; @@ -98,7 +103,7 @@ public: list shapes; list strides; auto& b = self.storage_.buffer_; - d["typestr"] = boost::apply_visitor(dtype_visitor(shapes, strides), b); + d["typestr"] = bh::detail::apply(dtype_visitor(shapes, strides), b); for (auto i = 0u; i < self.dim(); ++i) { if (i) strides.append(strides[-1] * shapes[-1]); shapes.append(self.axis(i).shape()); @@ -106,7 +111,7 @@ public: if (self.dim() == 0) shapes.append(0); d["shape"] = tuple(shapes); d["strides"] = tuple(strides); - d["data"] = boost::apply_visitor(data_visitor(shapes, strides), b); + d["data"] = bh::detail::apply(data_visitor(shapes, strides), b); return d; } }; diff --git a/test/histogram_test.cpp b/test/histogram_test.cpp index a2e95fe5..43d4fa2b 100644 --- a/test/histogram_test.cpp +++ b/test/histogram_test.cpp @@ -64,7 +64,7 @@ void run_tests() { // init_1 { auto h = - make_histogram(Type(), axis::regular<>{3, -1, 1}); + make_histogram>(Type(), axis::regular<>{3, -1, 1}); BOOST_TEST_EQ(h.dim(), 1); BOOST_TEST_EQ(h.size(), 5); BOOST_TEST_EQ(h.axis(0_c).shape(), 5); @@ -76,7 +76,7 @@ void run_tests() { // init_2 { - auto h = make_histogram( + auto h = make_histogram>( Type(), axis::regular<>{3, -1, 1}, axis::integer<>{-1, 2}); BOOST_TEST_EQ(h.dim(), 2); BOOST_TEST_EQ(h.size(), 25); @@ -89,7 +89,7 @@ void run_tests() { // init_3 { - auto h = make_histogram( + auto h = make_histogram>( Type(), axis::regular<>{3, -1, 1}, axis::integer<>{-1, 2}, axis::circular<>{3}); BOOST_TEST_EQ(h.dim(), 3); @@ -102,7 +102,7 @@ void run_tests() { // init_4 { - auto h = make_histogram( + auto h = make_histogram>( Type(), axis::regular<>{3, -1, 1}, axis::integer<>{-1, 2}, axis::circular<>{3}, axis::variable<>{-1, 0, 1}); BOOST_TEST_EQ(h.dim(), 4); @@ -116,7 +116,7 @@ void run_tests() { // init_5 { enum { A, B, C }; - auto h = make_histogram( + auto h = make_histogram>( Type(), axis::regular<>{3, -1, 1}, axis::integer<>{-1, 2}, axis::circular<>{3}, axis::variable<>{-1, 0, 1}, axis::category<>{{A, B, C}}); @@ -131,8 +131,8 @@ void run_tests() { // copy_ctor { - auto h = make_histogram(Type(), axis::integer<>{0, 2}, - axis::integer<>{0, 3}); + auto h = make_histogram>(Type(), axis::integer<>{0, 2}, + axis::integer<>{0, 3}); h(0, 0); auto h2 = decltype(h)(h); BOOST_TEST(h2 == h); @@ -144,8 +144,8 @@ void run_tests() { // 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(0, 0); auto h2 = decltype(h)(); BOOST_TEST_NE(h, h2); @@ -163,8 +163,8 @@ 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(0, 0); const auto href = h; decltype(h) h2(std::move(h)); @@ -185,7 +185,7 @@ void run_tests() { // axis methods { enum { A = 3, B = 5 }; - auto a = make_histogram( + auto a = make_histogram>( Type(), axis::regular<>(1, 1, 2, "foo")); BOOST_TEST_EQ(a.axis().size(), 1); BOOST_TEST_EQ(a.axis().shape(), 3); @@ -196,7 +196,8 @@ void run_tests() { a.axis().label("bar"); BOOST_TEST_EQ(a.axis().label(), "bar"); - auto b = make_histogram(Type(), axis::integer<>(1, 2)); + auto b = + make_histogram>(Type(), axis::integer<>(1, 2)); BOOST_TEST_EQ(b.axis().size(), 1); BOOST_TEST_EQ(b.axis().shape(), 3); BOOST_TEST_EQ(b.axis().index(1), 0); @@ -206,7 +207,7 @@ void run_tests() { BOOST_TEST_EQ(b.axis().label(), "foo"); auto c = - make_histogram(Type(), axis::category<>({A, B})); + make_histogram>(Type(), axis::category<>({A, B})); BOOST_TEST_EQ(c.axis().size(), 2); BOOST_TEST_EQ(c.axis().shape(), 3); BOOST_TEST_EQ(c.axis().index(A), 0); @@ -220,18 +221,20 @@ void run_tests() { // equal_compare { - auto a = make_histogram(Type(), axis::integer<>(0, 2)); - auto b = make_histogram(Type(), axis::integer<>(0, 2), - axis::integer<>(0, 3)); + auto a = + make_histogram>(Type(), axis::integer<>(0, 2)); + auto b = make_histogram>(Type(), axis::integer<>(0, 2), + axis::integer<>(0, 3)); BOOST_TEST(a != b); BOOST_TEST(b != a); - auto c = make_histogram(Type(), axis::integer<>(0, 2)); + auto c = + make_histogram>(Type(), axis::integer<>(0, 2)); BOOST_TEST(b != c); BOOST_TEST(c != b); BOOST_TEST(a == c); BOOST_TEST(c == a); auto d = - make_histogram(Type(), axis::regular<>(2, 0, 1)); + make_histogram>(Type(), axis::regular<>(2, 0, 1)); BOOST_TEST(c != d); BOOST_TEST(d != c); c(0); @@ -247,7 +250,8 @@ void run_tests() { // d1 { - auto h = make_histogram(Type(), axis::integer<>{0, 2}); + auto h = + make_histogram>(Type(), axis::integer<>{0, 2}); h(0); h(0); h(-1); @@ -266,7 +270,7 @@ void run_tests() { // d1_2 { - auto h = make_histogram( + auto h = make_histogram>( Type(), axis::integer<>(0, 2, "", axis::uoflow::off)); h(0); h(-0); @@ -284,7 +288,7 @@ void run_tests() { // d1_3 { - auto h = make_histogram( + auto h = make_histogram>( Type(), axis::category({"A", "B"})); h("A"); h("B"); @@ -302,7 +306,8 @@ void run_tests() { // d1w { - auto h = make_histogram(Type(), axis::integer<>(0, 2)); + auto h = + make_histogram>(Type(), axis::integer<>(0, 2)); h(-1); h(0); h(weight(0.5), 0); @@ -325,7 +330,7 @@ void run_tests() { // d2 { - auto h = make_histogram( + auto h = make_histogram>( Type(), axis::regular<>(2, -1, 1), axis::integer<>(-1, 2, "", axis::uoflow::off)); h(-1, -1); @@ -359,7 +364,7 @@ void run_tests() { // d2w { - auto h = make_histogram( + auto h = make_histogram>( Type(), axis::regular<>(2, -1, 1), axis::integer<>(-1, 2, "", axis::uoflow::off)); h(-1, 0); // -> 0, 1 @@ -405,9 +410,9 @@ void run_tests() { // d3w { - auto h = make_histogram(Type(), axis::integer<>(0, 3), - axis::integer<>(0, 4), - axis::integer<>(0, 5)); + auto h = make_histogram>(Type(), axis::integer<>(0, 3), + axis::integer<>(0, 4), + axis::integer<>(0, 5)); for (auto i = 0; i < h.axis(0_c).size(); ++i) { for (auto j = 0; j < h.axis(1_c).size(); ++j) { for (auto k = 0; k < h.axis(2_c).size(); ++k) { @@ -428,7 +433,8 @@ void run_tests() { // add_1 { - auto a = make_histogram(Type(), axis::integer<>(0, 2)); + auto a = + make_histogram>(Type(), axis::integer<>(0, 2)); auto b = make_histogram>(Type(), axis::integer<>(0, 2)); a(0); // 1 0 @@ -446,14 +452,17 @@ void run_tests() { BOOST_TEST_EQ(a3.at(1), 1); BOOST_TEST_EQ(a3.at(2), 0); - auto c = make_histogram(Type(), axis::integer<>(0, 3)); + auto c = + make_histogram>(Type(), axis::integer<>(0, 3)); BOOST_TEST_THROWS(c += b, std::invalid_argument); } // add_2 { - auto a = make_histogram(Type(), axis::integer<>(0, 2)); - auto b = make_histogram(Type(), axis::integer<>(0, 2)); + auto a = + make_histogram>(Type(), axis::integer<>(0, 2)); + auto b = + make_histogram>(Type(), axis::integer<>(0, 2)); a(0); BOOST_TEST_EQ(a.at(0).variance(), 1); @@ -506,7 +515,7 @@ void run_tests() { auto v = std::vector{0, 1, 2}; auto h = std::for_each( v.begin(), v.end(), - make_histogram(Type(), axis::integer<>(0, 3))); + make_histogram>(Type(), axis::integer<>(0, 3))); BOOST_TEST_EQ(h.at(0), 1); BOOST_TEST_EQ(h.at(1), 1); BOOST_TEST_EQ(h.at(2), 1); @@ -515,7 +524,8 @@ void run_tests() { // operators { - auto a = make_histogram(Type(), axis::integer<>(0, 3)); + auto a = + make_histogram>(Type(), axis::integer<>(0, 3)); auto b = a; a(0); b(1); @@ -551,7 +561,7 @@ void run_tests() { // histogram_serialization { enum { A, B, C }; - auto a = make_histogram( + auto a = make_histogram>( Type(), axis::regular<>(3, -1, 1, "r"), axis::circular<>(4, 0.0, 1.0, "p"), axis::regular(3, 1, 100, "lr"), @@ -580,7 +590,7 @@ void run_tests() { // histogram_ostream { - auto a = make_histogram( + auto a = make_histogram>( Type(), axis::regular<>(3, -1, 1, "r"), axis::integer<>(0, 2, "i")); std::ostringstream os; os << a; @@ -593,7 +603,7 @@ void run_tests() { // histogram_reset { - auto h = make_histogram( + auto h = make_histogram>( Type(), axis::integer<>(0, 2, "", axis::uoflow::off)); h(0); h(1); @@ -608,8 +618,8 @@ void run_tests() { // reduce { - auto h1 = make_histogram(Type(), axis::integer<>(0, 2), - axis::integer<>(0, 3)); + auto h1 = make_histogram>( + Type(), axis::integer<>(0, 2), axis::integer<>(0, 3)); h1(0, 0); h1(0, 1); h1(1, 0); @@ -644,9 +654,9 @@ void run_tests() { BOOST_TEST_EQ(h1_1.at(2), 1); BOOST_TEST(h1_1.axis() == h1.axis(1_c)); - auto h2 = make_histogram(Type(), axis::integer<>(0, 2), - axis::integer<>(0, 3), - axis::integer<>(0, 4)); + auto h2 = make_histogram>( + Type(), axis::integer<>(0, 2), axis::integer<>(0, 3), + axis::integer<>(0, 4)); h2(0, 0, 0); h2(0, 1, 0); h2(0, 1, 1); @@ -718,7 +728,7 @@ void run_tests() { int index(value_type s) const { return integer::index(std::atoi(s)); } }; - auto h = make_histogram(Type(), custom_axis(0, 3)); + auto h = make_histogram>(Type(), custom_axis(0, 3)); h("-10"); h("0"); h("1"); @@ -733,7 +743,8 @@ void run_tests() { // histogram iterator 1D { - auto h = make_histogram(Type(), axis::integer<>(0, 3)); + auto h = + make_histogram>(Type(), axis::integer<>(0, 3)); const auto& a = h.axis(); h(weight(2), 0); h(1); @@ -767,7 +778,7 @@ void run_tests() { // histogram iterator 2D { - auto h = make_histogram( + auto h = make_histogram>( Type(), axis::integer<>(0, 1), axis::integer<>(2, 4, "", axis::uoflow::off)); const auto& a0 = h.axis(0_c); @@ -830,7 +841,8 @@ void run_tests() { // STL compatibility { - auto h = make_histogram(Type(), axis::integer<>(0, 3)); + auto h = + make_histogram>(Type(), axis::integer<>(0, 3)); for (int i = 0; i < 3; ++i) h(i); auto a = std::vector>(); std::partial_sum(h.begin(), h.end(), std::back_inserter(a)); @@ -841,8 +853,8 @@ void run_tests() { // using STL containers { - auto h = make_histogram(Type(), axis::integer<>(0, 2), - axis::regular<>(2, 2, 4)); + auto h = make_histogram>(Type(), axis::integer<>(0, 2), + axis::regular<>(2, 2, 4)); // vector in h(std::vector({0, 2})); // pair in @@ -870,7 +882,8 @@ void run_tests() { // bin args out of range { - auto h1 = make_histogram(Type(), axis::integer<>(0, 2)); + auto h1 = + make_histogram>(Type(), axis::integer<>(0, 2)); BOOST_TEST_THROWS(h1.at(-2), std::out_of_range); BOOST_TEST_THROWS(h1.at(3), std::out_of_range); BOOST_TEST_THROWS(h1.at(std::make_tuple(-2)), std::out_of_range); @@ -880,8 +893,8 @@ void run_tests() { BOOST_TEST_THROWS(h1[std::make_tuple(-2)], std::out_of_range); BOOST_TEST_THROWS(h1[std::vector({3})], std::out_of_range); - auto h2 = make_histogram(Type(), axis::integer<>(0, 2), - axis::integer<>(0, 2)); + auto h2 = make_histogram>( + Type(), axis::integer<>(0, 2), axis::integer<>(0, 2)); BOOST_TEST_THROWS(h2.at(0, -2), std::out_of_range); BOOST_TEST_THROWS(h2.at(std::make_tuple(0, -2)), std::out_of_range); BOOST_TEST_THROWS(h2.at(std::vector({0, -2})), std::out_of_range); @@ -891,7 +904,8 @@ void run_tests() { // pass histogram to function { - auto h = make_histogram(Type(), axis::integer<>(0, 3)); + auto h = + make_histogram>(Type(), axis::integer<>(0, 3)); pass_histogram(h); } } @@ -900,23 +914,23 @@ template void run_mixed_tests() { // compare { - auto a = make_histogram(T1{}, axis::regular<>{3, 0, 3}, - axis::integer<>(0, 2)); + auto a = make_histogram>( + T1{}, axis::regular<>{3, 0, 3}, axis::integer<>(0, 2)); auto b = make_histogram>( T2{}, axis::regular<>{3, 0, 3}, axis::integer<>(0, 2)); BOOST_TEST_EQ(a, b); - auto b2 = make_histogram(T2{}, axis::integer<>{0, 3}, - axis::integer<>(0, 2)); + auto b2 = make_histogram>(T2{}, axis::integer<>{0, 3}, + axis::integer<>(0, 2)); BOOST_TEST_NE(a, b2); - auto b3 = make_histogram(T2{}, axis::regular<>(3, 0, 4), - axis::integer<>(0, 2)); + auto b3 = make_histogram>( + T2{}, axis::regular<>(3, 0, 4), axis::integer<>(0, 2)); BOOST_TEST_NE(a, b3); } // add { - auto a = make_histogram(T1{}, axis::integer<>{0, 2}); - auto b = make_histogram(T2{}, axis::integer<>{0, 2}); + auto a = make_histogram>(T1{}, axis::integer<>{0, 2}); + auto b = make_histogram>(T2{}, axis::integer<>{0, 2}); BOOST_TEST_EQ(a, b); a(0); // 1 0 b(1); // 0 1 @@ -924,14 +938,14 @@ void run_mixed_tests() { BOOST_TEST_EQ(a[0], 1); BOOST_TEST_EQ(a[1], 1); - auto c = make_histogram(T2{}, axis::integer<>{0, 3}); + auto c = make_histogram>(T2{}, axis::integer<>{0, 3}); BOOST_TEST_THROWS(a += c, std::invalid_argument); } // copy_assign { - auto a = make_histogram(T1{}, axis::regular<>{3, 0, 3}, - axis::integer<>(0, 2)); + auto a = make_histogram>( + T1{}, axis::regular<>{3, 0, 3}, axis::integer<>(0, 2)); auto b = make_histogram>( T2{}, axis::regular<>{3, 0, 3}, axis::integer<>(0, 2)); a(1, 1); @@ -942,6 +956,36 @@ void run_mixed_tests() { } int main() { + { + auto a = + make_dynamic_histogram(axis::integer<>(0, 3, "", axis::uoflow::off), + axis::integer<>(0, 2, "", axis::uoflow::off)); + a(0, 0); + double x = 1; + for (int i = 0; i < 80; ++i) { + a += a; + x += x; + } + a(1, 0); + for (int i = 0; i < 2; ++i) a(2, 0); + for (int i = 0; i < 3; ++i) a(0, 1); + for (int i = 0; i < 4; ++i) a(1, 1); + for (int i = 0; i < 5; ++i) a(2, 1); + + BOOST_TEST_EQ(a.at(0, 0), x); + BOOST_TEST_EQ(a.at(1, 0), 1); + BOOST_TEST_EQ(a.at(2, 0), 2); + BOOST_TEST_EQ(a.at(0, 1), 3); + BOOST_TEST_EQ(a.at(1, 1), 4); + BOOST_TEST_EQ(a.at(2, 1), 5); + std::cout << a.at(0, 0) << std::endl; + std::cout << a.at(1, 0) << std::endl; + std::cout << a.at(2, 0) << std::endl; + std::cout << a.at(0, 1) << std::endl; + std::cout << a.at(1, 1) << std::endl; + std::cout << a.at(2, 1) << std::endl; + } + // common interface run_tests(); run_tests(); diff --git a/test/python_suite_test.py b/test/python_suite_test.py index 35886384..88bbd429 100644 --- a/test/python_suite_test.py +++ b/test/python_suite_test.py @@ -849,7 +849,7 @@ class test_histogram(unittest.TestCase): integer(0, 2, uoflow=False)) a(0, 0) for i in range(80): - a += a + a = a + a # a now holds a multiprecision type a(1, 0) for i in range(2): diff --git a/test/speed_cpp.cpp b/test/speed_cpp.cpp index 838c6310..3dd1cc7d 100644 --- a/test/speed_cpp.cpp +++ b/test/speed_cpp.cpp @@ -136,14 +136,13 @@ int main() { compare_1d>, array_storage>>(nfill, itype)); printf("hs_sd %.3f\n", - compare_1d< - static_histogram>, adaptive_storage>>( - nfill, itype)); + compare_1d>, + adaptive_storage<>>>(nfill, itype)); printf("hd_ss %.3f\n", compare_1d>>( nfill, itype)); printf("hd_sd %.3f\n", - compare_1d>( + compare_1d>>( nfill, itype)); } @@ -160,12 +159,12 @@ int main() { printf( "hs_sd %.3f\n", compare_2d, axis::regular<>>, - adaptive_storage>>(nfill, itype)); + adaptive_storage<>>>(nfill, itype)); printf("hd_ss %.3f\n", compare_2d>>( nfill, itype)); printf("hd_sd %.3f\n", - compare_2d>( + compare_2d>>( nfill, itype)); } @@ -182,12 +181,12 @@ int main() { printf("hs_sd %.3f\n", compare_3d, axis::regular<>, axis::regular<>>, - adaptive_storage>>(nfill, itype)); + adaptive_storage<>>>(nfill, itype)); printf("hd_ss %.3f\n", compare_3d>>( nfill, itype)); printf("hd_sd %.3f\n", - compare_3d>( + compare_3d>>( nfill, itype)); } @@ -206,12 +205,12 @@ int main() { compare_6d, axis::regular<>, axis::regular<>, axis::regular<>, axis::regular<>, axis::regular<>>, - adaptive_storage>>(nfill, itype)); + adaptive_storage<>>>(nfill, itype)); printf("hd_ss %.3f\n", compare_6d>>( nfill, itype)); printf("hd_sd %.3f\n", - compare_6d>( + compare_6d>>( nfill, itype)); } }