guide_axis_with_uoflow_off.cpp 942 B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2015-2018 Hans Dembinski
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt
  5. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //[ guide_axis_with_uoflow_off
  7. #include <boost/histogram.hpp>
  8. #include <string>
  9. int main() {
  10. using namespace boost::histogram;
  11. // create a 1d-histogram over integer values from 1 to 6
  12. auto h1 = make_histogram(axis::integer<int>(1, 7));
  13. // axis has size 6...
  14. assert(h1.axis().size() == 6);
  15. // ... but histogram has size 8, because of overflow and underflow bins
  16. assert(h1.size() == 8);
  17. // create a 1d-histogram for throws of a six-sided die without extra bins,
  18. // since the values cannot be smaller than 1 or larger than 6
  19. auto h2 = make_histogram(axis::integer<int, use_default, axis::option::none_t>(1, 7));
  20. // now size of axis and histogram is equal
  21. assert(h2.axis().size() == 6);
  22. assert(h2.size() == 6);
  23. }
  24. //]