scikit-hep / hist

Histogramming for analysis powered by boost-histogram
https://hist.readthedocs.io
BSD 3-Clause "New" or "Revised" License
123 stars 23 forks source link

Confusing error message when using invalid start/stop for logarithmic histograms #567

Open kratsg opened 2 months ago

kratsg commented 2 months ago
>>> hist.Hist.new.StrCat(["all", "pass", "fail"], name="isEM").Log(1000, 0.0, 2000.0, name="pt", label="$pt_{\gamma}$ [GeV]").Int64()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/kratsg/radiativeDecays/venv/lib/python3.11/site-packages/hist/quick_construct.py", line 113, in Log
    axis.Regular(
  File "/Users/kratsg/radiativeDecays/venv/lib/python3.11/site-packages/hist/axis/__init__.py", line 108, in __init__
    super().__init__(
  File "/Users/kratsg/radiativeDecays/venv/lib/python3.11/site-packages/boost_histogram/_internal/axis.py", line 330, in __init__
    ax = transform._produce(bins, start, stop)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kratsg/radiativeDecays/venv/lib/python3.11/site-packages/boost_histogram/_internal/axis_transform.py", line 146, in _produce
    return self.__class__._type(bins, start, stop, self._this)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: forward transform of start or stop invalid

To an end-user, forward transform is relatively vague and maybe the error message could be more helpful such as "start and stop must be valid inputs for logarithmic" or similar?

matthewfeickert commented 2 months ago

I transfered this from https://github.com/scikit-hep/boost-histogram, even though this is ultimately a boost-histogram issue as there isn't a minimal reproducer for just boost-histogram yet. Once that is found then a boost-histogram Issue can be opened and then a PR to boost-histogram can close this Issue and the new one.