On Mon, Mar 30, 2009 at 7:54 PM, Partridge, Matthew BGI SYD <matthew.partri...@barclaysglobal.com> wrote: > > I apologise if I'm asking an obvious question or one that has already > been addressed. > > I've tried to understand the documentation in the numpy manual on > slicing, but I'm a bit lost. I'm trying to do indexing using both > slices and index lists. I have a problem when I do something like: > > x[0, :, [0,1,2]] > > Here are a couple of examples: > >>>> a = numpy.arange(6).reshape(2,3) >>>> print a > [[0 1 2] > [3 4 5]] >>>> print a[:, [0,1,2]] # example 1 - this works as I expected > [[0 1 2] > [3 4 5]] >>>> b = numpy.arange(6).reshape(1,2,3) >>>> print b > [[[0 1 2] > [3 4 5]]] >>>> print b[0, :, [0,1,2]] # example 2 - this seems to be the transpose > of what I was expecting > [[0 3] > [1 4] > [2 5]] >>>> print b[0, [[0],[1]], [[0,1,2]]] # example 3 - this is what I > expected > [[0 1 2] > [3 4 5]] > > Am I doing something wrong? Why do we get different behaviour in > example 2 compared with example 1 or example 3? > > (I'm using numpy 1.0.3.1 on python 2.4.1 for windows, but I've tried > some more recent versions of numpy as well.) > > mattp >
that's how it works, whether we like it or not. see thread with title "is it a bug?" starting march 11 Josef _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion