Repository: scipy/scipy

Issue:
DEP: add actual DeprecationWarning for sym_pos-keyword of scipy.linalg.solve
Since https://github.com/scipy/scipy/pull/6775, the `sym_pos` keyword to `scipy.linalg.solve` has been deprecated through documentation only. We should raise an explicit warning so that it can be removed in the future.


Discussion:

Resolving patch:
diff --git a/scipy/linalg/_basic.py b/scipy/linalg/_basic.py
--- a/scipy/linalg/_basic.py
+++ b/scipy/linalg/_basic.py
@@ -68,10 +68,13 @@ def solve(a, b, sym_pos=False, lower=False, overwrite_a=False,
         Square input data
     b : (N, NRHS) array_like
         Input data for the right hand side.
-    sym_pos : bool, optional
-        Assume `a` is symmetric and positive definite. This key is deprecated
-        and assume_a = 'pos' keyword is recommended instead. The functionality
-        is the same. It will be removed in the future.
+    sym_pos : bool, optional, deprecated
+        Assume `a` is symmetric and positive definite.
+
+        .. deprecated:: 0.19.0
+            This keyword is deprecated and should be replaced by using
+           ``assume_a = 'pos'``. `sym_pos` will be removed in SciPy 1.11.0.
+
     lower : bool, optional
         If True, only the data contained in the lower triangle of `a`. Default
         is to use upper triangle. (ignored for ``'gen'``)
@@ -164,6 +167,10 @@ def solve(a, b, sym_pos=False, lower=False, overwrite_a=False,
 
     # Backwards compatibility - old keyword.
     if sym_pos:
+        message = ("The 'sym_pos' keyword is deprecated and should be "
+                   "replaced by using 'assume_a = \"pos\"'. 'sym_pos' will be"
+                   " removed in SciPy 1.11.0.")
+        warn(message, DeprecationWarning, stacklevel=2)
         assume_a = 'pos'
 
     if assume_a not in ('gen', 'sym', 'her', 'pos'):
diff --git a/scipy/optimize/_linprog_ip.py b/scipy/optimize/_linprog_ip.py
--- a/scipy/optimize/_linprog_ip.py
+++ b/scipy/optimize/_linprog_ip.py
@@ -114,7 +114,10 @@ def solve(r):
                 # this seems to cache the matrix factorization, so solving
                 # with multiple right hand sides is much faster
                 def solve(r, sym_pos=sym_pos):
-                    return sp.linalg.solve(M, r, sym_pos=sym_pos)
+                    if sym_pos:
+                        return sp.linalg.solve(M, r, assume_a="pos")
+                    else:
+                        return sp.linalg.solve(M, r)
     # There are many things that can go wrong here, and it's hard to say
     # what all of them are. It doesn't really matter: if the matrix can't be
     # factorized, return None. get_solver will be called again with different
diff --git a/scipy/signal/_fir_filter_design.py b/scipy/signal/_fir_filter_design.py
--- a/scipy/signal/_fir_filter_design.py
+++ b/scipy/signal/_fir_filter_design.py
@@ -1050,7 +1050,7 @@ def firls(numtaps, bands, desired, weight=None, nyq=None, fs=None):
     try:  # try the fast way
         with warnings.catch_warnings(record=True) as w:
             warnings.simplefilter('always')
-            a = solve(Q, b, sym_pos=True, check_finite=False)
+            a = solve(Q, b, assume_a="pos", check_finite=False)
         for ww in w:
             if (ww.category == LinAlgWarning and
                     str(ww.message).startswith('Ill-conditioned matrix')):


Test patch:
diff --git a/scipy/linalg/tests/test_basic.py b/scipy/linalg/tests/test_basic.py
--- a/scipy/linalg/tests/test_basic.py
+++ b/scipy/linalg/tests/test_basic.py
@@ -619,6 +619,13 @@ def test_random_complex(self):
             x = solve(a, b)
             assert_array_almost_equal(dot(a, x), b)
 
+    def test_sym_pos_dep(self):
+        with pytest.warns(
+                DeprecationWarning,
+                match="The 'sym_pos' keyword is deprecated",
+        ):
+            solve([[1.]], [1], sym_pos=True)
+
     def test_random_sym(self):
         n = 20
         a = random([n, n])
@@ -628,7 +635,7 @@ def test_random_sym(self):
                 a[i, j] = a[j, i]
         for i in range(4):
             b = random([n])
-            x = solve(a, b, sym_pos=1)
+            x = solve(a, b, assume_a="pos")
             assert_array_almost_equal(dot(a, x), b)
 
     def test_random_sym_complex(self):
@@ -641,7 +648,7 @@ def test_random_sym_complex(self):
                 a[i, j] = conjugate(a[j, i])
         b = random([n])+2j*random([n])
         for i in range(2):
-            x = solve(a, b, sym_pos=1)
+            x = solve(a, b, assume_a="pos")
             assert_array_almost_equal(dot(a, x), b)
 
     def test_check_finite(self):