Skip to content

Commit d312062

Browse files
ferdymercuryvepadulano
authored andcommitted
[test] avoid empty bins
1 parent 7719ee0 commit d312062

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/stressHistogram.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9185,13 +9185,17 @@ bool testArrayRebin()
91859185
h1->Fill( r.Uniform( minRange * .9 , maxRange * 1.1 ) );
91869186

91879187
// Create vector - generate bin edges ( nbins is always > 2)
9188-
// ignore fact that array may contains bins with zero size
91899188
Double_t * rebinArray = new Double_t[rebin];
91909189
r.RndmArray(rebin, rebinArray);
91919190
std::sort(rebinArray, rebinArray + rebin);
91929191
for ( Int_t i = 0; i < rebin; ++i ) {
91939192
rebinArray[i] = TMath::Nint( rebinArray[i] * ( h1->GetNbinsX() - 2 ) + 2 );
91949193
rebinArray[i] = h1->GetBinLowEdge( (Int_t) rebinArray[i] );
9194+
// compensate for the fact that array may contain bins with zero size
9195+
if (i > 0) {
9196+
if (rebinArray[i] <= rebinArray[i - 1])
9197+
rebinArray[i] = rebinArray[i - 1] + 1e-15;
9198+
}
91959199
}
91969200

91979201

0 commit comments

Comments
 (0)