[Numpy-discussion] matrix vs. array

Andrew Straw strawman at astraw.com
Wed Mar 15 09:21:18 CST 2006


Bill Baxter wrote:

>
> On 3/15/06, *Paulo J. S. Silva* <pjssilva at ime.usp.br
> <mailto:pjssilva at ime.usp.br>> wrote:
>
>
>     > The other difference which isn't really obvious from looking at the
>     > source code is that matrices always have at least rank
>
>     Just to make clear. They *always* have rank two.
>
>
> Not necessarily.
>
> >>> m = numpy.matrix('[1 2 3; 4 5 6]')
> >>> mm = m[numpy.matrix('[0 1]')]
> >>> m
> matrix([[1, 2, 3],
>        [4, 5, 6]])
> >>> mm
> matrix([[[[1, 2, 3]],
>
>         [[4, 5, 6]]]])
> >>> mm.shape
> (1, 2, 1, 3)
>
Could you enter this as a bug so it doesn't get forgotten?
http://projects.scipy.org/scipy/numpy/newticket

Cheers!
Andrew




More information about the Numpy-discussion mailing list