Python 设置未按预期抑制的打印选项

Python 设置未按预期抑制的打印选项,python,numpy,Python,Numpy,我四处看了看,找不到一个解决方案,为什么打印选项似乎正确地应用了精度,但忽略了抑制。比如说 numpy.set_printoptions(precision =4, suppress=True) 当它返回我得到的数据时 Constant Ax^3 is 1.6047898918e-16 Constant Bx^2 is 1.0 Constant Cx is 7.4485117574e-15 Constant D is -4.0 suppress=True函数似乎没有使e^数据变成我想要的0

我四处看了看,找不到一个解决方案,为什么打印选项似乎正确地应用了精度,但忽略了抑制。比如说

numpy.set_printoptions(precision =4, suppress=True)
当它返回我得到的数据时

Constant Ax^3 is 1.6047898918e-16
Constant Bx^2 is 1.0
Constant Cx is 7.4485117574e-15
Constant D is -4.0
suppress=True
函数似乎没有使
e^
数据变成我想要的
0

我测试的代码是

if degree==3:
     print 'Testing third order polynomial model', '\n'  

#Polyfit Model Produces Expected Values Using Cubic Model
p = numpy.polyfit(xData,yData,3)
yp = numpy.polyval(p,xData)
A, B, C, D = numpy.polyfit(xData,yData,3)
print 'Constant Ax^3 is',A
print 'Constant Bx^2 is',B
print 'Constant Cx is',C
print 'Constant D is',D, '\n'

你可以告诉我,我对python很陌生,但我不明白为什么它不会抑制小值。

你检查了
A
B
C
D
的类型了吗
set\u printoptions
只修改numpy对象的表示,而不是python浮动。其实,<代码>设置打印选项(抑制=真);打印(np.array([1e-15])prints
array([0.])
,但是
np.float(1e-15)
prints
1e-15
。啊,我用“%.2f”%A,B,C”来打印它。谢谢