Re: [Numpy-discussion] Two questions on indexing

2010-09-16 Thread Friedrich Romstedt
2010/9/15 Mark Fenner : > One method of using indices seems to be as follows: > > In [19]: a = N.array(range(6)).reshape(3,2) > In [20]: i = N.indices([3,2]) > In [21]: r,c = i > In [22]: a[r,c] > Out[22]: > array([[0, 1], >       [2, 3], >       [4, 5]]) > > In [23]: a[tuple(i)] > Out[23]: > array

Re: [Numpy-discussion] Two questions on indexing

2010-09-15 Thread Brett Olsen
On Wed, Sep 15, 2010 at 4:38 PM, Mark Fenner wrote: > A separate question.  Suppose I have a slice for indexing that looks like: > > [:, :, 2, :, 5] > > How can I get an indexing slice for all OTHER dimension values besides > those specified.  Conceptually, something like: > > [:, :, all but 2, :,

[Numpy-discussion] Two questions on indexing

2010-09-15 Thread Mark Fenner
One method of using indices seems to be as follows: In [19]: a = N.array(range(6)).reshape(3,2) In [20]: i = N.indices([3,2]) In [21]: r,c = i In [22]: a[r,c] Out[22]: array([[0, 1],       [2, 3],       [4, 5]]) In [23]: a[tuple(i)] Out[23]: array([[0, 1],       [2, 3],       [4, 5]]) *Quest