root/root-histv7-bin-iterator.patch
Mattias Ellert b2cd752635 Update to 6.22.00
Drop patches accepted upstream
  root-FitData-assert-fix.patch
  root-clang-altivec-vector.patch
  root-format-fix.patch
  root-moved-file.patch
  root-xmlmodify-dep.patch
New and improved Python bindings
The new Python bindings can be built for both Python 2 and Python 3
  out of the box. Dropped the workaround in specfile for this (EPEL 7)
Dropped the python3-other packages (EPEL 7)
The new Python bindings has split the TPython interface to a separate
  library. Now in a separate root-tpython package
root-tpython and root-tmva-python are now using Python 3 on EPEL 7
New subpackage root-gui-browsable
New patches (submitted upstream)
  Fix too aggressive -Werror replacements
  Add missing call to TFile::SetCacheFileDir in a TMVA tutorial
  Adjust stressGraphics.ref
  Fix off-by-one error in histogram v7 bin iterator
  Compatibility with python 2.7 versions before 2.7.9
  Fix the RNTuple.LargeFile test on 32bit (i386 and armv7hf)
  Fix doxygen issues
  Fix bad regex in TProofMgr
  Compatibility with xrootd 5
2020-07-15 04:44:51 +02:00

51 lines
2.2 KiB
Diff

From af2e5c8b1bf17a0a0e1c1492735395bdd49ffd65 Mon Sep 17 00:00:00 2001
From: Mattias Ellert <mattias.ellert@physics.uu.se>
Date: Mon, 29 Jun 2020 12:57:43 +0200
Subject: [PATCH] Fix off-by-one error in the histogram v7 bin iterator
The histogram bin iterator should start at 1 and end at N + 1, not
start at 0 and end at N. (As for all iterators, the end element is the
invalid element after the last one.)
Fixes an assertion in the histhistv7testUnit test
[----------] 2 tests from BinIterNBins
[ RUN ] BinIterNBins.NumBins
/usr/include/c++/10/bits/stl_vector.h:1045: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = float; _Alloc = std::allocator<float>; std::vector<_Tp, _Alloc>::reference = float&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]: Assertion '__builtin_expect(__n < this->size(), true)' failed.
---
hist/histv7/inc/ROOT/RHist.hxx | 4 ++--
hist/histv7/test/biniter.cxx | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/hist/histv7/inc/ROOT/RHist.hxx b/hist/histv7/inc/ROOT/RHist.hxx
index ebb319f1ef..9521fe182f 100644
--- a/hist/histv7/inc/ROOT/RHist.hxx
+++ b/hist/histv7/inc/ROOT/RHist.hxx
@@ -158,9 +158,9 @@ public:
/// Get the uncertainty on the content of the bin at `x`.
double GetBinUncertainty(const CoordArray_t &x) const { return fImpl->GetBinUncertainty(x); }
- const_iterator begin() const { return const_iterator(*fImpl); }
+ const_iterator begin() const { return const_iterator(*fImpl, 1); }
- const_iterator end() const { return const_iterator(*fImpl, fImpl->GetNBinsNoOver()); }
+ const_iterator end() const { return const_iterator(*fImpl, fImpl->GetNBinsNoOver() + 1); }
/// Swap *this and other.
///
diff --git a/hist/histv7/test/biniter.cxx b/hist/histv7/test/biniter.cxx
index aa1c2dfef9..1f940aa8e7 100644
--- a/hist/histv7/test/biniter.cxx
+++ b/hist/histv7/test/biniter.cxx
@@ -45,7 +45,7 @@ TEST(BinIterNBins, BinRef) {
double founduncert = -1.;
RH2F::CoordArray_t foundcoord{};
- int nBins = 0;
+ int nBins = 1;
for (auto bin: h) {
auto binCenter = bin.GetCenter();
if (std::fabs(binCenter[0] - x) < 0.1 && std::fabs(binCenter[1] - y) < 0.1) {
--
2.26.2