[Numpy-discussion] Logical indexing and higher-dimensional arrays.
Stéfan van der Walt
Wed Feb 8 17:54:42 CST 2012
On Wed, Feb 8, 2012 at 6:49 AM, Travis Oliphant <email@example.com> wrote:
> There are also some very nice applications where you can select out of a 3-d volume a depth-surface defined by indexes like so:
> arr[ i[:,newaxis], j, depth]
> where arr is a 3-d array, i and j are 1-d index arrays: i = arange(arr.shape) and j = arange(arr.shape), and depth is a 2-d array of "depths". The selected result will be 2-d.
For those of you new to fancy indexing and broadcasting, have a look
at the Advanced NumPy Tutorial slides from SciPy2008:
It also includes an example like the one Travis mentioned.
More information about the NumPy-Discussion