python3-scipy: update to 1.11.1.
This commit is contained in:
parent
b21aca70c6
commit
cfd57ede59
@ -1,74 +0,0 @@
|
||||
From 61d892c9faa543ad80bd5e2d0bf69821188487e0 Mon Sep 17 00:00:00 2001
|
||||
From: Ilhan Polat <ilhanpolat@gmail.com>
|
||||
Date: Tue, 27 Jun 2023 12:00:38 +0200
|
||||
Subject: [PATCH] MAINT:linalg.det:Return scalars for singleton inputs (#18763)
|
||||
|
||||
---
|
||||
scipy/linalg/_basic.py | 17 ++++++++++++-----
|
||||
scipy/linalg/tests/test_basic.py | 17 +++++++++++++++++
|
||||
2 files changed, 29 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/scipy/linalg/_basic.py b/scipy/linalg/_basic.py
|
||||
index 327ba1ca36ce..6faa3898f720 100644
|
||||
--- 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"
|
||||
diff --git a/scipy/linalg/tests/test_basic.py b/scipy/linalg/tests/test_basic.py
|
||||
index 983530b63ff2..40308500ec4a 100644
|
||||
--- 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)
|
@ -1,7 +1,7 @@
|
||||
# Template file for 'python3-scipy'
|
||||
pkgname=python3-scipy
|
||||
version=1.11.0
|
||||
revision=2
|
||||
version=1.11.1
|
||||
revision=1
|
||||
build_style=meson
|
||||
build_helper="python3"
|
||||
configure_args="$(vopt_if openblas "" "-Dblas=blas -Dlapack=lapack")"
|
||||
@ -16,7 +16,7 @@ maintainer="Andrew J. Hesford <ajh@sideband.org>"
|
||||
license="BSD-3-Clause"
|
||||
homepage="https://scipy.org/"
|
||||
distfiles="${PYPI_SITE}/s/scipy/scipy-${version}.tar.gz"
|
||||
checksum=f9b0248cb9d08eead44cde47cbf6339f1e9aa0dfde28f5fb27950743e317bd5d
|
||||
checksum=fb5b492fa035334fd249f0973cc79ecad8b09c604b42a127a677b45a9a3d4289
|
||||
make_check="no" # Tests need an installed copy to run and meson makes this tough
|
||||
|
||||
build_options="openblas"
|
||||
|
Loading…
Reference in New Issue
Block a user