<br><br><div class="gmail_quote">On Tue, Apr 29, 2008 at 7:24 AM, Stéfan van der Walt <<a href="mailto:stefan@sun.ac.za">stefan@sun.ac.za</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Charles<br>
<br>
2008/4/29 Charles R Harris <<a href="mailto:charlesr.harris@gmail.com">charlesr.harris@gmail.com</a>>:<br>
> May I add that if I edit defmatrix.py to act like an array for scalar<br>
> indexing, then the following works.<br>
><br>
> In [1]: a = matrix(eye(2))<br>
><br>
> In [2]: array([a,a])<br>
> Out[2]:<br>
> array([[[ 1.,  0.],<br>
>          [ 0.,  1.]],<br>
><br>
>        [[ 1.,  0.],<br>
>         [ 0.,  1.]]])<br>
><br>
> This generates an error with the current version of matrix and, frankly, I<br>
> am not going to be bothered going all through the numpy c sources to special<br>
> case matrices to fix that. Someone else can do it if they wish. There are<br>
> recursive routines that expect the dimensions to decrease on each call.<br>
<br>
I'd also like to see matrices become proper hierarchical containers --<br>
the question is just how to do that.  Thus far, I'm most convinced by<br>
the arguments for RowVectors/Columns, which leaves us with a sane<br>
model for doing linear algebra, while providing the enhancements you<br>
mentioned here and in comments to another ticket.<br>
<br>
We were thinking of raising a warning on scalar indexing for 1.1, but<br>
given the above, would that be sensical?<br>
</blockquote><div><br>Hi Stefan,<br><br>The numpy c routines call PySequence_GetItem(s,i) as well as ask for the length (first index), so I think these should be left as they are for arrays in order to guarantee that matrices are compatible with all the normal array operations. This means either returning special row objects that index as expected, or returning 1D arrays. I don't think the '*' operator has these problems, but in any case that is a well documented feature of matrices.<br>
<br>Chuck<br></div><br></div><br>