-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
Describe the bug
When performing a variable rebin of an axis, the new variable axis does not have a name.
Steps to reproduce
import hist
h = hist.Hist(hist.axis.Regular(10, 0, 10, name="pt", label="$p_T$"), hist.axis.Regular(20, 0, 20, name="var", label="some variable"), hist.storage.Weight())
h2 = h[{"var": hist.rebin(groups=[2, 2, 4, 4, 8])}]
h2
prints:
Hist(
Regular(10, 0, 10, name='pt', label='$p_T$'),
Variable([0, 2, 4, 8, 12, 20], metadata=...),
storage=Weight()) # Sum: WeightedSum(value=0, variance=0)
One cannot then project based on the previous named axis:
h2.project("var")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/nmangane/scikit-hep-dev-2/.venv/lib/python3.12/site-packages/hist/basehist.py", line 224, in project
int_args = [self._name_to_index(a) if isinstance(a, str) else a for a in args]
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/nmangane/scikit-hep-dev-2/.venv/lib/python3.12/site-packages/hist/basehist.py", line 184, in _name_to_index
raise ValueError(f"The axis name {name} could not be found")
ValueError: The axis name var could not be found
** Package versions **
>>> hist.__version__
'2.8.0'
>>> bh.__version__
'1.5.1'
Metadata
Metadata
Assignees
Labels
No labels