2727#include " snprintf.h"
2828
2929#include < iostream>
30+ #include < cmath>
3031#include < ctime>
3132#include < cassert>
3233
@@ -779,10 +780,20 @@ void TAxis::SaveAttributes(std::ostream &out, const char *name, const char *subn
779780
780781// //////////////////////////////////////////////////////////////////////////////
781782// / Initialize axis with fix bins
783+ // /
784+ // / An error is printed if xup or xlow are infinite/nan
785+ // / (due to resulting undefined fixed bin width)
786+ // /
787+ // / Set xup <= xlow to force the axis range and number of bins to be automatically
788+ // / deduced after buffer is full or BufferEmpty is called
782789
783790void TAxis::Set (Int_t nbins, Double_t xlow, Double_t xup)
784791{
785792 fNbins = nbins;
793+ if (std::isinf (xlow) || std::isinf (xup))
794+ Error (" TAxis::Set" , " fixed binwidth not compatible with infinite lower/upper edges" );
795+ if (std::isnan (xlow) || std::isnan (xup))
796+ Error (" TAxis::Set" , " lower/upper edges should not be NaN" );
786797 fXmin = xlow;
787798 fXmax = xup;
788799 if (!fParent ) SetDefaults ();
@@ -791,6 +802,8 @@ void TAxis::Set(Int_t nbins, Double_t xlow, Double_t xup)
791802
792803// //////////////////////////////////////////////////////////////////////////////
793804// / Initialize axis with variable bins
805+ // /
806+ // / An error is printed if bin edges are not in strictly increasing order
794807
795808void TAxis::Set (Int_t nbins, const Float_t *xbins)
796809{
@@ -801,7 +814,7 @@ void TAxis::Set(Int_t nbins, const Float_t *xbins)
801814 fXbins .fArray [bin] = xbins[bin];
802815 for (bin=1 ; bin<= fNbins ; bin++)
803816 if (fXbins .fArray [bin] <= fXbins .fArray [bin - 1 ])
804- Error (" TAxis::Set" , " bins must be in increasing order" );
817+ Error (" TAxis::Set" , " bin edges must be in increasing order" );
805818 fXmin = fXbins .fArray [0 ];
806819 fXmax = fXbins .fArray [fNbins ];
807820 if (!fParent ) SetDefaults ();
@@ -819,7 +832,7 @@ void TAxis::Set(Int_t nbins, const Double_t *xbins)
819832 fXbins .fArray [bin] = xbins[bin];
820833 for (bin=1 ; bin<= fNbins ; bin++)
821834 if (fXbins .fArray [bin] <= fXbins .fArray [bin - 1 ])
822- Error (" TAxis::Set" , " bins must be in increasing order" );
835+ Error (" TAxis::Set" , " bin edges must be in increasing order" );
823836 fXmin = fXbins .fArray [0 ];
824837 fXmax = fXbins .fArray [fNbins ];
825838 if (!fParent ) SetDefaults ();
0 commit comments