janpipek / physt

Python histogram library - histograms as updateable, fully semantic objects with visualization tools. [P]ython [HYST]ograms.
MIT License
129 stars 15 forks source link

Be more explicit about bins too narrow for float representation #79

Open janpipek opened 2 years ago

janpipek commented 2 years ago

If the computed range for the binning divided by the number of bins is lower than the minimum float difference at the scale, we receive an error [ValueError: Bins not in rising order.] which is not very informative.

To reproduce:

data = [1, np.nextafter(1, 2)]
physt.h1(data)

It also happens when the range is 0, like in:

data = [1, 1]
physt.h1(data)
janpipek commented 1 year ago

There should be a way how to find bins even when there is just one unique value. Numpy does that.