diff --git a/include/boost/histogram/detail/axes.hpp b/include/boost/histogram/detail/axes.hpp index 6e0c76b6..e591ac7f 100644 --- a/include/boost/histogram/detail/axes.hpp +++ b/include/boost/histogram/detail/axes.hpp @@ -562,10 +562,7 @@ optional_index call_impl(static_container_tag, const dynamic_axes& axes, const U& u) { dimension_check(axes, mp_size()); optional_index i; - if (axes.size() == 1) - args_to_index<0>(i, axes, u); - else - args_to_index_get(mp_size(), i, axes, u); + args_to_index_get(mp_size(), i, axes, u); return i; } @@ -574,10 +571,7 @@ optional_index call_impl(dynamic_container_tag, const dynamic_axes& axes, const U& u) { dimension_check(axes, std::distance(std::begin(u), std::end(u))); optional_index i; - if (axes.size() == 1) - args_to_index<0>(i, axes, u); - else - args_to_index_iter(i, axes, std::begin(u)); + args_to_index_iter(i, axes, std::begin(u)); return i; } diff --git a/src/python/serialization_suite.hpp b/src/python/serialization_suite.hpp index 0e632708..bde91c5e 100644 --- a/src/python/serialization_suite.hpp +++ b/src/python/serialization_suite.hpp @@ -38,14 +38,14 @@ public: std::streamsize write(const char* s, std::streamsize n) { if (len_ == 0) { *pstr_ = PyBytes_FromStringAndSize(s, n); - if (*pstr_ == 0) // no point trying to recover from allocation error - std::abort(); + if (*pstr_ == nullptr) // no point trying to recover from allocation error + std::terminate(); len_ = n; } else { if (pos_ + n > len_) { len_ = pos_ + n; if (_PyBytes_Resize(pstr_, len_) == -1) - std::abort(); // no point trying to recover from allocation error + std::terminate(); // no point trying to recover from allocation error } char* b = PyBytes_AS_STRING(*pstr_); std::copy(s, s + n, b + pos_); @@ -63,7 +63,7 @@ private: template struct serialization_suite : python::pickle_suite { static python::tuple getstate(python::object obj) { - PyObject* pobj = 0; + PyObject* pobj = nullptr; iostreams::stream os(&pobj); archive::text_oarchive oa(os); oa << python::extract(obj)(); diff --git a/test/array_storage_test.cpp b/test/array_storage_test.cpp index 13b962fa..a585c540 100644 --- a/test/array_storage_test.cpp +++ b/test/array_storage_test.cpp @@ -15,11 +15,15 @@ int main() { using namespace boost::histogram; - // ctor + // ctor and reset { array_storage a; + BOOST_TEST_EQ(a.size(), 0); + a.reset(1); + BOOST_TEST_EQ(a.size(), 1); + a.increase(0); + BOOST_TEST_EQ(a[0], 1); a.reset(1); - BOOST_TEST_EQ(a.size(), 1u); BOOST_TEST_EQ(a[0], 0); } diff --git a/test/python_suite_test.py b/test/python_suite_test.py index 88bbd429..2e3f71be 100644 --- a/test/python_suite_test.py +++ b/test/python_suite_test.py @@ -681,6 +681,13 @@ class test_histogram(unittest.TestCase): self.assertEqual(h1.axis(), integer(1, 4)) self.assertEqual([h1.at(i).value for i in range(3)], [1, 1, 1]) + with self.assertRaises(ValueError): + h.reduce_to(*range(100)) + + with self.assertRaises(ValueError): + h.reduce_to(2, 1) + + def test_pickle_0(self): a = histogram(category(0, 1, 2), integer(0, 20, label='ia'),