(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.
Original ticket http://projects.scipy.org/numpy/ticket/1876 on 2011-06-21 by atmention:lebigot, assigned to unknown.
NumPy's dot() function has a non-symmetrical behavior for scalar multipliers, when one of the objects is a matrix of objects:
(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:
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.