From 3e2d9e37173e02a2e663babee06e62c2a6c1a8a5 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 23 Aug 2024 16:15:52 -0400 Subject: [PATCH] fix: the result of group_mapping() should be checked for None Signed-off-by: Henry Schreiner --- .gitmodules | 5 +---- src/boost_histogram/_internal/hist.py | 8 ++++++-- src/boost_histogram/tag.py | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.gitmodules b/.gitmodules index 371fe6e7..4cce2c4e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,4 @@ -[submodule "pybind11"] - path = extern/pybind11 - url = ../../pybind/pybind11.git -[submodule "extern/boosthistogram"] +[submodule "extern/histogram"] path = extern/histogram url = ../../boostorg/histogram.git [submodule "extern/core"] 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: