[SciPy-user] cholesky decomposition fails

Chris Fonnesbeck fonnesbeck at gmail.com
Mon Oct 31 08:20:49 CST 2005


I am trying to change over some of my kalman filtering code over to
the new scipy, and have run into a failure in the cholesky
decomposition function in scipy.linalg:

from scipy.linalg import cholesky
from scipy import array

# Very simple decomposition
cholesky(array([[1,0],[0,1]]))

Using ipython for more debugging information, I get:

---------------------------------------------------------------------------
exceptions.ValueError                                Traceback (most
recent call last)

/Users/chris/<console>

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy/linalg/decomp.py
in cholesky(a=array([[ 1.,  0.],
       [ 0.,  1.]]), lower=0, overwrite_a=0)
    317
    318     """
--> 319     a1 = asarray_chkfinite(a)
        a1 = undefined
        global asarray_chkfinite = <function asarray_chkfinite at 0x48d570>
        a = array([[ 1.,  0.],
       [ 0.,  1.]])
    320     if len(a1.shape) != 2 or a1.shape[0] != a1.shape[1]:
    321         raise ValueError, 'expected square matrix'

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy_base/function_base.py
in asarray_chkfinite(x=array([[ 1.,  0.],
       [ 0.,  1.]]))
     24     """Like asarray except it checks to be sure no NaNs or
Infs are present.
     25     """
---> 26     x = asarray(x)
        x = array([[ 1.,  0.],
       [ 0.,  1.]])
        global asarray = <function asarray at 0x47de70>
     27     if not all(_nx.isfinite(x)):
     28         raise ValueError, "Array must not contain infs or nans."

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy_base/type_check.py
in asarray(a=array([[ 1.,  0.],
       [ 0.,  1.]]), typecode=None, savespace=None)
     48             r.savespace(savespace)
     49          return r
---> 50    return array(a,typecode,copy=0,savespace=savespace or 0)
        global array = <built-in function array>
        a = array([[ 1.,  0.],
       [ 0.,  1.]])
        typecode = None
        global copy = undefined
        savespace = None
     51
     52 def asfarray(a, typecode=None, savespace=None):

ValueError: Invalid type for array


Clearly, my array does not contain inf's or nan's.

C.

--
Chris Fonnesbeck
Atlanta, GA



More information about the SciPy-user mailing list