小编use*_*323的帖子

numpy.isfinite()中的意外异常

由于我不明白的原因,我得到了这个例外.这是非常复杂的,我的np.array v来自,但这是异常发生时的代码:

print v, type(v)

for val in v:
    print val, type(val)

print "use isfinte() with astype(float64): "
np.isfinite(v.astype("float64"))

print "use isfinite() as usual: "
try:
    np.isfinite(v)
except Exception,e:
    print e
Run Code Online (Sandbox Code Playgroud)

这给出了以下输出:

[6.4441947744288255 7.2246449651781788 4.1028442021807656
 4.8832943929301189] <type 'numpy.ndarray'> 

6.44419477443 <type 'numpy.float64'>
7.22464496518 <type 'numpy.float64'>
4.10284420218 <type 'numpy.float64'>
4.88329439293 <type 'numpy.float64'>

np.isfinte() with astype(float64): 
[ True  True  True  True]

np.isfinte() as usual: 
ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported …
Run Code Online (Sandbox Code Playgroud)

python numpy

14
推荐指数
1
解决办法
2万
查看次数

标签 统计

numpy ×1

python ×1