From: Todd M. <jm...@st...> - 2002-12-15 21:33:08
|
Magnus Lie Hetland wrote: >I can see why this happens, to some degree, but it is a bit confusing >still: > > > >>>>a = zeros([5,5]) >>>>a[[1,2,3]] >>>> >>>> >array([[0, 0, 0, 0, 0], > [0, 0, 0, 0, 0], > [0, 0, 0, 0, 0]]) > > >>>>a[[1,2]] >>>> >>>> >0 > > >>>>a[[1]] >>>> >>>> >array([[0, 0, 0, 0, 0]]) > >I was planning to use index arrays to select a subset of the rows in a >two-dimensional array, but because of the special-casing for >one-dimensional arrays of the same length as the dimensionality of the >array being indexed, it seems I can't do that (without using >put/take, which may be quite OK, I guess)... Am I right? (I see why >this behaviour is needed for tuples and slice objects; and I guess >type checking would be sort of "ugly"...) > >Of course a[[1,2],] works just as expected. > >This may not be important, but perhaps worth a sentence or example in >the manual? I.e. if you are using an index array idx and you don't >want to risk having it cast as a single index lookup, you should do > > a[idx,] > >Wouldn't that be sound advice in general? > > > Assuming you're talking about numarray here, I regard this as a 0.4 bug which you just found. Thanks! Todd |