Skip to content

Commit f139e75

Browse files
authored
Merge pull request scipy#20560 from j-bowhay/turboeigvals_removal
2 parents 76f2d3c + e33e698 commit f139e75

File tree

2 files changed

+8
-101
lines changed

2 files changed

+8
-101
lines changed

scipy/linalg/_decomp.py

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
'eig_banded', 'eigvals_banded',
1717
'eigh_tridiagonal', 'eigvalsh_tridiagonal', 'hessenberg', 'cdf2rdf']
1818

19-
import warnings
20-
2119
import numpy as np
2220
from numpy import (array, isfinite, inexact, nonzero, iscomplexobj,
2321
flatnonzero, conj, asarray, argsort, empty,
@@ -26,7 +24,6 @@
2624
from scipy._lib._util import _asarray_validated
2725
from ._misc import LinAlgError, _datacopied, norm
2826
from .lapack import get_lapack_funcs, _compute_lwork
29-
from scipy._lib.deprecation import _NoValue, _deprecate_positional_args
3027

3128

3229
_I = np.array(1j, dtype='F')
@@ -283,11 +280,9 @@ def eig(a, b=None, left=False, right=True, overwrite_a=False,
283280
return w, vr
284281

285282

286-
@_deprecate_positional_args(version="1.14.0")
287283
def eigh(a, b=None, *, lower=True, eigvals_only=False, overwrite_a=False,
288-
overwrite_b=False, turbo=_NoValue, eigvals=_NoValue, type=1,
289-
check_finite=True, subset_by_index=None, subset_by_value=None,
290-
driver=None):
284+
overwrite_b=False, type=1, check_finite=True, subset_by_index=None,
285+
subset_by_value=None, driver=None):
291286
"""
292287
Solve a standard or generalized eigenvalue problem for a complex
293288
Hermitian or real symmetric matrix.
@@ -355,16 +350,6 @@ def eigh(a, b=None, *, lower=True, eigvals_only=False, overwrite_a=False,
355350
Whether to check that the input matrices contain only finite numbers.
356351
Disabling may give a performance gain, but may result in problems
357352
(crashes, non-termination) if the inputs do contain infinities or NaNs.
358-
turbo : bool, optional, deprecated
359-
.. deprecated:: 1.5.0
360-
`eigh` keyword argument `turbo` is deprecated in favour of
361-
``driver=gvd`` keyword instead and will be removed in SciPy
362-
1.14.0.
363-
eigvals : tuple (lo, hi), optional, deprecated
364-
.. deprecated:: 1.5.0
365-
`eigh` keyword argument `eigvals` is deprecated in favour of
366-
`subset_by_index` keyword instead and will be removed in SciPy
367-
1.14.0.
368353
369354
Returns
370355
-------
@@ -460,17 +445,6 @@ def eigh(a, b=None, *, lower=True, eigvals_only=False, overwrite_a=False,
460445
(5, 1)
461446
462447
"""
463-
if turbo is not _NoValue:
464-
warnings.warn("Keyword argument 'turbo' is deprecated in favour of '"
465-
"driver=gvd' keyword instead and will be removed in "
466-
"SciPy 1.14.0.",
467-
DeprecationWarning, stacklevel=2)
468-
if eigvals is not _NoValue:
469-
warnings.warn("Keyword argument 'eigvals' is deprecated in favour of "
470-
"'subset_by_index' keyword instead and will be removed "
471-
"in SciPy 1.14.0.",
472-
DeprecationWarning, stacklevel=2)
473-
474448
# set lower
475449
uplo = 'L' if lower else 'U'
476450
# Set job for Fortran routines
@@ -516,19 +490,12 @@ def eigh(a, b=None, *, lower=True, eigvals_only=False, overwrite_a=False,
516490
cplx = True if iscomplexobj(b1) else (cplx or False)
517491
drv_args.update({'overwrite_b': overwrite_b, 'itype': type})
518492

519-
# backwards-compatibility handling
520-
subset_by_index = subset_by_index if (eigvals in (None, _NoValue)) else eigvals
521-
522493
subset = (subset_by_index is not None) or (subset_by_value is not None)
523494

524495
# Both subsets can't be given
525496
if subset_by_index and subset_by_value:
526497
raise ValueError('Either index or value subset can be requested.')
527498

528-
# Take turbo into account if all conditions are met otherwise ignore
529-
if turbo not in (None, _NoValue) and b is not None:
530-
driver = 'gvx' if subset else 'gvd'
531-
532499
# Check indices if given
533500
if subset_by_index:
534501
lo, hi = (int(x) for x in subset_by_index)
@@ -943,11 +910,9 @@ def eigvals(a, b=None, overwrite_a=False, check_finite=True,
943910
homogeneous_eigvals=homogeneous_eigvals)
944911

945912

946-
@_deprecate_positional_args(version="1.14.0")
947913
def eigvalsh(a, b=None, *, lower=True, overwrite_a=False,
948-
overwrite_b=False, turbo=_NoValue, eigvals=_NoValue, type=1,
949-
check_finite=True, subset_by_index=None, subset_by_value=None,
950-
driver=None):
914+
overwrite_b=False, type=1, check_finite=True, subset_by_index=None,
915+
subset_by_value=None, driver=None):
951916
"""
952917
Solves a standard or generalized eigenvalue problem for a complex
953918
Hermitian or real symmetric matrix.
@@ -1010,15 +975,6 @@ def eigvalsh(a, b=None, *, lower=True, overwrite_a=False,
1010975
"evd", "evr", "evx" for standard problems and "gv", "gvd", "gvx" for
1011976
generalized (where b is not None) problems. See the Notes section of
1012977
`scipy.linalg.eigh`.
1013-
turbo : bool, optional, deprecated
1014-
.. deprecated:: 1.5.0
1015-
'eigvalsh' keyword argument `turbo` is deprecated in favor of
1016-
``driver=gvd`` option and will be removed in SciPy 1.14.0.
1017-
1018-
eigvals : tuple (lo, hi), optional
1019-
.. deprecated:: 1.5.0
1020-
'eigvalsh' keyword argument `eigvals` is deprecated in favor of
1021-
`subset_by_index` option and will be removed in SciPy 1.14.0.
1022978
1023979
Returns
1024980
-------
@@ -1066,11 +1022,10 @@ def eigvalsh(a, b=None, *, lower=True, overwrite_a=False,
10661022
array([-3.74637491, -0.76263923, 6.08502336, 12.42399079])
10671023
10681024
"""
1069-
return eigh(a, b=b, lower=lower, eigvals_only=True,
1070-
overwrite_a=overwrite_a, overwrite_b=overwrite_b,
1071-
turbo=turbo, eigvals=eigvals, type=type,
1072-
check_finite=check_finite, subset_by_index=subset_by_index,
1073-
subset_by_value=subset_by_value, driver=driver)
1025+
return eigh(a, b=b, lower=lower, eigvals_only=True, overwrite_a=overwrite_a,
1026+
overwrite_b=overwrite_b, type=type, check_finite=check_finite,
1027+
subset_by_index=subset_by_index, subset_by_value=subset_by_value,
1028+
driver=driver)
10741029

10751030

10761031
def eigvals_banded(a_band, lower=False, overwrite_a_band=False,

scipy/linalg/tests/test_decomp.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -844,31 +844,15 @@ def test_wrong_inputs(self):
844844
# Both value and index subsets requested
845845
assert_raises(ValueError, eigh, np.ones([3, 3]), np.ones([3, 3]),
846846
subset_by_value=[1, 2], subset_by_index=[2, 4])
847-
with np.testing.suppress_warnings() as sup:
848-
sup.filter(DeprecationWarning, "Keyword argument 'eigvals")
849-
assert_raises(ValueError, eigh, np.ones([3, 3]), np.ones([3, 3]),
850-
subset_by_value=[1, 2], eigvals=[2, 4])
851847
# Invalid upper index spec
852848
assert_raises(ValueError, eigh, np.ones([3, 3]), np.ones([3, 3]),
853849
subset_by_index=[0, 4])
854-
with np.testing.suppress_warnings() as sup:
855-
sup.filter(DeprecationWarning, "Keyword argument 'eigvals")
856-
assert_raises(ValueError, eigh, np.ones([3, 3]), np.ones([3, 3]),
857-
eigvals=[0, 4])
858850
# Invalid lower index
859851
assert_raises(ValueError, eigh, np.ones([3, 3]), np.ones([3, 3]),
860852
subset_by_index=[-2, 2])
861-
with np.testing.suppress_warnings() as sup:
862-
sup.filter(DeprecationWarning, "Keyword argument 'eigvals")
863-
assert_raises(ValueError, eigh, np.ones([3, 3]), np.ones([3, 3]),
864-
eigvals=[-2, 2])
865853
# Invalid index spec #2
866854
assert_raises(ValueError, eigh, np.ones([3, 3]), np.ones([3, 3]),
867855
subset_by_index=[2, 0])
868-
with np.testing.suppress_warnings() as sup:
869-
sup.filter(DeprecationWarning, "Keyword argument 'eigvals")
870-
assert_raises(ValueError, eigh, np.ones([3, 3]), np.ones([3, 3]),
871-
subset_by_index=[2, 0])
872856
# Invalid value spec
873857
assert_raises(ValueError, eigh, np.ones([3, 3]), np.ones([3, 3]),
874858
subset_by_value=[2, 0])
@@ -964,38 +948,6 @@ def test_eigvalsh_new_args(self):
964948
assert_equal(len(w3), 2)
965949
assert_allclose(w3, np.array([1.2, 1.3]))
966950

967-
@pytest.mark.parametrize("method", [eigh, eigvalsh])
968-
def test_deprecation_warnings(self, method):
969-
with pytest.warns(DeprecationWarning,
970-
match="Keyword argument 'turbo'"):
971-
method(np.zeros((2, 2)), turbo=True)
972-
with pytest.warns(DeprecationWarning,
973-
match="Keyword argument 'eigvals'"):
974-
method(np.zeros((2, 2)), eigvals=[0, 1])
975-
with pytest.deprecated_call(match="use keyword arguments"):
976-
method(np.zeros((2,2)), np.eye(2, 2), True)
977-
978-
def test_deprecation_results(self):
979-
a = _random_hermitian_matrix(3)
980-
b = _random_hermitian_matrix(3, posdef=True)
981-
982-
# check turbo gives same result as driver='gvd'
983-
with np.testing.suppress_warnings() as sup:
984-
sup.filter(DeprecationWarning, "Keyword argument 'turbo'")
985-
w_dep, v_dep = eigh(a, b, turbo=True)
986-
w, v = eigh(a, b, driver='gvd')
987-
assert_allclose(w_dep, w)
988-
assert_allclose(v_dep, v)
989-
990-
# check eigvals gives the same result as subset_by_index
991-
with np.testing.suppress_warnings() as sup:
992-
sup.filter(DeprecationWarning, "Keyword argument 'eigvals'")
993-
w_dep, v_dep = eigh(a, eigvals=[0, 1])
994-
w, v = eigh(a, subset_by_index=[0, 1])
995-
assert_allclose(w_dep, w)
996-
assert_allclose(v_dep, v)
997-
998-
999951
@pytest.mark.parametrize('dt', [int, float, np.float32, complex, np.complex64])
1000952
def test_empty(self, dt):
1001953
a = np.empty((0, 0), dtype=dt)

0 commit comments

Comments
 (0)