diff options
author | Michał Górny <mgorny@gentoo.org> | 2024-05-19 09:54:22 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2024-05-19 13:47:12 +0200 |
commit | 927d3eba08db355eb46d922f3b4d34532fc7b166 (patch) | |
tree | ad4ca063b4bb7065ea31ba73a5a72863c9ec2ae0 | |
parent | dev-python/pytest: Backport upstream py3.13 fixes (diff) | |
download | gentoo-927d3eba08db355eb46d922f3b4d34532fc7b166.tar.gz gentoo-927d3eba08db355eb46d922f3b4d34532fc7b166.tar.bz2 gentoo-927d3eba08db355eb46d922f3b4d34532fc7b166.zip |
dev-python/bottleneck: Backport upstream numpy-2 fixes
Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r-- | dev-python/bottleneck/bottleneck-1.3.8-r1.ebuild | 58 | ||||
-rw-r--r-- | dev-python/bottleneck/files/bottleneck-1.3.8-numpy-2.patch | 64 |
2 files changed, 122 insertions, 0 deletions
diff --git a/dev-python/bottleneck/bottleneck-1.3.8-r1.ebuild b/dev-python/bottleneck/bottleneck-1.3.8-r1.ebuild new file mode 100644 index 000000000000..5be4257cec27 --- /dev/null +++ b/dev-python/bottleneck/bottleneck-1.3.8-r1.ebuild @@ -0,0 +1,58 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +DISTUTILS_EXT=1 +DISTUTILS_USE_PEP517=setuptools +PYPI_NO_NORMALIZE=1 +PYPI_PN=${PN^} +PYTHON_COMPAT=( python3_{10..12} pypy3 ) + +inherit distutils-r1 pypi + +DESCRIPTION="Fast NumPy array functions written in C" +HOMEPAGE=" + https://github.com/pydata/bottleneck/ + https://pypi.org/project/Bottleneck/ +" + +LICENSE="BSD" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~arm64-macos ~x64-macos" + +DEPEND=" + >=dev-python/numpy-1.9.1:=[${PYTHON_USEDEP}] +" +RDEPEND=" + ${DEPEND} +" + +distutils_enable_tests pytest + +PATCHES=( + # https://github.com/pydata/bottleneck/pull/450 + "${FILESDIR}/${P}-numpy-2.patch" +) + +src_prepare() { + # don't overwrites user's optimization level + sed -e '/extra_compile_args=\["-O2"\]/d' -i setup.py || die + + distutils-r1_src_prepare +} + +python_test() { + local EPYTEST_DESELECT=() + case ${EPYTHON} in + pypy3) + EPYTEST_DESELECT+=( + # GC assumptions? + tests/memory_test.py::test_memory_leak + ) + ;; + esac + + rm -rf bottleneck || die + epytest --pyargs bottleneck +} diff --git a/dev-python/bottleneck/files/bottleneck-1.3.8-numpy-2.patch b/dev-python/bottleneck/files/bottleneck-1.3.8-numpy-2.patch new file mode 100644 index 000000000000..153b984f1fe7 --- /dev/null +++ b/dev-python/bottleneck/files/bottleneck-1.3.8-numpy-2.patch @@ -0,0 +1,64 @@ +From 787d6daa292ef013efb2ce93f100079457330363 Mon Sep 17 00:00:00 2001 +From: Ben Greiner <code@bnavigator.de> +Date: Thu, 9 May 2024 20:27:16 +0200 +Subject: [PATCH 3/3] Replace np.array(a, copy=False) with np.asarray(a) + +See https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword +--- + bottleneck/slow/move.py | 8 ++++---- + bottleneck/slow/nonreduce_axis.py | 2 +- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/bottleneck/slow/move.py b/bottleneck/slow/move.py +index 0aa06f141..76a54a24e 100644 +--- a/bottleneck/slow/move.py ++++ b/bottleneck/slow/move.py +@@ -52,7 +52,7 @@ def move_argmin(a, window, min_count=None, axis=-1): + "Slow move_argmin for unaccelerated dtype" + + def argmin(a, axis): +- a = np.array(a, copy=False) ++ a = np.asarray(a) + flip = [slice(None)] * a.ndim + flip[axis] = slice(None, None, -1) + a = a[tuple(flip)] # if tie, pick index of rightmost tie +@@ -78,7 +78,7 @@ def move_argmax(a, window, min_count=None, axis=-1): + "Slow move_argmax for unaccelerated dtype" + + def argmax(a, axis): +- a = np.array(a, copy=False) ++ a = np.asarray(a) + flip = [slice(None)] * a.ndim + flip[axis] = slice(None, None, -1) + a = a[tuple(flip)] # if tie, pick index of rightmost tie +@@ -115,7 +115,7 @@ def move_rank(a, window, min_count=None, axis=-1): + + def move_func(func, a, window, min_count=None, axis=-1, **kwargs): + "Generic moving window function implemented with a python loop." +- a = np.array(a, copy=False) ++ a = np.asarray(a) + if min_count is None: + mc = window + else: +@@ -226,7 +226,7 @@ def lastrank(a, axis=-1): + -0.5 + + """ +- a = np.array(a, copy=False) ++ a = np.asarray(a) + ndim = a.ndim + if a.size == 0: + # At least one dimension has length 0 +diff --git a/bottleneck/slow/nonreduce_axis.py b/bottleneck/slow/nonreduce_axis.py +index f09dfa739..1dd67529a 100644 +--- a/bottleneck/slow/nonreduce_axis.py ++++ b/bottleneck/slow/nonreduce_axis.py +@@ -15,7 +15,7 @@ def nanrankdata(a, axis=None): + + + def _rank(func1d, a, axis): +- a = np.array(a, copy=False) ++ a = np.asarray(a) + if axis is None: + a = a.ravel() + axis = 0 |