From 8ec278810556abf179111303085fc5643ec4e920 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 9 Aug 2024 14:17:46 -0400 Subject: [PATCH] fix: support NumPy 2.2 Signed-off-by: Henry Schreiner --- .github/workflows/wheels.yml | 5 +++++ pyproject.toml | 1 - src/boost_histogram/_internal/hist.py | 6 ++++-- tests/test_pandaslike.py | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 223c1344..9386144d 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -115,6 +115,11 @@ jobs: - uses: yezz123/setup-uv@v4 + - uses: actions/setup-python@v4 + if: matrix.os == 'macos-14' + with: + python-version: 3.8 + - uses: pypa/cibuildwheel@v2.20 env: CIBW_BUILD: ${{ matrix.build }} diff --git a/pyproject.toml b/pyproject.toml index 7f39f4dc..c9448bf2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -167,7 +167,6 @@ test-command = "pytest --benchmark-disable {project}/tests" test-skip = [ "pp310-*", "*universal2:arm64", - "cp38-macosx_arm64", "cp*-*musllinux*", # segfault ] skip = [ diff --git a/src/boost_histogram/_internal/hist.py b/src/boost_histogram/_internal/hist.py index ab49c982..da63ea7e 100644 --- a/src/boost_histogram/_internal/hist.py +++ b/src/boost_histogram/_internal/hist.py @@ -354,8 +354,10 @@ def view( """ return _to_view(self._hist.view(flow)) - def __array__(self) -> np.typing.NDArray[Any]: - return self.view(False) + def __array__( + self, dtype: np.typing.DTypeLike | None = None, *, copy: bool | None = None + ) -> np.typing.NDArray[Any]: + return np.asarray(self.view(False), dtype=dtype, copy=copy) # type: ignore[no-any-return,call-overload] def __eq__(self, other: Any) -> bool: return hasattr(other, "_hist") and self._hist == other._hist diff --git a/tests/test_pandaslike.py b/tests/test_pandaslike.py index f83e03d3..ae58a490 100644 --- a/tests/test_pandaslike.py +++ b/tests/test_pandaslike.py @@ -11,8 +11,8 @@ class Seriesish: def __init__(self, array): self.array = np.asarray(array) - def __array__(self): - return self.array + def __array__(self, dtype=None, *, copy=None): + return np.asarray(self.array, dtype=dtype, copy=copy) def test_setting_weighted_profile_convertable():