On 29/04/2008, Travis E. Oliphant <[EMAIL PROTECTED]> wrote: > I'm quite persuaded now that a[i] should return a 1-d object for > arrays. In addition to the places Chuck identified, there are at > least 2 other places where special code was written to work-around the > expectation that item selection returns an object with reduced > dimensionality (a special-cased .tolist for matrices and a special-cased > getitem in the fancy indexing code). > > As the number of special-case work-arounds grows the more I'm convinced > the conceptualization is wrong. So, I now believe we should change the > a[i] for matrices to return a 1-d array. > > The only down-side I see is that a[i] != a[i,:] for matrices. > However, matrix(a[i]) == a[i,:], and so I'm not sure there is really a > problem, there. I also don't think that whatever problem may actually > be buried in the fact that type(a[i]) != type(a[i,:]) is worse than the > problem that several pieces of NumPy code actually expect hierarchical > container behavior of multi-dimensional sequences.
I am puzzled by this. What is the rationale for x[i,:] not being a 1-d object? Does this not require many special-case bits of code as well? What about a[i,...]? That is what I would use to make a hierarchical bit of code, and I would be startled to find myself in an infinite loop waiting for the dimension to become one. > I don't think making the small change to have a[i] return 1-d arrays > precludes us from that 1-d array being a bit more formalized in 1.2 as a > RowVector should we choose that direction. It does, however, fix > several real bugs right now. +1 What's more, I think we need to have a matrix-cleanliness test suite that verifies that all basic numpy tools behave identically on matrices and preserve matrixiness. But that's a big job, and for 1.2. Anne _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion