Skip to content

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

@kratsg

Description

@kratsg
>>> 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions