[Numpy-discussion] np.dot and 'out' bug

Nicolas Rougier Nicolas.Rougier at inria.fr
Thu May 23 09:45:45 EDT 2013


Hi,

From the dot documentation, I tried something simple:

a = np.array([[1, 2], [3, 4]])
b = np.array([[1, 2], [3, 4]])
np.dot(a, b)

-> array([[ 7, 10],
          [15, 22]])

And I got expected result but if I use either a or b as output, results are wrong (and nothing in the dot documentation prevents me from doing this):

a = np.array([[1, 2], [3, 4]])
b = np.array([[1, 2], [3, 4]])
np.dot(a,b,out=a)

-> array([[ 6, 20],
          [15, 46]])

a = np.array([[1, 2], [3, 4]])
b = np.array([[1, 2], [3, 4]])
np.dot(a,b,out=b)

-> array([[ 6, 10],
          [30, 46]])


Can anyone confirm this behavior ? (tested using numpy 1.7.1)


Nicolas


More information about the NumPy-Discussion mailing list