[Numpy-discussion] numpy.dot gives wrong results with floats?

Zachary Pincus zpincus at stanford.edu
Wed Mar 1 01:07:02 EST 2006


Hi folks,

I'm using numpy 0.95 and came across an odd error with numpy.dot and  
degenerate 2D floating-point arrays. See below for an illustration.


In [1]: import numpy
In [2]: numpy.version.version
Out[2]: '0.9.5'

In [3]: numpy.dot([[5]],[[1,1,1]]) # 2D int case OK
Out[3]: array([[5, 5, 5]])

In [4]: numpy.dot([[5.]],[[1,1,1]]) # 2D float case: what???
Out[4]: array([[  5.00000000e+000,   4.46601253e-316,    
5.42111867e-306]])

In [5]: numpy.dot([5.],[1,1,1]) # 1D float case OK
Out[5]: array([ 5.,  5.,  5.])

In [6]: numpy.dot([[[5.]]],[[[1,1,1]]]) # 3D float case OK
Out[6]: array([[[[ 5.,  5.,  5.]]]])


Zach




More information about the NumPy-Discussion mailing list