[SciPy-user] Handling NaN in array's

Nils Wagner nwagner at iam.uni-stuttgart.de
Fri Mar 24 02:31:38 CST 2006


 >>> b=rand(2)
 >>> linalg.cg(a,b)
(array([        nan,         nan]), 1)
 >>> linalg.cgs(a,b)
(array([        nan,         nan]), 1)
 >>> linalg.solve(a,b)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib64/python2.4/site-packages/scipy/linalg/basic.py", line 
103, in solve
    a1, b1 = map(asarray_chkfinite,(a,b))
  File "/usr/lib64/python2.4/site-packages/numpy/lib/function_base.py", 
line 167, in asarray_chkfinite
    raise ValueError, "array must not contain infs or NaNs"
ValueError: array must not contain infs or NaNs


Iterative solvers are inured to NaNs.
Also


 >>> linalg.hessenberg(a)
array([[        nan,  1.        ],
       [ 1.        ,  0.        ]])
 >>> a
array([[        nan,  1.        ],
       [ 1.        ,  0.        ]])

Nils



More information about the SciPy-user mailing list