On 16/04/2008, Stéfan van der Walt <[EMAIL PROTECTED]> wrote: > On 16/04/2008, Alan G Isaac <[EMAIL PROTECTED]> wrote: > > > The whole issue occurs because a Matrix is not a proper > > > container. > > > > > > Right. And *that* is the case because of the attempt to > > treat matrices as containers of matrices instead of as > > containers of 1d arrays. > > > > I can see no real advantage to having matrices be containers > > of row vectors instead. A row vector would just be a matrix > > (i.e., essentially 2d) that allowed 1d style indexing. > > Again I ask, have you ever needed such a thing? > > > In the Matrix world, there is no such thing as an (N,) array -- which > is why the current Matrix object behaves so strangely, and always > returns a result with ndim > 1. > > Your proposal suggests that a Matrix be a container of arrays, but it > does not address the slicing of column vectors, i.e. > > x[0] > x[0,:] > x[:,0] > > would then behave in completely different ways, whereas with ndarrays > they don't. > > If you modified the proposal to say "any slicing operation that > returns a (1,N) or (N,1) matrix should now return an (N,) ndarray", it > would be more consistent, but then, wouldn't that break some other > expected behaviour? I thought one of the powerful features of a > matrix is that it preserves the orientation of a vector slice? > > The only way I've seen so far to have consistent slicing, is to have > an N-dim Matrix object be a container of N-1 dim Matrices, up to the > 2-D case, in which it becomes a container of Vectors which, in turn, > contain scalars.
I don't think of arrays as containers of anything but scalars, so I find this whole argument from intuition extremely strange. My (draconian) suggestion would be to simply raise an exception when a matrix is indexed with a scalar. They're inherently two-dimensional; if you want a submatrix you should provide both indices (possibly including a ":"). If you actually want a subarray, as with an array, use ".A". That said, I don't actually use matrices, so I don't get a vote. Anne _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion