简体   繁体   English

阈值必须是数字和非 NAN,打印 numpy 数组时,为什么 numpy.nan 在 python3 中未定义

[英]threshold must be numeric and non-NAN, When printing numpy array, Why numpy.nan is undefined in python3

Im trying to print all the values of a matrix in python2 by我试图在 python2 中打印矩阵的所有值

import numpy as np
np.set_printoptions(threshold=np.nan)
print myMatrix

but its giving me the error threshold must be numeric and non-NAN但它给我的错误threshold must be numeric and non-NAN

In python3 I can print the array by在python3中,我可以通过

import sys
numpy.set_printoptions(threshold=sys.maxsize)
print(myMatrix)

But why numpy.nan isn't working in python3但是为什么 numpy.nan 在 python3 中不起作用

nunmpy.nan was never supposed to be supported .从来不应该支持nunmpy.nan This is why it doesn't work in python 3这就是它在 python 3 中不起作用的原因

正确的是: np.set_printoptions(threshold=np.inf, linewidth=np.nan)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM