[Numpy-discussion] Detect subclass of ndarray

Alan G Isaac aisaac@american....
Sat Mar 24 08:44:23 CDT 2007


On Fri, 23 Mar 2007, Charles R Harris apparently wrote: 
> the following gives the wrong result:
> In [15]: I = matrix(eye(2))
> In [16]: I*ones(2)
> Out[16]: matrix([[ 1.,  1.]])
> where the output should be a column vector.

Why should this output a column?
I would prefer an exception.
Add the axis if you want it:
I*ones(2)[:,None]
works fine.

Matrix multiplication should only work
for 2d arrays.

Making a larger point:
I find the mixing of matrices and arrays
when using ``*`` to be highly suspect and
far too implicit.  This is going to bite
people.

Finally, however else this moves forward,
I think making ``*`` work differently than
``dot`` is a bad idea.

Cheers,
Alan Isaac 




More information about the Numpy-discussion mailing list