[Numpy-discussion] Specifying Index Programmatically

Michael McNeil Forbes mforbes at physics.ubc.ca
Mon Aug 17 10:53:54 EDT 2009


There is also numpy.s_:

inds = np.s_[...,2,:]
z[inds]

(Though there are some problems with negative indices: see for example http://www.mail-archive.com/numpy-discussion@scipy.org/msg18245.html)

On 8 Aug 2009, at 10:02 PM, T J wrote:

> On Sat, Aug 8, 2009 at 8:54 PM, Neil Martinsen-Burrell<nmb at wartburg.edu 
> > wrote:
>>
>> The ellipsis is a built-in python constant called Ellipsis.  The  
>> colon
>> is a slice object, again a python built-in, called with None as an
>> argument.  So, z[...,2,:] == z[Ellipsis,2,slice(None)].




More information about the NumPy-Discussion mailing list