diff --git a/src/boost_histogram/_internal/hist.py b/src/boost_histogram/_internal/hist.py index b9f1ef2c..9dc5b906 100644 --- a/src/boost_histogram/_internal/hist.py +++ b/src/boost_histogram/_internal/hist.py @@ -862,8 +862,12 @@ def __getitem__(self: H, index: IndexingExpr) -> H | float | Accumulator: if ind.step is not None: if getattr(ind.step, "factor", None) is not None: merge = ind.step.factor - elif getattr(ind.step, "group_mapping", None) is not None: - groups = ind.step.group_mapping(self.axes[i]) + elif ( + hasattr(ind.step, "group_mapping") + and (tmp_groups := ind.step.group_mapping(self.axes[i])) + is not None + ): + groups = tmp_groups elif callable(ind.step): if ind.step is sum: integrations.add(i) diff --git a/src/boost_histogram/tag.py b/src/boost_histogram/tag.py index 1c435495..fa4154e1 100644 --- a/src/boost_histogram/tag.py +++ b/src/boost_histogram/tag.py @@ -11,7 +11,7 @@ from ._internal.typing import AxisLike -__all__ = ("Slicer", "Locator", "at", "loc", "overflow", "underflow", "sum", "rebin") +__all__ = ("Slicer", "Locator", "at", "loc", "overflow", "underflow", "rebin", "sum") class Slicer: