[Numpy-discussion] numpy.dot behavior with column vector and length 1 vector
Travis Oliphant
oliphant.travis at ieee.org
Sat Jan 28 18:56:01 CST 2006
Brendan Simons wrote:
> Is this behavior expected? If so, why am I wrong in assuming these
> statements should all return the same result?
>
> PyCrust 0.9.5 - The Flakiest Python Shell
> Python 2.4.1 (#2, Mar 31 2005, 00:05:10)
> [GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import numpy
> >>> colVect = numpy.ones((3, 1))
> >>> colVect * 5.3
> array([[ 5.3],
> [ 5.3],
> [ 5.3]])
> >>> numpy.dot(colVect, 5.3)
> array([[ 5.3],
> [ 5.3],
> [ 5.3]])
> >>> colVect * [5.3]
> array([[ 5.3],
> [ 5.3],
> [ 5.3]])
> >>> numpy.dot(colVect, [5.3])
> array([ 5.3, 0. , 0. ])
This is a dotblas bug. You can always tell by testing out the original
dot function:
from numpy.core.multiarray import dot as dot_
dot_(colVect, [5.3])
does not give this result.
-Travis
More information about the Numpy-discussion
mailing list