Skip to content

Commit

Permalink
chore: use boost 1.80+ (#802)
Browse files Browse the repository at this point in the history
* chore: use boost 1.80

Signed-off-by: Henry Schreiner <[email protected]>

* chore: drop workaround for bug in boost-histogram <1.80

Signed-off-by: Henry Schreiner <[email protected]>

* chore: remove numpy axis

Signed-off-by: Henry Schreiner <[email protected]>

* WIP: use native axis for numpy

Signed-off-by: Henry Schreiner <[email protected]>

* fix: restore regular_numpy, without a way to create it

Signed-off-by: Henry Schreiner <[email protected]>

style: pre-commit fixes

---------

Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii authored Aug 14, 2023
1 parent 5c5473f commit 728a1cd
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 32 deletions.
2 changes: 1 addition & 1 deletion extern/config
Submodule config updated 200 files
2 changes: 1 addition & 1 deletion extern/core
Submodule core updated 203 files
2 changes: 1 addition & 1 deletion extern/histogram
Submodule histogram updated 133 files
2 changes: 1 addition & 1 deletion extern/mp11
Submodule mp11 updated 69 files
+273 −45 .github/workflows/ci.yml
+1 −1 CMakeLists.txt
+1 −1 README.md
+9 −9 appveyor.yml
+52 −12 doc/mp11/algorithm.adoc
+15 −0 doc/mp11/changelog.adoc
+7 −0 doc/mp11/definitions.adoc
+10 −0 doc/mp11/integral.adoc
+154 −1 doc/mp11/list.adoc
+14 −0 doc/mp11/utility.adoc
+38 −17 include/boost/mp11/algorithm.hpp
+11 −0 include/boost/mp11/detail/config.hpp
+140 −4 include/boost/mp11/detail/mp_append.hpp
+119 −0 include/boost/mp11/detail/mp_defer.hpp
+105 −3 include/boost/mp11/detail/mp_fold.hpp
+13 −1 include/boost/mp11/detail/mp_front.hpp
+41 −0 include/boost/mp11/detail/mp_is_value_list.hpp
+27 −0 include/boost/mp11/detail/mp_list_v.hpp
+1 −1 include/boost/mp11/detail/mp_map_find.hpp
+4 −1 include/boost/mp11/detail/mp_plus.hpp
+18 −5 include/boost/mp11/detail/mp_rename.hpp
+25 −0 include/boost/mp11/detail/mp_value.hpp
+1 −0 include/boost/mp11/integral.hpp
+171 −3 include/boost/mp11/list.hpp
+14 −12 include/boost/mp11/tuple.hpp
+6 −96 include/boost/mp11/utility.hpp
+1 −1 include/boost/mp11/version.hpp
+40 −2 test/Jamfile
+60 −0 test/mp_append_3.cpp
+49 −0 test/mp_apply_q_sf.cpp
+89 −0 test/mp_assign_2.cpp
+64 −0 test/mp_at_2.cpp
+57 −0 test/mp_back_2.cpp
+32 −0 test/mp_clear_2.cpp
+58 −0 test/mp_compose_sf.cpp
+10 −0 test/mp_drop.cpp
+98 −0 test/mp_drop_2.cpp
+40 −0 test/mp_empty_2.cpp
+159 −0 test/mp_erase_2.cpp
+40 −0 test/mp_fill_2.cpp
+32 −13 test/mp_fold.cpp
+50 −0 test/mp_fold_q_sf.cpp
+45 −0 test/mp_from_sequence_2.cpp
+40 −0 test/mp_front_2.cpp
+119 −0 test/mp_insert_2.cpp
+37 −0 test/mp_iota_2.cpp
+24 −0 test/mp_is_list.cpp
+58 −0 test/mp_is_value_list.cpp
+34 −0 test/mp_list_v.cpp
+54 −0 test/mp_pop_back_2.cpp
+37 −0 test/mp_pop_front_2.cpp
+46 −0 test/mp_push_back_2.cpp
+46 −0 test/mp_push_front_2.cpp
+51 −0 test/mp_rename_2.cpp
+56 −0 test/mp_rename_v.cpp
+125 −0 test/mp_repeat_2.cpp
+48 −0 test/mp_repeat_3.cpp
+60 −0 test/mp_replace_front_2.cpp
+43 −0 test/mp_replace_second_2.cpp
+41 −0 test/mp_replace_third_2.cpp
+32 −0 test/mp_second_2.cpp
+38 −0 test/mp_size_2.cpp
+88 −0 test/mp_take_2.cpp
+32 −0 test/mp_third_2.cpp
+99 −0 test/mp_transform_front_2.cpp
+61 −0 test/mp_transform_second_2.cpp
+61 −0 test/mp_transform_third_2.cpp
+48 −0 test/mp_valid_and_true.cpp
+40 −0 test/mp_value.cpp
2 changes: 1 addition & 1 deletion extern/pybind11
Submodule pybind11 updated 105 files
5 changes: 4 additions & 1 deletion include/bh_python/axis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,10 @@ py::array_t<double> 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<A, axis::regular_numpy>::value) {
if(numpy_upper
&& !(std::is_same<A, axis::regular_none>::value
|| std::is_same<A, axis::regular_uflow>::value
|| std::is_same<A, axis::regular_numpy>::value)) {
edges.mutable_at(ax.size() + underflow) = std::nextafter(
edges.at(ax.size() + underflow), std::numeric_limits<double>::min());
}
Expand Down
1 change: 0 additions & 1 deletion src/boost_histogram/_core/axis/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
1 change: 0 additions & 1 deletion src/boost_histogram/_internal/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions src/boost_histogram/_internal/hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions src/boost_histogram/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -69,16 +66,17 @@ 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:
# Nextafter may affect bin edges slightly
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)
Expand Down
13 changes: 1 addition & 12 deletions tests/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 728a1cd

Please sign in to comment.