Skip to content

Commit 88bfedb

Browse files
committed
[hist] do not support infinite bin edges even if variable binwidth
Fixes #20174
1 parent 2a5f2a6 commit 88bfedb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

hist/hist/src/TAxis.cxx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,14 +804,21 @@ void TAxis::Set(Int_t nbins, Double_t xlow, Double_t xup)
804804
/// Initialize axis with variable bins
805805
///
806806
/// An error is printed if bin edges are not in strictly increasing order
807+
/// or if any of them is infinite or nan
807808

808809
void TAxis::Set(Int_t nbins, const Float_t *xbins)
809810
{
810811
Int_t bin;
811812
fNbins = nbins;
812813
fXbins.Set(fNbins+1);
813-
for (bin=0; bin<= fNbins; bin++)
814+
for (bin = 0; bin <= fNbins; bin++) {
815+
if (std::isinf(xbins[bin])) {
816+
Error("TAxis::Set", "infinite bin edges are not supported. Use a large number instead.");
817+
} else if (std::isnan(xbins[bin])) {
818+
Error("TAxis::Set", "bin edges should not be NaN");
819+
}
814820
fXbins.fArray[bin] = xbins[bin];
821+
}
815822
for (bin=1; bin<= fNbins; bin++)
816823
if (fXbins.fArray[bin] <= fXbins.fArray[bin - 1])
817824
Error("TAxis::Set", "bin edges must be in increasing order");

0 commit comments

Comments
 (0)