commit:     5aa895d9c03be3b5c0d3fa80148d2ab41e79e440
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 16 07:03:07 2024 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jun 16 07:03:07 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5aa895d9
dev-python/blosc: Fix test failures with >=dev-python/numpy-2

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-python/blosc/blosc-1.11.1.ebuild              |  5 +++
 dev-python/blosc/files/blosc-1.11.1-numpy-2.patch | 51 +++++++++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/dev-python/blosc/blosc-1.11.1.ebuild 
b/dev-python/blosc/blosc-1.11.1.ebuild
index a6135a6ca9c4..d61d1db5fca0 100644
--- a/dev-python/blosc/blosc-1.11.1.ebuild
+++ b/dev-python/blosc/blosc-1.11.1.ebuild
@@ -45,6 +45,11 @@ BDEPEND="
 
 DOCS=( ANNOUNCE.rst README.rst RELEASE_NOTES.rst )
 
+PATCHES=(
+       # https://github.com/Blosc/python-blosc/pull/329
+       "${FILESDIR}/${P}-numpy-2.patch"
+)
+
 src_configure() {
        export USE_SYSTEM_BLOSC=1
        export BLOSC_DIR="${EPREFIX}/usr"

diff --git a/dev-python/blosc/files/blosc-1.11.1-numpy-2.patch 
b/dev-python/blosc/files/blosc-1.11.1-numpy-2.patch
new file mode 100644
index 000000000000..97010c0a4bf6
--- /dev/null
+++ b/dev-python/blosc/files/blosc-1.11.1-numpy-2.patch
@@ -0,0 +1,51 @@
+From 4823cb746023821166756322becd3fc242cd0b32 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgo...@gentoo.org>
+Date: Sun, 16 Jun 2024 08:59:36 +0200
+Subject: [PATCH] Fix test failures with NumPy 2
+
+* Replace deprecated `np.alltrue()` with `np.all()` (available since
+  NumPy 1.7.0).
+
+* Cast NumPy boolean to `bool()`, to ensure doctests pass both with
+  NumPy 2 (using `np.True_`) and NumPy 1 (using plain `True`).
+---
+ blosc/toplevel.py | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/blosc/toplevel.py b/blosc/toplevel.py
+index ad9c12d..4d2d413 100644
+--- a/blosc/toplevel.py
++++ b/blosc/toplevel.py
+@@ -514,7 +514,7 @@ def compress_ptr(address, items, typesize=8, clevel=9, 
shuffle=blosc.SHUFFLE,
+         items, np_array.dtype.itemsize)
+     >>> d = blosc.decompress(c)
+     >>> np_ans = numpy.fromstring(d, dtype=np_array.dtype)
+-    >>> (np_array == np_ans).all()
++    >>> bool((np_array == np_ans).all())
+     True
+ 
+     >>> import ctypes
+@@ -640,7 +640,7 @@ def decompress_ptr(bytes_like, address):
+         items, np_array.dtype.itemsize)
+     >>> np_ans = numpy.empty(items, dtype=np_array.dtype)
+     >>> nbytes = blosc.decompress_ptr(c, 
np_ans.__array_interface__['data'][0])
+-    >>> (np_array == np_ans).all()
++    >>> bool((np_array == np_ans).all())
+     True
+     >>> nbytes == items * np_array.dtype.itemsize
+     True
+@@ -769,12 +769,12 @@ def unpack_array(packed_array, **kwargs):
+     >>> len(parray) < a.size*a.itemsize
+     True
+     >>> a2 = blosc.unpack_array(parray)
+-    >>> numpy.alltrue(a == a2)
++    >>> bool(numpy.all(a == a2))
+     True
+     >>> a = numpy.array(['å', 'ç', 'ø'])
+     >>> parray = blosc.pack_array(a)
+     >>> a2 = blosc.unpack_array(parray)
+-    >>> numpy.alltrue(a == a2)
++    >>> bool(numpy.all(a == a2))
+     True
+     """
+ 

Reply via email to