Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / histogram / examples / guide_histogram_reduction.cpp
index b7f78b6..e9ec7db 100644 (file)
@@ -24,15 +24,16 @@ int main() {
   // rebin the second axis by merging pairs of adjacent bins
   auto h2 = algorithm::reduce(h, algorithm::shrink(0, 0.0, 3.0), algorithm::rebin(1, 2));
 
-  // reduce does not remove counts if the histogram has underflow/overflow bins
-  assert(algorithm::sum(h) == 4 && algorithm::sum(h2) == 4);
-
   assert(h2.axis(0).size() == 3);
   assert(h2.axis(0).bin(0).lower() == 0.0);
   assert(h2.axis(0).bin(2).upper() == 3.0);
   assert(h2.axis(1).size() == 2);
   assert(h2.axis(1).bin(0).lower() == -1.0);
   assert(h2.axis(1).bin(1).upper() == 1.0);
+
+  // reduce does not change the total count if the histogram has underflow/overflow bins;
+  // counts in removed bins are added to the corresponding under- and overflow bins
+  assert(algorithm::sum(h) == 4 && algorithm::sum(h2) == 4);
 }
 
 //]