From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 92F75158009 for ; Tue, 27 Jun 2023 10:56:22 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D27AAE07DB; Tue, 27 Jun 2023 10:56:21 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id B9055E07DB for ; Tue, 27 Jun 2023 10:56:21 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E2D24335CD7 for ; Tue, 27 Jun 2023 10:56:20 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 4DD0D135 for ; Tue, 27 Jun 2023 10:56:19 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1687863341.07a7407c3e3ffd6ef563eee05ace9a3c40cdbddb.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/scipy/files/, dev-python/scipy/ X-VCS-Repository: repo/gentoo X-VCS-Files: dev-python/scipy/files/scipy-1.11.0-determinant-1x1-matrix.patch dev-python/scipy/scipy-1.11.0-r1.ebuild X-VCS-Directories: dev-python/scipy/ dev-python/scipy/files/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 07a7407c3e3ffd6ef563eee05ace9a3c40cdbddb X-VCS-Branch: master Date: Tue, 27 Jun 2023 10:56:19 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 9cf29c5f-3493-4a01-a5ca-775ac48a5ed0 X-Archives-Hash: 1e4994e24b05d8e108c86c91870804a8 commit: 07a7407c3e3ffd6ef563eee05ace9a3c40cdbddb Author: Sam James gentoo org> AuthorDate: Tue Jun 27 10:55:23 2023 +0000 Commit: Sam James gentoo org> CommitDate: Tue Jun 27 10:55:41 2023 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=07a7407c dev-python/scipy: backport det(1x1) fix Signed-off-by: Sam James gentoo.org> .../scipy-1.11.0-determinant-1x1-matrix.patch | 69 +++++++++++ dev-python/scipy/scipy-1.11.0-r1.ebuild | 128 +++++++++++++++++++++ 2 files changed, 197 insertions(+) diff --git a/dev-python/scipy/files/scipy-1.11.0-determinant-1x1-matrix.patch b/dev-python/scipy/files/scipy-1.11.0-determinant-1x1-matrix.patch new file mode 100644 index 000000000000..248ee5299f2c --- /dev/null +++ b/dev-python/scipy/files/scipy-1.11.0-determinant-1x1-matrix.patch @@ -0,0 +1,69 @@ +https://github.com/scipy/scipy/issues/18759 +https://github.com/scipy/scipy/pull/18763 +https://github.com/scipy/scipy/commit/61d892c9faa543ad80bd5e2d0bf69821188487e0 + +From 61d892c9faa543ad80bd5e2d0bf69821188487e0 Mon Sep 17 00:00:00 2001 +From: Ilhan Polat +Date: Tue, 27 Jun 2023 12:00:38 +0200 +Subject: [PATCH] MAINT:linalg.det:Return scalars for singleton inputs (#18763) + +--- a/scipy/linalg/_basic.py ++++ b/scipy/linalg/_basic.py +@@ -1001,7 +1001,8 @@ def det(a, overwrite_a=False, check_finite=True): + det : (...) float or complex + Determinant of `a`. For stacked arrays, a scalar is returned for each + (m, m) slice in the last two dimensions of the input. For example, an +- input of shape (p, q, m, m) will produce a result of shape (p, q). ++ input of shape (p, q, m, m) will produce a result of shape (p, q). If ++ all dimensions are 1 a scalar is returned regardless of ndim. + + Notes + ----- +@@ -1066,11 +1067,17 @@ def det(a, overwrite_a=False, check_finite=True): + + # Scalar case + if a1.shape[-2:] == (1, 1): +- if a1.dtype.char in 'dD': +- return np.squeeze(a1) ++ # Either ndarray with spurious singletons or a single element ++ if max(*a1.shape) > 1: ++ temp = np.squeeze(a1) ++ if a1.dtype.char in 'dD': ++ return temp ++ else: ++ return (temp.astype('d') if a1.dtype.char == 'f' else ++ temp.astype('D')) + else: +- return (np.squeeze(a1).astype('d') if a1.dtype.char == 'f' else +- np.squeeze(a1).astype('D')) ++ return (np.float64(a1.item()) if a1.dtype.char in 'fd' else ++ np.complex128(a1.item())) + + # Then check overwrite permission + if not _datacopied(a1, a): # "a" still alive through "a1" +--- a/scipy/linalg/tests/test_basic.py ++++ b/scipy/linalg/tests/test_basic.py +@@ -930,6 +930,23 @@ class TestDet: + def setup_method(self): + self.rng = np.random.default_rng(1680305949878959) + ++ def test_1x1_all_singleton_dims(self): ++ a = np.array([[1]]) ++ deta = det(a) ++ assert deta.dtype.char == 'd' ++ assert np.isscalar(deta) ++ assert deta == 1. ++ a = np.array([[[[1]]]], dtype='f') ++ deta = det(a) ++ assert deta.dtype.char == 'd' ++ assert np.isscalar(deta) ++ assert deta == 1. ++ a = np.array([[[1 + 3.j]]], dtype=np.complex64) ++ deta = det(a) ++ assert deta.dtype.char == 'D' ++ assert np.isscalar(deta) ++ assert deta == 1.+3.j ++ + def test_1by1_stacked_input_output(self): + a = self.rng.random([4, 5, 1, 1], dtype=np.float32) + deta = det(a) diff --git a/dev-python/scipy/scipy-1.11.0-r1.ebuild b/dev-python/scipy/scipy-1.11.0-r1.ebuild new file mode 100644 index 000000000000..f3c49aa6ef84 --- /dev/null +++ b/dev-python/scipy/scipy-1.11.0-r1.ebuild @@ -0,0 +1,128 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +FORTRAN_NEEDED=fortran +DISTUTILS_EXT=1 +DISTUTILS_USE_PEP517=meson-python +PYTHON_COMPAT=( python3_{10..11} ) +PYTHON_REQ_USE="threads(+)" + +inherit fortran-2 distutils-r1 multiprocessing + +DESCRIPTION="Scientific algorithms library for Python" +HOMEPAGE=" + https://scipy.org/ + https://github.com/scipy/scipy/ + https://pypi.org/project/scipy/ +" + +if [[ ${PV} == *9999* ]] ; then + inherit git-r3 + + # Need submodules, so git for now. + EGIT_REPO_URI="https://github.com/scipy/scipy" + EGIT_BRANCH="maintenance/$(ver_cut 1-2).x" + EGIT_SUBMODULES=( '*' ) +else + inherit pypi + + # Upstream is often behind with doc updates + DOC_PV=${PV} + + SRC_URI+=" + doc? ( + https://docs.scipy.org/doc/${PN}-${DOC_PV}/${PN}-html-${DOC_PV}.zip + )" + + if [[ ${PV} != *rc* ]] ; then + KEYWORDS="~amd64 ~arm ~arm64 -hppa ~ia64 ~loong ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86" + fi +fi + +LICENSE="BSD LGPL-2" +SLOT="0" +IUSE="doc +fortran test-rust" + +# umfpack is technically optional but it's preferred to have it available. +DEPEND=" + >=dev-python/numpy-1.21.6[lapack,${PYTHON_USEDEP}] + sci-libs/arpack:= + sci-libs/umfpack + virtual/cblas + >=virtual/lapack-3.8 +" +RDEPEND=" + ${DEPEND} + dev-python/pillow[${PYTHON_USEDEP}] +" +BDEPEND=" + dev-lang/swig + >=dev-python/cython-0.29.35[${PYTHON_USEDEP}] + >=dev-python/meson-python-0.12.1[${PYTHON_USEDEP}] + >=dev-python/pybind11-2.10.4[${PYTHON_USEDEP}] + >=dev-util/meson-1.1.0 + dev-util/patchelf + virtual/pkgconfig + doc? ( app-arch/unzip ) + fortran? ( dev-python/pythran[${PYTHON_USEDEP}] ) + test? ( + dev-python/pytest-xdist[${PYTHON_USEDEP}] + ) + test-rust? ( + dev-python/pooch[${PYTHON_USEDEP}] + ) +" + +distutils_enable_tests pytest + +PATCHES=( + "${FILESDIR}"/${P}-determinant-1x1-matrix.patch +) + +src_unpack() { + default + + if use doc; then + unzip -qo "${DISTDIR}"/${PN}-html-${DOC_PV}.zip -d html || die + fi +} + +python_configure_all() { + DISTUTILS_ARGS=( + -Dblas=blas + -Dlapack=lapack + -Duse-pythran=$(usex fortran true false) + ) +} + +python_test() { + cd "${BUILD_DIR}/install$(python_get_sitedir)" || die + + local EPYTEST_DESELECT=( + # Network + scipy/datasets/tests/test_data.py::TestDatasets::test_existence_all + scipy/datasets/tests/test_data.py::TestDatasets::test_ascent + scipy/datasets/tests/test_data.py::TestDatasets::test_face + scipy/datasets/tests/test_data.py::TestDatasets::test_electrocardiogram + + # Precision issue with diff. blas? + scipy/optimize/tests/test__basinhopping.py::Test_Metropolis::test_gh7799 + ) + local EPYTEST_IGNORE=() + + if ! has_version -b "dev-python/pooch[${PYTHON_USEDEP}]" ; then + EPYTEST_IGNORE+=( + scipy/datasets/tests/test_data.py + ) + fi + + epytest -n "$(makeopts_jobs)" scipy +} + +python_install_all() { + use doc && local HTML_DOCS=( "${WORKDIR}"/html/. ) + + distutils-r1_python_install_all +}