[Numpy-discussion] matrix indexing question

Alan G Isaac aisaac@american....
Sun Mar 25 13:39:03 CDT 2007

> Em Dom, 2007-03-25 às 13:07 -0400, Alan G Isaac escreveu:
>>     >>> x[1]
>>     matrix([[1, 0]])
>> feels wrong.  (Similarly when iterating across rows.)

On Sun, 25 Mar 2007, Paulo Jose da Silva e Silva apparently wrote:
> I think the point here is that if you are using matrices, 
> then all you "should" want are matrices, just like in 
>         >> b = A(1, :)
>         b =
>              1     2

Yes, that is the idea behind this, which I am also 
accustomed to from GAUSS.  But note again that the Matlab 
equivalent ::

    >>> x=N.mat('1 2;3 4')
    >>> x[0,:]
    matrix([[1, 2]])

does provide this behavior.  The question I am raising
is a design question and is I think really not addressed
by the rule of thumb you offer.  Specifically, that rule
of thumb if it is indeed the justification of  ::

    >>> x[1]
    matrix([[3, 4]])

finds itself in basic conflict with the idea that I ought to 
be able to iterate over the objects in an iterable container.

I mean really, does this not "feel" wrong? ::

    >>> for item in x: print item.__repr__()
    matrix([[1, 2]])
    matrix([[3, 4]])

Alan Isaac

More information about the Numpy-discussion mailing list