[Numpy-svn] r6140 - in trunk/numpy: lib ma
numpy-svn at scipy.org
numpy-svn at scipy.org
Sat Dec 13 11:18:27 EST 2008
Author: ptvirtan
Date: 2008-12-13 10:18:04 -0600 (Sat, 13 Dec 2008)
New Revision: 6140
Modified:
trunk/numpy/lib/polynomial.py
trunk/numpy/ma/extras.py
Log:
Get lstsq and eigvals from numpy.linalg, not from numpy.dual. Addresses Scipy ticket #800
Modified: trunk/numpy/lib/polynomial.py
===================================================================
--- trunk/numpy/lib/polynomial.py 2008-12-05 21:35:23 UTC (rev 6139)
+++ trunk/numpy/lib/polynomial.py 2008-12-13 16:18:04 UTC (rev 6140)
@@ -15,36 +15,13 @@
from numpy.lib.twodim_base import diag, vander
from numpy.lib.shape_base import hstack, atleast_1d
from numpy.lib.function_base import trim_zeros, sort_complex
-eigvals = None
-lstsq = None
+from numpy.linalg import eigvals, lstsq
class RankWarning(UserWarning):
"""Issued by polyfit when Vandermonde matrix is rank deficient.
"""
pass
-def get_linalg_funcs():
- "Look for linear algebra functions in numpy"
- global eigvals, lstsq
- from numpy.dual import eigvals, lstsq
- return
-
-def _eigvals(arg):
- "Return the eigenvalues of the argument"
- try:
- return eigvals(arg)
- except TypeError:
- get_linalg_funcs()
- return eigvals(arg)
-
-def _lstsq(X, y, rcond):
- "Do least squares on the arguments"
- try:
- return lstsq(X, y, rcond)
- except TypeError:
- get_linalg_funcs()
- return lstsq(X, y, rcond)
-
def poly(seq_of_zeros):
"""
Return polynomial coefficients given a sequence of roots.
@@ -94,7 +71,7 @@
seq_of_zeros = atleast_1d(seq_of_zeros)
sh = seq_of_zeros.shape
if len(sh) == 2 and sh[0] == sh[1]:
- seq_of_zeros = _eigvals(seq_of_zeros)
+ seq_of_zeros = eigvals(seq_of_zeros)
elif len(sh) ==1:
pass
else:
@@ -177,7 +154,7 @@
# build companion matrix and find its eigenvalues (the roots)
A = diag(NX.ones((N-2,), p.dtype), -1)
A[0, :] = -p[1:] / p[0]
- roots = _eigvals(A)
+ roots = eigvals(A)
else:
roots = NX.array([])
@@ -500,7 +477,7 @@
# solve least squares equation for powers of x
v = vander(x, order)
- c, resids, rank, s = _lstsq(v, y, rcond)
+ c, resids, rank, s = lstsq(v, y, rcond)
# warn on rank reduction, which indicates an ill conditioned matrix
if rank != order and not full:
Modified: trunk/numpy/ma/extras.py
===================================================================
--- trunk/numpy/ma/extras.py 2008-12-05 21:35:23 UTC (rev 6139)
+++ trunk/numpy/ma/extras.py 2008-12-13 16:18:04 UTC (rev 6140)
@@ -40,7 +40,7 @@
from numpy import ndarray, array as nxarray
import numpy.core.umath as umath
from numpy.lib.index_tricks import AxisConcatenator
-from numpy.lib.polynomial import _lstsq
+from numpy.linalg import lstsq
#...............................................................................
def issequence(seq):
@@ -1033,7 +1033,7 @@
x = x / scale
# solve least squares equation for powers of x
v = vander(x, order)
- c, resids, rank, s = _lstsq(v, y.filled(0), rcond)
+ c, resids, rank, s = lstsq(v, y.filled(0), rcond)
# warn on rank reduction, which indicates an ill conditioned matrix
if rank != order and not full:
warnings.warn("Polyfit may be poorly conditioned", np.RankWarning)
More information about the Numpy-svn
mailing list