[Scipy-svn] r6980 - in trunk: doc/release scipy/linalg scipy/linalg/tests

scipy-svn at scipy.org scipy-svn at scipy.org
Mon Nov 29 09:57:24 EST 2010


Author: rgommers
Date: 2010-11-29 08:57:24 -0600 (Mon, 29 Nov 2010)
New Revision: 6980

Modified:
   trunk/doc/release/0.9.0-notes.rst
   trunk/scipy/linalg/decomp_qr.py
   trunk/scipy/linalg/tests/test_decomp.py
Log:
DEP: remove deprecated econ kw from linalg.qr.

The mode keyword is now the same as that for numpy's qr. Closes #243.

Modified: trunk/doc/release/0.9.0-notes.rst
===================================================================
--- trunk/doc/release/0.9.0-notes.rst	2010-11-29 14:56:59 UTC (rev 6979)
+++ trunk/doc/release/0.9.0-notes.rst	2010-11-29 14:57:24 UTC (rev 6980)
@@ -144,7 +144,10 @@
 The ``output_type`` keyword in many ``scipy.ndimage`` interpolation functions
 has been removed.
 
+The ``econ`` keyword in ``scipy.linalg.qr`` has been removed. The same
+functionality is still available by specifying ``mode='economic'``.
 
+
 ``scipy.stats``
 ---------------
 

Modified: trunk/scipy/linalg/decomp_qr.py
===================================================================
--- trunk/scipy/linalg/decomp_qr.py	2010-11-29 14:56:59 UTC (rev 6979)
+++ trunk/scipy/linalg/decomp_qr.py	2010-11-29 14:57:24 UTC (rev 6980)
@@ -12,7 +12,7 @@
 from misc import _datanotshared
 
 
-def qr(a, overwrite_a=False, lwork=None, econ=None, mode='qr'):
+def qr(a, overwrite_a=False, lwork=None, mode='full'):
     """Compute QR decomposition of a matrix.
 
     Calculate the decomposition :lm:`A = Q R` where Q is unitary/orthogonal
@@ -22,28 +22,24 @@
     ----------
     a : array, shape (M, N)
         Matrix to be decomposed
-    overwrite_a : boolean
+    overwrite_a : bool, optional
         Whether data in a is overwritten (may improve performance)
-    lwork : integer
+    lwork : int, optional
         Work array size, lwork >= a.shape[1]. If None or -1, an optimal size
         is computed.
-    econ : boolean
-        Whether to compute the economy-size QR decomposition, making shapes
-        of Q and R (M, K) and (K, N) instead of (M,M) and (M,N). K=min(M,N).
-        Default is False.
-    mode : {'qr', 'r'}
+    mode : {'full', 'r', 'economic'}
         Determines what information is to be returned: either both Q and R
-        or only R.
+        ('full', default), only R ('r') or both Q and R but computed in
+        economy-size ('economic', see Notes).
 
     Returns
     -------
-    (if mode == 'qr')
-    Q : double or complex array, shape (M, M) or (M, K) for econ==True
+    Q : double or complex ndarray
+        Of shape (M, M), or (M, K) for ``mode='economic'``.  Not returned if
+        ``mode='r'``.
+    R : double or complex ndarray
+        Of shape (M, N), or (K, N) for ``mode='economic'``.  ``K = min(M, N)``.
 
-    (for any mode)
-    R : double or complex array, shape (M, N) or (K, N) for econ==True
-        Size K = min(M, N)
-
     Raises LinAlgError if decomposition fails
 
     Notes
@@ -51,6 +47,9 @@
     This is an interface to the LAPACK routines dgeqrf, zgeqrf,
     dorgqr, and zungqr.
 
+    If ``mode=economic``, the shapes of Q and R are (M, K) and (K, N) instead
+    of (M,M) and (M,N), with ``K=min(M,N)``.
+
     Examples
     --------
     >>> from scipy import random, linalg, dot
@@ -64,17 +63,18 @@
     >>> r2 = linalg.qr(a, mode='r')
     >>> allclose(r, r2)
 
-    >>> q3, r3 = linalg.qr(a, econ=True)
+    >>> q3, r3 = linalg.qr(a, mode='economic')
     >>> q3.shape, r3.shape
     ((9, 6), (6, 6))
 
     """
-    if econ is None:
-        econ = False
-    else:
-        warn("qr econ argument will be removed after scipy 0.7. "
-             "The economy transform will then be available through "
-             "the mode='economic' argument.", DeprecationWarning)
+    if mode == 'qr':
+        # 'qr' was the old default, equivalent to 'full'. Neither 'full' nor
+        # 'qr' are used below, but set to 'full' anyway to be sure
+        mode = 'full'
+    if not mode in ['full', 'qr', 'r', 'economic']:
+        raise ValueError(\
+                 "Mode argument should be one of ['full', 'r', 'economic']")
 
     a1 = asarray_chkfinite(a)
     if len(a1.shape) != 2:
@@ -92,7 +92,7 @@
     if info < 0:
         raise ValueError("illegal value in %d-th argument of internal geqrf"
                                                                     % -info)
-    if not econ or M < N:
+    if not mode == 'economic' or M < N:
         R = special_matrices.triu(qr)
     else:
         R = special_matrices.triu(qr[0:N, 0:N])
@@ -111,7 +111,7 @@
         Q, work, info = gor_un_gqr(qr[:,0:M], tau, lwork=-1, overwrite_a=1)
         lwork = work[0]
         Q, work, info = gor_un_gqr(qr[:,0:M], tau, lwork=lwork, overwrite_a=1)
-    elif econ:
+    elif mode == 'economic':
         # get optimal work array
         Q, work, info = gor_un_gqr(qr, tau, lwork=-1, overwrite_a=1)
         lwork = work[0]
@@ -201,13 +201,11 @@
     lwork : integer
         Work array size, lwork >= a.shape[1]. If None or -1, an optimal size
         is computed.
-    econ : boolean
 
     Returns
     -------
-    R : double array, shape (M, N) or (K, N) for econ==True
-        Size K = min(M, N)
-    Q : double or complex array, shape (M, M) or (M, K) for econ==True
+    R : double array, shape (M, N)
+    Q : double or complex array, shape (M, M)
 
     Raises LinAlgError if decomposition fails
 

Modified: trunk/scipy/linalg/tests/test_decomp.py
===================================================================
--- trunk/scipy/linalg/tests/test_decomp.py	2010-11-29 14:56:59 UTC (rev 6979)
+++ trunk/scipy/linalg/tests/test_decomp.py	2010-11-29 14:57:24 UTC (rev 6980)
@@ -816,7 +816,7 @@
     def test_simple_tall_e(self):
         # economy version
         a = [[8,2],[2,9],[5,3]]
-        q,r = qr(a,econ=True)
+        q,r = qr(a, mode='economic')
         assert_array_almost_equal(dot(transpose(q),q),identity(2))
         assert_array_almost_equal(dot(q,r),a)
         assert_equal(q.shape, (3,2))
@@ -852,7 +852,7 @@
         n = 100
         for k in range(2):
             a = random([m,n])
-            q,r = qr(a,econ=True)
+            q,r = qr(a, mode='economic')
             assert_array_almost_equal(dot(transpose(q),q),identity(n))
             assert_array_almost_equal(dot(q,r),a)
             assert_equal(q.shape, (m,n))




More information about the Scipy-svn mailing list