[NumPy-Tickets] [NumPy] #1876: dot() non-symmetrical for scalar*matrix of objects

NumPy Trac numpy-tickets@scipy....
Tue Jun 21 11:10:51 CDT 2011

#1876: dot() non-symmetrical for scalar*matrix of objects
 Reporter:  lebigot              |       Owner:  somebody   
     Type:  defect               |      Status:  new        
 Priority:  normal               |   Milestone:  Unscheduled
Component:  Other                |     Version:  1.5.1      
 Keywords:  dot, matrix, object  |  
 NumPy's dot() function has a non-symmetrical behavior for scalar
 multipliers, when one of the objects is a matrix of objects:

 >>> arr = matrix([1, 2], dtype=object)
 >>> dot(arr, 3)
 matrix([[3, 6]], dtype=object)
 >>> dot(3, arr)

 (My implementation of NumPy uses BLAS, but I think I remember also seeing
 this problem with the basic implementation.)

 A consequence of this is the following failed simple multiplication:

 >>> arr*3
 matrix([[3, 6]], dtype=object)
 >>> 3*arr
 Traceback (most recent call last):
   File "<ipython console>", line 1, in <module>
 TypeError: unsupported operand type(s) for *: 'int' and 'matrix'

 The final TypeError looks definitely like a bug.  Mathematically, one also
 wants to have a symmetrical dot() product, for scalars (both dot(3, arr)
 and dot(arr, 3) should work), no?  A symmetrical dot() product for
 matrices of objects would solve both problems.

Ticket URL: <http://projects.scipy.org/numpy/ticket/1876>
NumPy <http://projects.scipy.org/numpy>
My example project

More information about the NumPy-Tickets mailing list