[Numpy-discussion] matrix indexing question

Alan G Isaac aisaac at american.edu
Sun Mar 25 20:48:37 EDT 2007


> Alan G Isaac wrote: 
>> So this :: 
>>     >>> x[1] 
>>     matrix([[1, 0]]) 
>> feels wrong.  (Similarly when iterating across rows.) 
>> Of course I realize that I can just :: 
>>     >>> x.A[1] 
>>     array([1, 0]) 


On Sun, 25 Mar 2007, "Colin J. Williams" apparently wrote: 
> An array and a matrix are different animals.  Conversion 
> from one to the other should be spelled out. 


But you are just begging the question here.
The question is: when I iterate across matrix rows,
why am I iterating across matrices and not arrays.
This seems quite out of whack with general Python practice.

You cannot just say "conversion should be explicit"
because that assumes (incorrectly actually) that
the rows are matrices.  The "conversion should be explicit"
argument actually cuts in the opposite direction of what
you appear to believe.

Cheers,
Alan Isaac







More information about the NumPy-Discussion mailing list