diff --git a/extern/assert b/extern/assert index 65068b2b..02256c84 160000 --- a/extern/assert +++ b/extern/assert @@ -1 +1 @@ -Subproject commit 65068b2b9adb23415f3b68de7a12f34e075c2101 +Subproject commit 02256c84fd0cd58a139d9dc1b25b5019ca976ada diff --git a/extern/config b/extern/config index e108255f..a1cf5d53 160000 --- a/extern/config +++ b/extern/config @@ -1 +1 @@ -Subproject commit e108255ffb5d2557ed3398b3fc575a2e9fd434cc +Subproject commit a1cf5d531405e62927b0257b5cbecc66a545b508 diff --git a/extern/core b/extern/core index a1ad1784..c7134904 160000 --- a/extern/core +++ b/extern/core @@ -1 +1 @@ -Subproject commit a1ad1784bfc21133f4d83fbf47dda961bb4a7c31 +Subproject commit c7134904e27237dbbb81ba28f0f23fc365b079dd diff --git a/extern/histogram b/extern/histogram index 8f3a3c07..a29729e6 160000 --- a/extern/histogram +++ b/extern/histogram @@ -1 +1 @@ -Subproject commit 8f3a3c07e47812460e1b6c68472fcdcf645fdcd6 +Subproject commit a29729e6682652800b06dc8aded29bbeb4acea61 diff --git a/extern/mp11 b/extern/mp11 index d15c63c0..ef7608b4 160000 --- a/extern/mp11 +++ b/extern/mp11 @@ -1 +1 @@ -Subproject commit d15c63c0a6426da25c41afa57f5260f806366289 +Subproject commit ef7608b463298b881bc82eae4f45a4385ed74fca diff --git a/extern/pybind11 b/extern/pybind11 index 5b0a6fc2..aa304c9c 160000 --- a/extern/pybind11 +++ b/extern/pybind11 @@ -1 +1 @@ -Subproject commit 5b0a6fc2017fcc176545afe3e09c9f9885283242 +Subproject commit aa304c9c7d725ffb9d10af08a3b34cb372307020 diff --git a/extern/throw_exception b/extern/throw_exception index 8c7b14f6..23dd41e9 160000 --- a/extern/throw_exception +++ b/extern/throw_exception @@ -1 +1 @@ -Subproject commit 8c7b14f68bebf8a82b4728d6a13f7601bc2b6073 +Subproject commit 23dd41e920ecd91237500ac6428f7d392a7a875c diff --git a/extern/variant2 b/extern/variant2 index e4b4b3f0..e2546b70 160000 --- a/extern/variant2 +++ b/extern/variant2 @@ -1 +1 @@ -Subproject commit e4b4b3f02beb42c3dce3b5d352bc225ea6a6cb8f +Subproject commit e2546b70ca04d4263f7a5917815506e488b6920f diff --git a/include/bh_python/axis.hpp b/include/bh_python/axis.hpp index 66acf728..f88d9e43 100644 --- a/include/bh_python/axis.hpp +++ b/include/bh_python/axis.hpp @@ -219,7 +219,10 @@ py::array_t edges(const A& ax, bool flow = false, bool numpy_upper = fal for(index_type i = -underflow; i <= ax.size() + overflow; ++i) edges.mutable_at(i + underflow) = ax.value(i); - if(numpy_upper && !std::is_same::value) { + if(numpy_upper + && !(std::is_same::value + || std::is_same::value + || std::is_same::value)) { edges.mutable_at(ax.size() + underflow) = std::nextafter( edges.at(ax.size() + underflow), std::numeric_limits::min()); } diff --git a/src/boost_histogram/_core/axis/__init__.pyi b/src/boost_histogram/_core/axis/__init__.pyi index dd9b2fc5..328046ed 100644 --- a/src/boost_histogram/_core/axis/__init__.pyi +++ b/src/boost_histogram/_core/axis/__init__.pyi @@ -57,7 +57,6 @@ class regular_oflow(_BaseRegular): ... class regular_uoflow(_BaseRegular): ... class regular_uoflow_growth(_BaseRegular): ... class regular_circular(_BaseRegular): ... -class regular_numpy(_BaseRegular): ... class regular_pow(_BaseRegular): def __init__(self, bins: int, start: float, stop: float, power: float) -> None: ... diff --git a/src/boost_histogram/_internal/axis.py b/src/boost_histogram/_internal/axis.py index 4a007854..54e061ab 100644 --- a/src/boost_histogram/_internal/axis.py +++ b/src/boost_histogram/_internal/axis.py @@ -259,7 +259,6 @@ def widths(self) -> np.typing.NDArray[Any]: ca.regular_uflow, ca.regular_oflow, ca.regular_none, - ca.regular_numpy, ca.regular_pow, ca.regular_trans, ca.regular_circular, diff --git a/src/boost_histogram/_internal/hist.py b/src/boost_histogram/_internal/hist.py index 0708247e..9fa34ef0 100644 --- a/src/boost_histogram/_internal/hist.py +++ b/src/boost_histogram/_internal/hist.py @@ -791,9 +791,6 @@ def sum(self, flow: bool = False) -> float | Accumulator: """ Compute the sum over the histogram bins (optionally including the flow bins). """ - if any(x == 0 for x in (self.axes.extent if flow else self.axes.size)): - return self.storage_type.accumulator() - return self._hist.sum(flow) # type: ignore[no-any-return] @property diff --git a/src/boost_histogram/numpy.py b/src/boost_histogram/numpy.py index 1c755df8..74487447 100644 --- a/src/boost_histogram/numpy.py +++ b/src/boost_histogram/numpy.py @@ -13,12 +13,9 @@ import numpy as np -from boost_histogram import _core - from . import axis as _axis from . import storage as _storage from ._internal import hist as _hist -from ._internal.utils import cast as _cast __all__ = ("histogram", "histogram2d", "histogramdd") @@ -69,7 +66,7 @@ def histogramdd( if range is None: range = (None,) * rank - axs = [] + axs: list[_axis.Axis] = [] for n, (b, r) in enumerate(zip(bins, range)): if np.issubdtype(type(b), np.integer): if r is None: @@ -77,8 +74,9 @@ def histogramdd( r = (np.amin(a[n]), np.amax(a[n])) # noqa: PLW2901 if r[0] == r[1]: r = (r[0] - 0.5, r[1] + 0.5) # noqa: PLW2901 - cpp_ax = _core.axis.regular_numpy(typing.cast(int, b), r[0], r[1]) - new_ax = _cast(None, cpp_ax, _axis.Axis) + new_ax = _axis.Regular( + typing.cast(int, b), r[0], r[1], underflow=False, overflow=False + ) axs.append(new_ax) else: barr: np.typing.NDArray[Any] = np.asarray(b, dtype=np.double) diff --git a/tests/test_pickle.py b/tests/test_pickle.py index 37deaec4..e4d9db57 100644 --- a/tests/test_pickle.py +++ b/tests/test_pickle.py @@ -80,10 +80,9 @@ def test_accumulators(accum, args, copy_fn): (bh.axis.StrCategory, (["1", "2", "3"],), {}), (bh.axis.StrCategory, (["1", "2", "3"],), {"growth": True}), ] -raw_axes_creations = [(bh._core.axis.regular_numpy, (4, 2, 4), {})] -@pytest.mark.parametrize(("axis", "args", "opts"), axes_creations + raw_axes_creations) +@pytest.mark.parametrize(("axis", "args", "opts"), axes_creations) def test_axes(axis, args, opts, copy_fn): orig = axis(*args, **opts) new = copy_fn(orig) @@ -188,16 +187,6 @@ def test_histogram_metadata(copy_fn, metadata): assert hist == new -def test_numpy_edge(copy_fn): - ax1 = bh._core.axis.regular_numpy(10, 0, 1) - ax2 = copy_fn(ax1) - - # stop defaults to 0, so this fails if the copy fails - assert ax1 == ax2 - assert ax1.index(1) == ax2.index(1) - assert ax2.index(1) == 9 - - @pytest.mark.skipif( platform.python_implementation() == "PyPy", reason="Not remotely supported on PyPY, hangs forever",