diff --git a/README.md b/README.md index c648dedf..446c9746 100644 --- a/README.md +++ b/README.md @@ -71,15 +71,15 @@ Example 1: Fill a 1d-histogram in C++ auto h = bh::make_static_histogram(bh::regular_axis(10, -1.0, 2.0, "x")); // fill histogram with data - h.increment(-1.5); // put in underflow bin - h.increment(-1.0); // included in first bin, bin interval is semi-open - h.increment(-0.5); - h.increment(1.1); - h.increment(0.3); - h.increment(1.7); - h.increment(2.0); // put in overflow bin, bin interval is semi-open - h.increment(20.0); // put in overflow bin - h.wincrement(0.1, 5.0); // fill with a weighted entry, weight is 5.0 + h.fill(-1.5); // put in underflow bin + h.fill(-1.0); // included in first bin, bin interval is semi-open + h.fill(-0.5); + h.fill(1.1); + h.fill(0.3); + h.fill(1.7); + h.fill(2.0); // put in overflow bin, bin interval is semi-open + h.fill(20.0); // put in overflow bin + h.wfill(0.1, 5.0); // fill with a weighted entry, weight is 5.0 // access histogram counts, loop includes under- and overflow bin const auto& a = h.axis<0>(); @@ -132,7 +132,7 @@ Example 2: Fill a 2d-histogram in Python with data in Numpy arrays rphi[:, 1] = np.arctan2(y, x) # compute phi # fill histogram with numpy array - h.increment(rphi) + h.fill(rphi) # access histogram counts (no copy) count_matrix = np.asarray(h) diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index 895ec418..4b2624f1 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -78,27 +78,27 @@ endif() # checks if(BUILD_CHECKS) add_executable(speed_cpp_hs_ss - ../test/check/speed_cpp.cpp) + ../test/speed_cpp.cpp) target_link_libraries(speed_cpp_hs_ss ${LIBRARIES}) target_compile_definitions(speed_cpp_hs_ss PUBLIC HISTOGRAM_TYPE=1) add_executable(speed_cpp_hs_sd - ../test/check/speed_cpp.cpp) + ../test/speed_cpp.cpp) target_link_libraries(speed_cpp_hs_sd ${LIBRARIES}) target_compile_definitions(speed_cpp_hs_sd PUBLIC HISTOGRAM_TYPE=2) add_executable(speed_cpp_hd_ss - ../test/check/speed_cpp.cpp) + ../test/speed_cpp.cpp) target_link_libraries(speed_cpp_hd_ss ${LIBRARIES}) target_compile_definitions(speed_cpp_hd_ss PUBLIC HISTOGRAM_TYPE=3) add_executable(speed_cpp_hd_sd - ../test/check/speed_cpp.cpp) + ../test/speed_cpp.cpp) target_link_libraries(speed_cpp_hd_sd ${LIBRARIES}) target_compile_definitions(speed_cpp_hd_sd PUBLIC HISTOGRAM_TYPE=4) add_executable(axis_size - ../test/check/axis_size.cpp) + ../test/axis_size.cpp) endif() # tests diff --git a/doc/rationale.qbk b/doc/rationale.qbk index 96e5a07b..3e9c5c04 100644 --- a/doc/rationale.qbk +++ b/doc/rationale.qbk @@ -21,7 +21,7 @@ Properties Getter/setter-like functions are wrapped as properties. Keyword-based parameters - C++ member functions :cpp:func:`histogram::fill` and :cpp:func:`histogram::wfill` are wrapped by the single Python member function :py:func:`histogram.increment` with an optional keyword parameter `w` to pass a weight. + C++ member functions :cpp:func:`histogram::fill` and :cpp:func:`histogram::wfill` are wrapped by the single Python member function :py:func:`histogram.fill` with an optional keyword parameter `w` to pass a weight. [endsect] diff --git a/doc/tutorial.qbk b/doc/tutorial.qbk index c3eba018..80734f76 100644 --- a/doc/tutorial.qbk +++ b/doc/tutorial.qbk @@ -3,94 +3,113 @@ [section Example 1: 1d-histogram in C++] How to make a 1d-histogram in C++ and to fill it: -[c++] -`` - #include - #include +[c++] +``` + #include // proposed for inclusion in Boost + #include // proposed for inclusion in Boost + #include // proposed for inclusion in Boost #include #include int main(int, char**) { namespace bh = boost::histogram; - /* Create a 1-d histogram with an axis that has 10 bins - * of equal width, covering the real line in the interval - * [-1.0, 2.0), label it 'x'. - * Several other binning strategies are supported, see - * documentation of axis_types. - */ - bh::histogram h(bh::regular_axis(10, -1.0, 2.0, "x")); + // create 1d-histogram with 10 equidistant bins from -1.0 to 2.0, + // with axis of histogram labeled as "x" + auto h = bh::make_static_histogram(bh::regular_axis(10, -1.0, 2.0, "x")); - /* Fill histogram with a few entries. Values outside of - * axis are placed in the overflow and underflow bins. - * Normally you would loop over a source of values. - */ - h.increment(-1.5); // put in underflow bin - h.increment(-0.5); - h.increment(1.1); - h.increment(-1.0); // included, interval is semi-open - h.increment(0.3); - h.increment(1.7); - h.increment(2.0); // put in overflow bin, interval is semi-open - h.increment(20.0); // put in overflow bin + // fill histogram with data + h.fill(-1.5); // put in underflow bin + h.fill(-1.0); // included in first bin, bin interval is semi-open + h.fill(-0.5); + h.fill(1.1); + h.fill(0.3); + h.fill(1.7); + h.fill(2.0); // put in overflow bin, bin interval is semi-open + h.fill(20.0); // put in overflow bin + h.wfill(0.1, 5.0); // fill with a weighted entry, weight is 5.0 - /* Fill histogram with a weighted count. This increases the - * bin counter not by one, but by the specified weight. - * - * This call transparently causes histogram to change it memory - * layout to store counts as doubles instead of integers. The - * layout for weighted counts requires up to 16x more memory - * and will cause inaccuracies of the type a + 1 == a if a is - * sufficiently large. - * - * Use wfill(...) if you have to, else prefer fill(...). - */ - h.wincrement(0.1, 5.0); - - /* Print a table representation of the histogram showing the bin - * value and a estimate of the standard deviation. Overflow and - * Underflow bins are accessed naturally as the bins -1 and 10. - */ - for (int i = -1; i <= h.bins(0); ++i) { - const bh::regular_axis& a = h.axis(0); + // access histogram counts, loop includes under- and overflow bin + const auto& a = h.axis<0>(); + for (int i = -1, n = bh::bins(a) + 1; i < n; ++i) { std::cout << "bin " << i - << " x in [" << a[i] << ", " << a[i+1] << "): " + << " x in [" << bh::left(a, i) << ", " << bh::right(a, i) << "): " << h.value(i) << " +/- " << std::sqrt(h.variance(i)) << std::endl; } + + /* program output: + + bin -1 x in [-inf, -1): 1 +/- 1 + bin 0 x in [-1, -0.7): 1 +/- 1 + bin 1 x in [-0.7, -0.4): 1 +/- 1 + bin 2 x in [-0.4, -0.1): 0 +/- 0 + bin 3 x in [-0.1, 0.2): 5 +/- 5 + bin 4 x in [0.2, 0.5): 1 +/- 1 + bin 5 x in [0.5, 0.8): 0 +/- 0 + bin 6 x in [0.8, 1.1): 0 +/- 0 + bin 7 x in [1.1, 1.4): 1 +/- 1 + bin 8 x in [1.4, 1.7): 0 +/- 0 + bin 9 x in [1.7, 2): 1 +/- 1 + bin 10 x in [2, inf): 2 +/- 1.41421 + */ } +``` -`` +Example 2: Fill a 2d-histogram in Python with data in Numpy arrays -The program output is: +[python] +``` + import histogram as bh + import numpy as np -[teletype] + # create 2d-histogram over polar coordinates, with + # 10 equidistant bins in radius from 0 to 5 and + # 4 equidistant bins in polar angle + h = bh.histogram(bh.regular_axis(10, 0.0, 5.0, "radius", + uoflow=False), + bh.polar_axis(4, 0.0, "phi")) -`` + # generate some numpy arrays with data to fill into histogram, + # in this case normal distributed random numbers in x and y, + # converted into polar coordinates + x = np.random.randn(1000) # generate x + y = np.random.randn(1000) # generate y + rphi = np.empty((1000, 2)) + rphi[:, 0] = (x ** 2 + y ** 2) ** 0.5 # compute radius + rphi[:, 1] = np.arctan2(y, x) # compute phi - bin -1 x in [-inf, -1): 1 +/- 1 - bin 0 x in [-1, -0.7): 1 +/- 1 - bin 1 x in [-0.7, -0.4): 1 +/- 1 - bin 2 x in [-0.4, -0.1): 0 +/- 0 - bin 3 x in [-0.1, 0.2): 5 +/- 5 - bin 4 x in [0.2, 0.5): 1 +/- 1 - bin 5 x in [0.5, 0.8): 0 +/- 0 - bin 6 x in [0.8, 1.1): 0 +/- 0 - bin 7 x in [1.1, 1.4): 1 +/- 1 - bin 8 x in [1.4, 1.7): 0 +/- 0 - bin 9 x in [1.7, 2): 1 +/- 1 - bin 10 x in [2, inf): 2 +/- 1.41421 -`` + # fill histogram with numpy array + h.fill(rphi) + + # access histogram counts (no copy) + count_matrix = np.asarray(h) + + print count_matrix + + # program output: + # + # [[37 26 33 37] + # [60 69 76 62] + # [48 80 80 77] + # [38 49 45 49] + # [22 24 20 23] + # [ 7 9 9 8] + # [ 3 2 3 3] + # [ 0 0 0 0] + # [ 0 1 0 0] + # [ 0 0 0 0]] +``` [endsect] + [section Example 2: 2d-histogram in Python] How to make a 2d-histogram in Python and to fill it using a Numpy array: [python] - -`` +`` import histogram as bh import numpy as np @@ -104,14 +123,14 @@ How to make a 2d-histogram in Python and to fill it using a Numpy array: uoflow=False), bh.polar_axis(4, 0.0, "phi")) - # fill histogram with random values, using numpy to make + # fill histogram with random values, using numpy to make # a two-dimensional normal distribution in cartesian coordinates x = np.random.randn(1000) # generate x y = np.random.randn(1000) # generate y rphi = np.empty((1000, 2)) rphi[:, 0] = (x ** 2 + y ** 2) ** 0.5 # compute radius rphi[:, 1] = np.arctan2(y, x) # compute phi - h.increment(rphi) + h.fill(rphi) # access counts as a numpy array (no data is copied) count_matrix = np.asarray(h) @@ -119,8 +138,10 @@ How to make a 2d-histogram in Python and to fill it using a Numpy array: print count_matrix `` + The program output are the counts per bin as a 2d-array: +[python] `` [[37 26 33 37] [60 69 76 62] diff --git a/examples/example_1d.py b/examples/example_1d.py index e0e7eff5..38ec73e6 100644 --- a/examples/example_1d.py +++ b/examples/example_1d.py @@ -3,7 +3,7 @@ import numpy as np import matplotlib.pyplot as plt h = hg.histogram(hg.regular_axis(10, -3, 3)) -h.increment(np.random.randn(1000)) +h.fill(np.random.randn(1000)) bins = h.axis(0).bins diff --git a/examples/example_2d.py b/examples/example_2d.py index 4fdfb2f1..b2e98e1b 100644 --- a/examples/example_2d.py +++ b/examples/example_2d.py @@ -6,7 +6,7 @@ h = hg.histogram(hg.regular_axis(10, -3, 3, uoflow=False), hg.regular_axis(10, -3, 3, uoflow=False)) xy = np.random.randn(2000).reshape((1000, 2)) xy[:,1] *= 0.5 -h.increment(xy) +h.fill(xy) bins = h.axis(0).bins diff --git a/include/boost/histogram/axis.hpp b/include/boost/histogram/axis.hpp index c31f402c..4895885b 100644 --- a/include/boost/histogram/axis.hpp +++ b/include/boost/histogram/axis.hpp @@ -379,7 +379,7 @@ public: {} explicit - category_axis(const std::vector& categories) : + category_axis(const std::vector& categories) : category_axis(categories.begin(), categories.end()) {} diff --git a/include/boost/histogram/detail/tiny_string.hpp b/include/boost/histogram/detail/tiny_string.hpp index 4ebc755e..4bb0d3ae 100644 --- a/include/boost/histogram/detail/tiny_string.hpp +++ b/include/boost/histogram/detail/tiny_string.hpp @@ -10,25 +10,16 @@ #include #include #include +#include namespace boost { namespace histogram { namespace detail { -class tiny_string { +class tiny_string : + boost::operators +{ public: - tiny_string(const char* s) - { - if (s) { - const auto n = std::strlen(s) + 1; - if (n > 1) { - ptr_.reset(new char[n]); - std::strcpy(ptr_.get(), s); - } else - ptr_.reset(); - } - } - tiny_string() = default; tiny_string(const tiny_string& other) : @@ -44,10 +35,35 @@ public: tiny_string(tiny_string&& other) noexcept = default; tiny_string& operator=(tiny_string&& other) = default; + tiny_string(const std::string& other) : + tiny_string(other.c_str()) + {} + + tiny_string& operator=(const std::string& other) { + tiny_string tmp(other.c_str()); + swap(tmp); + return *this; + } + + tiny_string(const char* other) + { + if (other) { + const auto n = std::strlen(other) + 1; + if (n > 1) { + ptr_.reset(new char[n]); + std::strcpy(ptr_.get(), other); + } + } + } + + tiny_string& operator=(const char* other) { + tiny_string tmp(other); + swap(tmp); + return *this; + } + bool operator==(const tiny_string& other) const { - if (ptr_ && other.ptr_) - return std::strcmp(ptr_.get(), other.ptr_.get()) == 0; - return ptr_ == other.ptr_; + return std::strcmp(c_str(), other.c_str()) == 0; } void swap(tiny_string& other) noexcept { diff --git a/include/boost/histogram/dynamic_histogram.hpp b/include/boost/histogram/dynamic_histogram.hpp index e0e3ca4f..8056ff4f 100644 --- a/include/boost/histogram/dynamic_histogram.hpp +++ b/include/boost/histogram/dynamic_histogram.hpp @@ -133,7 +133,7 @@ public: } template - void increment(Values... values) + void fill(Values... values) { BOOST_ASSERT_MSG(sizeof...(values) == dim(), "number of arguments does not match histogram dimension"); @@ -145,7 +145,7 @@ public: template > - void increment(Iterator begin, Iterator end) + void fill(Iterator begin, Iterator end) { BOOST_ASSERT_MSG(std::distance(begin, end) == dim(), "number of arguments does not match histogram dimension"); @@ -157,16 +157,16 @@ public: template > - void increment(const Sequence& values) + void fill(const Sequence& values) { - increment(std::begin(values), std::end(values)); + fill(std::begin(values), std::end(values)); } template - void wincrement(value_type w, Values... values) + void wfill(value_type w, Values... values) { static_assert(detail::has_weight_support::value, - "wincrement only supported for adaptive_storage"); + "wfill only supported for adaptive_storage"); BOOST_ASSERT_MSG(sizeof...(values) == dim(), "number of arguments does not match histogram dimension"); detail::linearize_x lin; @@ -177,10 +177,10 @@ public: template > - void wincrement(value_type w, Iterator begin, Iterator end) + void wfill(value_type w, Iterator begin, Iterator end) { static_assert(detail::has_weight_support::value, - "wincrement only supported for adaptive_storage"); + "wfill only supported for adaptive_storage"); BOOST_ASSERT_MSG(std::distance(begin, end) == dim(), "iterator range does not match histogram dimension"); detail::linearize_x lin; @@ -191,9 +191,9 @@ public: template > - void wincrement(value_type w, const Sequence& values) + void wfill(value_type w, const Sequence& values) { - wincrement(w, std::begin(values), std::end(values)); + wfill(w, std::begin(values), std::end(values)); } template diff --git a/include/boost/histogram/static_histogram.hpp b/include/boost/histogram/static_histogram.hpp index e3df6eb5..6d2f6ec7 100644 --- a/include/boost/histogram/static_histogram.hpp +++ b/include/boost/histogram/static_histogram.hpp @@ -103,7 +103,7 @@ public: } template - void increment(Values... values) + void fill(Values... values) { static_assert(sizeof...(values) == dim(), "number of arguments does not match histogram dimension"); @@ -115,7 +115,7 @@ public: template > - void increment(Iterator begin, Iterator end) + void fill(Iterator begin, Iterator end) { BOOST_ASSERT_MSG(std::distance(begin, end) == dim(), "iterator range does not match histogram dimension"); @@ -127,16 +127,16 @@ public: template > - void increment(const Sequence& values) + void fill(const Sequence& values) { - increment(std::begin(values), std::end(values)); + fill(std::begin(values), std::end(values)); } template - void wincrement(value_type w, Values... values) + void wfill(value_type w, Values... values) { static_assert(detail::has_weight_support::value, - "wincrement only supported for adaptive_storage"); + "wfill only supported for adaptive_storage"); static_assert(sizeof...(values) == dim(), "number of arguments does not match histogram dimension"); detail::linearize_x lin; @@ -147,10 +147,10 @@ public: template > - void wincrement(value_type w, Iterator begin, Iterator end) + void wfill(value_type w, Iterator begin, Iterator end) { static_assert(detail::has_weight_support::value, - "wincrement only supported for adaptive_storage"); + "wfill only supported for adaptive_storage"); BOOST_ASSERT_MSG(std::distance(begin, end) == dim(), "iterator range does not match histogram dimension"); detail::linearize_x lin; @@ -161,9 +161,9 @@ public: template > - void wincrement(value_type w, const Sequence& values) + void wfill(value_type w, const Sequence& values) { - wincrement(w, std::begin(values), std::end(values)); + wfill(w, std::begin(values), std::end(values)); } template diff --git a/src/python/axis.cpp b/src/python/axis.cpp index 83fc6217..77da6c88 100644 --- a/src/python/axis.cpp +++ b/src/python/axis.cpp @@ -84,9 +84,9 @@ category_axis_init(python::tuple args, python::dict kwargs) { // } // } - std::vector c; + std::vector c; for (int i = 1, n = len(args); i < n; ++i) - c.push_back(extract(args[i])); + c.push_back(extract(args[i])); return pyinit(c); } @@ -183,9 +183,9 @@ void register_axis_types() // used to pass arguments from raw python init to specialized C++ constructors class_>("vector_double", no_init); - class_>("vector_cstring", no_init); + class_>("vector_string", no_init); class_::const_iterator>("vector_double_iterator", no_init); - class_::const_iterator>("vector_cstring_iterator", no_init); + class_::const_iterator>("vector_string_iterator", no_init); class_("regular_axis", "An axis for real-valued data and bins of equal width." @@ -228,7 +228,7 @@ void register_axis_types() "\nBinning is a O(1) operation.", no_init) .def("__init__", raw_function(category_axis_init)) - .def(init>()) + .def(init>()) .def(axis_suite()) ; diff --git a/src/python/histogram.cpp b/src/python/histogram.cpp index 5f367c1d..c3864c20 100644 --- a/src/python/histogram.cpp +++ b/src/python/histogram.cpp @@ -75,7 +75,7 @@ histogram_init(python::tuple args, python::dict kwargs) { } python::object -histogram_increment(python::tuple args, python::dict kwargs) { +histogram_fill(python::tuple args, python::dict kwargs) { using namespace python; const unsigned nargs = len(args); @@ -143,7 +143,7 @@ histogram_increment(python::tuple args, python::dict kwargs) { for (unsigned i = 0; i < dims[0]; ++i) { double* v = reinterpret_cast(PyArray_GETPTR1(a, i) ); double* w = reinterpret_cast(PyArray_GETPTR1(aw, i)); - self.wincrement(*w, v, v+self.dim()); + self.wfill(*w, v, v+self.dim()); } Py_DECREF(aw); @@ -154,7 +154,7 @@ histogram_increment(python::tuple args, python::dict kwargs) { } else { for (unsigned i = 0; i < dims[0]; ++i) { double* v = reinterpret_cast(PyArray_GETPTR1(a, i)); - self.increment(v, v+self.dim()); + self.fill(v, v+self.dim()); } } @@ -175,11 +175,11 @@ histogram_increment(python::tuple args, python::dict kwargs) { v[i] = extract(args[1 + i]); if (ow.is_none()) { - self.increment(v, v+self.dim()); + self.fill(v, v+self.dim()); } else { const double w = extract(ow); - self.wincrement(w, v, v+self.dim()); + self.wfill(w, v, v+self.dim()); } return object(); @@ -293,10 +293,10 @@ void register_histogram() ":param int i: index of the axis\n" ":returns: axis object for axis i", (arg("self"), arg("i") = 0)) - .def("increment", raw_function(histogram_increment), + .def("fill", raw_function(histogram_fill), "Pass a sequence of values with a length n is" "\nequal to the dimensions of the histogram," - "\nand optionally a weight w for this increment" + "\nand optionally a weight w for this fill" "\n(*int* or *float*)." "\n" "\nIf Numpy support is enabled, values may also" diff --git a/test/axis_test.cpp b/test/axis_test.cpp index 33ec4e87..6c30fb41 100644 --- a/test/axis_test.cpp +++ b/test/axis_test.cpp @@ -99,7 +99,7 @@ int main() { // category_axis_operators { - category_axis a{"A", "B", "C"}; + category_axis a{{"A", "B", "C"}}; category_axis b; BOOST_TEST_NOT(a == b); b = a; diff --git a/test/detail_test.cpp b/test/detail_test.cpp index c7fda145..56ed81ec 100644 --- a/test/detail_test.cpp +++ b/test/detail_test.cpp @@ -12,6 +12,10 @@ #include using namespace boost::histogram::detail; +#ifndef BOOST_TEST_CSTR_EQ + #define BOOST_TEST_CSTR_EQ(x,y) BOOST_TEST(std::strcmp(x,y) == 0) +#endif + int main () { // weight diff --git a/test/dynamic_histogram_test.cpp b/test/dynamic_histogram_test.cpp index 4c58be69..afb3c5f7 100644 --- a/test/dynamic_histogram_test.cpp +++ b/test/dynamic_histogram_test.cpp @@ -125,7 +125,7 @@ int main() { { auto h = make_dynamic_histogram_with>(integer_axis(0, 1), integer_axis(0, 2)); - h.increment(0, 0); + h.fill(0, 0); auto h2 = decltype(h)(h); BOOST_TEST(h2 == h); auto h3 = dynamic_histogram< @@ -139,7 +139,7 @@ int main() { { auto h = make_dynamic_histogram_with>(integer_axis(0, 1), integer_axis(0, 2)); - h.increment(0, 0); + h.fill(0, 0); auto h2 = decltype(h)(); BOOST_TEST(!(h == h2)); h2 = h; @@ -159,7 +159,7 @@ int main() { { auto h = make_dynamic_histogram(integer_axis(0, 1), integer_axis(0, 2)); - h.increment(0, 0); + h.fill(0, 0); const auto href = h; decltype(h) h2(std::move(h)); BOOST_TEST_EQ(h.dim(), 0u); @@ -195,13 +195,13 @@ int main() { auto d = make_dynamic_histogram(regular_axis(2, 0, 1)); BOOST_TEST(!(c == d)); BOOST_TEST(!(d == c)); - c.increment(0); + c.fill(0); BOOST_TEST(!(a == c)); BOOST_TEST(!(c == a)); - a.increment(0); + a.fill(0); BOOST_TEST(a == c); BOOST_TEST(c == a); - a.increment(0); + a.fill(0); BOOST_TEST(!(a == c)); BOOST_TEST(!(c == a)); } @@ -209,10 +209,10 @@ int main() { // d1 { auto h = make_dynamic_histogram(integer_axis(0, 1)); - h.increment(0); - h.increment(0); - h.increment(-1); - h.increment(10); + h.fill(0); + h.fill(0); + h.fill(-1); + h.fill(10); BOOST_TEST_EQ(h.dim(), 1u); BOOST_TEST_EQ(bins(h.axis(0)), 2); @@ -237,10 +237,10 @@ int main() { // d1_2 { auto h = make_dynamic_histogram(integer_axis(0, 1, "", false)); - h.increment(0); - h.increment(-0); - h.increment(-1); - h.increment(10); + h.fill(0); + h.fill(-0); + h.fill(-1); + h.fill(10); BOOST_TEST_EQ(h.dim(), 1u); BOOST_TEST_EQ(bins(h.axis(0)), 2); @@ -261,11 +261,11 @@ int main() { // d1w { auto h = make_dynamic_histogram(regular_axis(2, -1, 1)); - h.increment(0); - h.wincrement(2, -1.0); - h.increment(-1.0); - h.increment(-2.0); - h.wincrement(5, 10); + h.fill(0); + h.wfill(2, -1.0); + h.fill(-1.0); + h.fill(-2.0); + h.wfill(5, 10); BOOST_TEST_EQ(h.sum(), 10.0); @@ -284,12 +284,12 @@ int main() { { auto h = make_dynamic_histogram(regular_axis(2, -1, 1), integer_axis(-1, 1, nullptr, false)); - h.increment(-1, -1); - h.increment(-1, 0); + h.fill(-1, -1); + h.fill(-1, 0); std::array ai = {{-1., -10.}}; - h.increment(ai); + h.fill(ai); double in[2] = {-10., 0.}; - h.increment(in, in+2); + h.fill(in, in+2); BOOST_TEST_EQ(h.dim(), 2u); BOOST_TEST_EQ(bins(h.axis(0)), 2); @@ -335,10 +335,10 @@ int main() { { auto h = make_dynamic_histogram(regular_axis(2, -1, 1), integer_axis(-1, 1, nullptr, false)); - h.increment(-1, 0); // -> 0, 1 - h.wincrement(10, -1, -1); // -> 0, 0 - h.wincrement(5, -1, -10); // is ignored - h.wincrement(7, -10, 0); // -> -1, 1 + h.fill(-1, 0); // -> 0, 1 + h.wfill(10, -1, -1); // -> 0, 0 + h.wfill(5, -1, -10); // is ignored + h.wfill(7, -10, 0); // -> -1, 1 BOOST_TEST_EQ(h.sum(), 18.0); @@ -384,7 +384,7 @@ int main() { for (auto j = 0; j < bins(h.axis(1)); ++j) for (auto k = 0; k < bins(h.axis(2)); ++k) { - h.wincrement(i+j+k, i, j, k); + h.wfill(i+j+k, i, j, k); } for (auto i = 0; i < bins(h.axis(0)); ++i) @@ -412,8 +412,8 @@ int main() { mpl::vector, container_storage> >(integer_axis(-1, 1)); - a.increment(-1); - b.increment(1); + a.fill(-1); + b.fill(1); auto c = a; c += b; BOOST_TEST_EQ(c.value(-1), 0); @@ -435,8 +435,8 @@ int main() { auto a = make_dynamic_histogram(integer_axis(-1, 1)); auto b = make_dynamic_histogram(integer_axis(-1, 1)); - a.increment(0); - b.wincrement(3, -1); + a.fill(0); + b.wfill(3, -1); auto c = a; c += b; BOOST_TEST_EQ(c.value(-1), 0); @@ -457,8 +457,8 @@ int main() { { auto a = make_dynamic_histogram_with>>(integer_axis(-1, 1)); auto b = make_dynamic_histogram_with>>(integer_axis(-1, 1)); - a.increment(-1); - b.increment(1); + a.fill(-1); + b.fill(1); auto c = a; c += b; BOOST_TEST_EQ(c.value(-1), 0u); @@ -501,7 +501,7 @@ int main() { variable_axis({0.1, 0.2, 0.3, 0.4, 0.5}, "v"), category_axis{"A", "B", "C"}, integer_axis(0, 1, "i")); - a.increment(0.5, 0.1, 0.25, 1, 0); + a.fill(0.5, 0.1, 0.25, 1, 0); std::string buf; { std::ostringstream os; diff --git a/test/python_suite_test.py.in b/test/python_suite_test.py.in index a6688154..d7ae9358 100755 --- a/test/python_suite_test.py.in +++ b/test/python_suite_test.py.in @@ -349,17 +349,17 @@ class histogramest(unittest.TestCase): h1 = histogram(integer_axis(-1, 1, uoflow=True)) for h in (h0, h1): with self.assertRaises(RuntimeError): - h.increment() + h.fill() with self.assertRaises(RuntimeError): - h.increment(1, 2) - h.increment(-10) - h.increment(-1) - h.increment(-1) - h.increment(0) - h.increment(1) - h.increment(1) - h.increment(1) - h.increment(10) + h.fill(1, 2) + h.fill(-10) + h.fill(-1) + h.fill(-1) + h.fill(0) + h.fill(1) + h.fill(1) + h.fill(1) + h.fill(10) self.assertEqual(h0.sum, 6) self.assertEqual(h0.axis(0).shape, 3) self.assertEqual(h1.sum, 8) @@ -386,14 +386,14 @@ class histogramest(unittest.TestCase): def test_growth(self): h = histogram(integer_axis(-1, 1)) - h.increment(-1) - h.increment(1) - h.increment(1) + h.fill(-1) + h.fill(1) + h.fill(1) for i in range(255): - h.increment(0) - h.increment(0) + h.fill(0) + h.fill(0) for i in range(1000-256): - h.increment(0) + h.fill(0) self.assertEqual(h.value(-1), 0) self.assertEqual(h.value(0), 1) self.assertEqual(h.value(1), 1000) @@ -404,17 +404,17 @@ class histogramest(unittest.TestCase): for uoflow in (False, True): h = histogram(integer_axis(-1, 1, uoflow=uoflow), regular_axis(4, -2, 2, uoflow=uoflow)) - h.increment(-1, -2) - h.increment(-1, -1) - h.increment(0, 0) - h.increment(0, 1) - h.increment(1, 0) - h.increment(3, -1) - h.increment(0, -3) + h.fill(-1, -2) + h.fill(-1, -1) + h.fill(0, 0) + h.fill(0, 1) + h.fill(1, 0) + h.fill(3, -1) + h.fill(0, -3) with self.assertRaises(Exception): - h.increment(1) + h.fill(1) with self.assertRaises(Exception): - h.increment(1, 2, 3) + h.fill(1, 2, 3) m = [[1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 0, 1], @@ -429,13 +429,13 @@ class histogramest(unittest.TestCase): for uoflow in (False, True): h = histogram(integer_axis(-1, 1, uoflow=uoflow), regular_axis(4, -2, 2, uoflow=uoflow)) - h.increment(-1, -2) - h.increment(-1, -1) - h.increment(0, 0) - h.increment(0, 1) - h.increment(1, 0) - h.increment(3, -1) - h.increment(0, -3) + h.fill(-1, -2) + h.fill(-1, -1) + h.fill(0, 0) + h.fill(0, 1) + h.fill(1, 0) + h.fill(3, -1) + h.fill(0, -3) m = [[1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 0, 1], @@ -460,13 +460,13 @@ class histogramest(unittest.TestCase): for uoflow in (False, True): h = histogram(integer_axis(-1, 1, uoflow=uoflow), regular_axis(4, -2, 2, uoflow=uoflow)) - h.increment(-1, -2) - h.increment(-1, -1) - h.increment(0, 0) - h.increment(0, 1) - h.increment(1, 0) - h.increment(3, -1) - h.increment(0, -3) + h.fill(-1, -2) + h.fill(-1, -1) + h.fill(0, 0) + h.fill(0, 1) + h.fill(1, 0) + h.fill(3, -1) + h.fill(0, -3) m = [[1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 0, 1], @@ -476,7 +476,7 @@ class histogramest(unittest.TestCase): h2 = histogram(integer_axis(-1, 1, uoflow=uoflow), regular_axis(4, -2, 2, uoflow=uoflow)) - h2.increment(0, 0, w=0) + h2.fill(0, 0, w=0) h2 += h h2 += h @@ -495,15 +495,15 @@ class histogramest(unittest.TestCase): variable_axis(0.0, 1.0, 2.0), polar_axis(4, label='pa')) for i in range(a.axis(0).bins): - a.increment(i, 0, 0, 0, 0) + a.fill(i, 0, 0, 0, 0) for j in range(a.axis(1).bins): - a.increment(i, j, 0, 0, 0) + a.fill(i, j, 0, 0, 0) for k in range(a.axis(2).bins): - a.increment(i, j, k, 0, 0) + a.fill(i, j, k, 0, 0) for l in range(a.axis(3).bins): - a.increment(i, j, k, l, 0) + a.fill(i, j, k, l, 0) for m in range(a.axis(4).bins): - a.increment(i, j, k, l, m * 0.5 * pi) + a.fill(i, j, k, l, m * 0.5 * pi) io = BytesIO() pickle.dump(a, io) @@ -525,13 +525,13 @@ class histogramest(unittest.TestCase): regular_axis(4, 0.0, 4.0, uoflow=False), variable_axis(0.0, 1.0, 2.0)) for i in range(a.axis(0).bins): - a.increment(i, 0, 0, 0, w=3) + a.fill(i, 0, 0, 0, w=3) for j in range(a.axis(1).bins): - a.increment(i, j, 0, 0, w=10) + a.fill(i, j, 0, 0, w=10) for k in range(a.axis(2).bins): - a.increment(i, j, k, 0, w=2) + a.fill(i, j, k, 0, w=2) for l in range(a.axis(3).bins): - a.increment(i, j, k, l, w=5) + a.fill(i, j, k, l, w=5) io = BytesIO() pickle.dump(a, io) @@ -550,7 +550,7 @@ class histogramest(unittest.TestCase): def test_numpy_conversion_0(self): a = histogram(integer_axis(0, 2, uoflow=False)) for i in range(100): - a.increment(1) + a.fill(1) c = numpy.array(a) # a copy v = numpy.asarray(a) # a view @@ -559,12 +559,12 @@ class histogramest(unittest.TestCase): self.assertTrue(numpy.all(t == numpy.array((0, 100, 0)))) for i in range(100): - a.increment(1) + a.fill(1) self.assertTrue(numpy.all(c == numpy.array((0, 100, 0)))) self.assertTrue(numpy.all(v == numpy.array((0, 200, 0)))) for i in range(100): - a.increment(1) + a.fill(1) c = numpy.array(a) self.assertEqual(c.dtype, numpy.uint16) self.assertTrue(numpy.all(c == numpy.array((0, 300, 0)))) @@ -575,7 +575,7 @@ class histogramest(unittest.TestCase): def test_numpy_conversion_1(self): a = histogram(integer_axis(0, 2)) for i in range(10): - a.increment(1, w=3) + a.fill(1, w=3) c = numpy.array(a) # a copy v = numpy.asarray(a) # a view self.assertEqual(c.dtype, numpy.float64) @@ -592,7 +592,7 @@ class histogramest(unittest.TestCase): for j in range(a.axis(1).bins): for k in range(a.axis(2).bins): for m in range(i+j+k): - a.increment(i, j, k) + a.fill(i, j, k) r[i,j,k] = i+j+k c = numpy.array(a) # a copy v = numpy.asarray(a) # a view @@ -616,7 +616,7 @@ class histogramest(unittest.TestCase): for i in range(a.axis(0).bins): for j in range(a.axis(1).bins): for k in range(a.axis(2).bins): - a.increment(i, j, k, w=i+j+k) + a.fill(i, j, k, w=i+j+k) r[0, i, j, k] = i+j+k r[1, i, j, k] = (i+j+k)**2 c = numpy.array(a) # a copy @@ -636,7 +636,7 @@ class histogramest(unittest.TestCase): @unittest.skipUnless(have_numpy, "requires build with numpy-support") def test_bad_numpy_conversion(self): a = histogram(integer_axis(0, 0)) - a.increment(0) + a.fill(0) for i in xrange(80): a += a # a now holds a multiprecision type @@ -646,36 +646,36 @@ class histogramest(unittest.TestCase): @unittest.skipUnless(have_numpy, "requires build with numpy-support") def test_fill_with_numpy_array_0(self): a = histogram(integer_axis(0, 2, uoflow=False)) - a.increment(numpy.array([-1, 0, 1, 2, 1, 4])) - a.increment((-1, 0)) - a.increment([1, 2]) + a.fill(numpy.array([-1, 0, 1, 2, 1, 4])) + a.fill((-1, 0)) + a.fill([1, 2]) self.assertEqual(a.value(0), 2) self.assertEqual(a.value(1), 3) self.assertEqual(a.value(2), 2) with self.assertRaises(ValueError): - a.increment(numpy.empty((2, 2))) + a.fill(numpy.empty((2, 2))) with self.assertRaises(ValueError): - a.increment(numpy.empty((1, 2, 2))) + a.fill(numpy.empty((1, 2, 2))) with self.assertRaises(RuntimeError): - a.increment(numpy.empty((2, 1)), 1) + a.fill(numpy.empty((2, 1)), 1) with self.assertRaises(ValueError): - a.increment("abc") + a.fill("abc") a = histogram(integer_axis(0, 1, uoflow=False), regular_axis(2, 0, 2, uoflow=False)) - a.increment(numpy.array([[-1., -1.], [0., 1.], [1., 0.1]])) + a.fill(numpy.array([[-1., -1.], [0., 1.], [1., 0.1]])) self.assertEqual(a.value(0, 0), 0) self.assertEqual(a.value(0, 1), 1) self.assertEqual(a.value(1, 0), 1) self.assertEqual(a.value(1, 1), 0) with self.assertRaises(ValueError): - a.increment((1, 2, 3)) + a.fill((1, 2, 3)) a = histogram(integer_axis(0, 2, uoflow=False)) - a.increment([0, 0, 1, 2]) - a.increment((1, 0, 2, 2)) + a.fill([0, 0, 1, 2]) + a.fill((1, 0, 2, 2)) self.assertEqual(a.value(0), 3) self.assertEqual(a.value(1), 2) self.assertEqual(a.value(2), 3) @@ -686,8 +686,8 @@ class histogramest(unittest.TestCase): a = histogram(integer_axis(0, 2, uoflow=True)) v = numpy.array([-1, 0, 1, 2, 3, 4]) w = numpy.array([ 2, 3, 4, 5, 6, 7]) - a.increment(v, w=w) - a.increment([0, 1], w=[2.0, 3.0]) + a.fill(v, w=w) + a.fill([0, 1], w=[2.0, 3.0]) self.assertEqual(a.value(-1), 2) self.assertEqual(a.value(0), 5) self.assertEqual(a.value(1), 7) @@ -698,28 +698,28 @@ class histogramest(unittest.TestCase): self.assertEqual(a.variance(2), 25) with self.assertRaises(RuntimeError): - a.increment([1, 2], foo=[1, 1]) + a.fill([1, 2], foo=[1, 1]) with self.assertRaises(ValueError): - a.increment([1, 2], w=[1]) + a.fill([1, 2], w=[1]) with self.assertRaises(ValueError): - a.increment([1, 2], w="ab") + a.fill([1, 2], w="ab") with self.assertRaises(ValueError): - a.increment([1, 2], w=1) + a.fill([1, 2], w=1) with self.assertRaises(RuntimeError): - a.increment([1, 2], w=[1, 1], foo=1) + a.fill([1, 2], w=[1, 1], foo=1) with self.assertRaises(ValueError): - a.increment([1, 2], w=[[1, 1], [2, 2]]) + a.fill([1, 2], w=[[1, 1], [2, 2]]) a = histogram(integer_axis(0, 1, uoflow=False), regular_axis(2, 0, 2, uoflow=False)) - a.increment(numpy.array([[-1., -1.], [0., 1.], [1., 0.1]])) + a.fill(numpy.array([[-1., -1.], [0., 1.], [1., 0.1]])) self.assertEqual(a.value(0, 0), 0) self.assertEqual(a.value(0, 1), 1) self.assertEqual(a.value(1, 0), 1) self.assertEqual(a.value(1, 1), 0) a = histogram(integer_axis(0, 2, uoflow=False)) - a.increment([0, 0, 1, 2]) - a.increment((1, 0, 2, 2)) + a.fill([0, 0, 1, 2]) + a.fill((1, 0, 2, 2)) self.assertEqual(a.value(0), 3) self.assertEqual(a.value(1), 2) self.assertEqual(a.value(2), 3) diff --git a/test/speed_cpp.cpp b/test/speed_cpp.cpp index e52339d6..70b39048 100644 --- a/test/speed_cpp.cpp +++ b/test/speed_cpp.cpp @@ -46,7 +46,7 @@ double compare_1d(unsigned n, int distrib) auto h = Histogram(regular_axis(100, 0, 1)); auto t = clock(); for (unsigned i = 0; i < n; ++i) - h.increment(r[i]); + h.fill(r[i]); t = clock() - t; best = std::min(best, double(t) / CLOCKS_PER_SEC); } @@ -66,7 +66,7 @@ double compare_3d(unsigned n, int distrib) regular_axis(100, 0, 1)); auto t = clock(); for (unsigned i = 0; i < n; ++i) - h.increment(r[3 * i], r[3 * i + 1], r[3 * i + 2]); + h.fill(r[3 * i], r[3 * i + 1], r[3 * i + 2]); t = clock() - t; best = std::min(best, double(t) / CLOCKS_PER_SEC); } @@ -94,7 +94,7 @@ double compare_6d(unsigned n, int distrib) for (unsigned i = 0; i < n; ++i) { for (unsigned k = 0; k < 6; ++k) x[k] = r[6 * i + k]; - h.increment(x[0], x[1], x[2], x[3], x[4], x[5]); + h.fill(x[0], x[1], x[2], x[3], x[4], x[5]); } t = clock() - t; best = std::min(best, double(t) / CLOCKS_PER_SEC); @@ -123,7 +123,7 @@ int main() { compare_1d< static_histogram< mpl::vector, - adaptive_storage + adaptive_storage<> > >(12000000, itype) #elif HISTOGRAM_TYPE == 3 @@ -137,7 +137,7 @@ int main() { compare_1d< dynamic_histogram< default_axes, - adaptive_storage + adaptive_storage<> > >(12000000, itype) #endif @@ -156,7 +156,7 @@ int main() { compare_3d< static_histogram< mpl::vector, - adaptive_storage + adaptive_storage<> > >(4000000, itype) #elif HISTOGRAM_TYPE == 3 @@ -170,7 +170,7 @@ int main() { compare_3d< dynamic_histogram< default_axes, - adaptive_storage + adaptive_storage<> > >(4000000, itype) #endif @@ -191,7 +191,7 @@ int main() { static_histogram< mpl::vector, - adaptive_storage + adaptive_storage<> > >(2000000, itype) #elif HISTOGRAM_TYPE == 3 @@ -205,7 +205,7 @@ int main() { compare_6d< dynamic_histogram< default_axes, - adaptive_storage + adaptive_storage<> > >(2000000, itype) #endif diff --git a/test/speed_vs_numpy.py b/test/speed_vs_numpy.py index fb5ff32b..169d34d3 100755 --- a/test/speed_vs_numpy.py +++ b/test/speed_vs_numpy.py @@ -26,7 +26,7 @@ def compare_1d(n, distrib): h = histogram(regular_axis(100, 0, 1)) t = timer() - h.increment(r) + h.fill(r) t = timer() - t best_boost = min(t, best_boost) assert(np.all(w == np.array(h)[:-2])) @@ -57,7 +57,7 @@ def compare_3d(n, distrib): regular_axis(100, 0, 1), regular_axis(100, 0, 1)) t = timer() - h.increment(r) + h.fill(r) t = timer() - t best_boost = min(t, best_boost) assert(np.all(w == np.array(h)[:-2,:-2,:-2])) @@ -95,7 +95,7 @@ def compare_6d(n, distrib): regular_axis(10, 0, 1), regular_axis(10, 0, 1)) t = timer() - h.increment(r) + h.fill(r) t = timer() - t best_boost = min(t, best_boost) assert(np.all(w == np.array(h)[:-2,:-2,:-2,:-2,:-2,:-2])) diff --git a/test/static_histogram_test.cpp b/test/static_histogram_test.cpp index 725f088f..0a5a8897 100644 --- a/test/static_histogram_test.cpp +++ b/test/static_histogram_test.cpp @@ -113,7 +113,7 @@ int main() { { auto h = make_static_histogram(integer_axis(0, 1), integer_axis(0, 2)); - h.increment(0, 0); + h.fill(0, 0); auto h2 = decltype(h)(h); BOOST_TEST(h2 == h); auto h3 = static_histogram< @@ -127,7 +127,7 @@ int main() { { auto h = make_static_histogram(integer_axis(0, 1), integer_axis(0, 2)); - h.increment(0, 0); + h.fill(0, 0); auto h2 = decltype(h)(); BOOST_TEST(!(h == h2)); h2 = h; @@ -147,7 +147,7 @@ int main() { { auto h = make_static_histogram(integer_axis(0, 1), integer_axis(0, 2)); - h.increment(0, 0); + h.fill(0, 0); const auto href = h; decltype(h) h2(std::move(h)); BOOST_TEST_EQ(h.dim(), 2); @@ -176,13 +176,13 @@ int main() { auto d = make_static_histogram(regular_axis(2, 0, 1)); BOOST_TEST(!(c == d)); BOOST_TEST(!(d == c)); - c.increment(0); + c.fill(0); BOOST_TEST(!(a == c)); BOOST_TEST(!(c == a)); - a.increment(0); + a.fill(0); BOOST_TEST(a == c); BOOST_TEST(c == a); - a.increment(0); + a.fill(0); BOOST_TEST(!(a == c)); BOOST_TEST(!(c == a)); } @@ -190,10 +190,10 @@ int main() { // d1 { auto h = make_static_histogram(integer_axis(0, 1)); - h.increment(0); - h.increment(0); - h.increment(-1); - h.increment(10); + h.fill(0); + h.fill(0); + h.fill(-1); + h.fill(10); BOOST_TEST_EQ(h.dim(), 1); BOOST_TEST_EQ(bins(h.axis<0>()), 2); @@ -218,10 +218,10 @@ int main() { // d1_2 { auto h = make_static_histogram(integer_axis(0, 1, "", false)); - h.increment(0); - h.increment(-0); - h.increment(-1); - h.increment(10); + h.fill(0); + h.fill(-0); + h.fill(-1); + h.fill(10); BOOST_TEST_EQ(h.dim(), 1); BOOST_TEST_EQ(bins(h.axis<0>()), 2); @@ -242,11 +242,11 @@ int main() { // d1w { auto h = make_static_histogram(regular_axis(2, -1, 1)); - h.increment(0); - h.wincrement(2.0, -1.0); - h.increment(-1.0); - h.increment(-2.0); - h.wincrement(5.0, 10.0); + h.fill(0); + h.wfill(2.0, -1.0); + h.fill(-1.0); + h.fill(-2.0); + h.wfill(5.0, 10.0); BOOST_TEST_EQ(h.sum(), 10); @@ -265,12 +265,12 @@ int main() { { auto h = make_static_histogram(regular_axis(2, -1, 1), integer_axis(-1, 1, "", false)); - h.increment(-1, -1); - h.increment(-1, 0); + h.fill(-1, -1); + h.fill(-1, 0); std::array ai = {{-1., -10.}}; - h.increment(ai); + h.fill(ai); double in[2] = {-10., 0.}; - h.increment(in, in+2); + h.fill(in, in+2); BOOST_TEST_EQ(h.dim(), 2); BOOST_TEST_EQ(bins(h.axis<0>()), 2); @@ -316,10 +316,10 @@ int main() { { auto h = make_static_histogram(regular_axis(2, -1, 1), integer_axis(-1, 1, "", false)); - h.increment(-1, 0); // -> 0, 1 - h.wincrement(10, -1, -1); // -> 0, 0 - h.wincrement(5, -1, -10); // is ignored - h.wincrement(7, -10, 0); // -> -1, 1 + h.fill(-1, 0); // -> 0, 1 + h.wfill(10, -1, -1); // -> 0, 0 + h.wfill(5, -1, -10); // is ignored + h.wfill(7, -10, 0); // -> -1, 1 BOOST_TEST_EQ(h.sum(), 18); @@ -365,7 +365,7 @@ int main() { for (auto j = 0; j < bins(h.axis<1>()); ++j) for (auto k = 0; k < bins(h.axis<2>()); ++k) { - h.wincrement(i+j+k, i, j, k); + h.wfill(i+j+k, i, j, k); } for (auto i = 0; i < bins(h.axis<0>()); ++i) @@ -382,8 +382,8 @@ int main() { auto b = make_static_histogram_with< container_storage> >(integer_axis(-1, 1)); - a.increment(-1); - b.increment(1); + a.fill(-1); + b.fill(1); auto c = a; c += b; BOOST_TEST_EQ(c.value(-1), 0); @@ -409,8 +409,8 @@ int main() { adaptive_storage<> >(integer_axis(-1, 1)); - a.increment(0); - b.wincrement(3, -1); + a.fill(0); + b.wfill(3, -1); auto c = a; c += b; BOOST_TEST_EQ(c.value(-1), 0); @@ -435,8 +435,8 @@ int main() { auto b = make_static_histogram_with< container_storage> >(integer_axis(-1, 1)); - a.increment(-1); - b.increment(1); + a.fill(-1); + b.fill(1); auto c = a; c += b; BOOST_TEST_EQ(c.value(-1), 0); @@ -478,15 +478,15 @@ int main() { auto h = bh::make_static_histogram(bh::regular_axis(10, -1.0, 2.0, "x")); // fill histogram with data - h.increment(-1.5); // put in underflow bin - h.increment(-1.0); // included in first bin, bin interval is semi-open - h.increment(-0.5); - h.increment(1.1); - h.increment(0.3); - h.increment(1.7); - h.increment(2.0); // put in overflow bin, bin interval is semi-open - h.increment(20.0); // put in overflow bin - h.wincrement(5.0, 0.1); // fill with a weighted entry, weight is 5.0 + h.fill(-1.5); // put in underflow bin + h.fill(-1.0); // included in first bin, bin interval is semi-open + h.fill(-0.5); + h.fill(1.1); + h.fill(0.3); + h.fill(1.7); + h.fill(2.0); // put in overflow bin, bin interval is semi-open + h.fill(20.0); // put in overflow bin + h.wfill(5.0, 0.1); // fill with a weighted entry, weight is 5.0 std::ostringstream os1; // access histogram counts @@ -522,7 +522,7 @@ int main() { variable_axis({0.1, 0.2, 0.3, 0.4, 0.5}, "v"), category_axis{"A", "B", "C"}, integer_axis(0, 1, "i")); - a.increment(0.5, 0.1, 0.25, 1, 0); + a.fill(0.5, 0.1, 0.25, 1, 0); std::string buf; { std::ostringstream os;