[Numpy-discussion] Backwards slicing including the first element

2010-03-10 Thread Jerome Esteve
Dear all, Is there a way to give an integer value to j when using a[i:j:-1] so that the first element of the array can be included in the slice ? I would like to use some code like a[i:i-k:-1] to get a slice of length k. The numpy documentation seems to suggest that j=-1 should work: Assume

Re: [Numpy-discussion] Backwards slicing including the first element

2010-03-10 Thread Warren Weckesser
Jerome Esteve wrote: Dear all, Is there a way to give an integer value to j when using a[i:j:-1] so that the first element of the array can be included in the slice ? I would like to use some code like a[i:i-k:-1] to get a slice of length k. The numpy documentation seems to suggest

Re: [Numpy-discussion] Backwards slicing including the first element

2010-03-10 Thread Warren Weckesser
Warren Weckesser wrote: Jerome Esteve wrote: Dear all, Is there a way to give an integer value to j when using a[i:j:-1] so that the first element of the array can be included in the slice ? I would like to use some code like a[i:i-k:-1] to get a slice of length k. The numpy

Re: [Numpy-discussion] Backwards slicing including the first element

2010-03-10 Thread josef . pktd
On Wed, Mar 10, 2010 at 10:19 AM, Warren Weckesser warren.weckes...@enthought.com wrote: Warren Weckesser wrote: Jerome Esteve wrote: Dear all, Is there a way to give an integer value to j when using a[i:j:-1] so that the first element of the array can be included in the slice ? I would

Re: [Numpy-discussion] Backwards slicing including the first element

2010-03-10 Thread Chris Barker
Jerome Esteve wrote: Is there a way to give an integer value to j when using a[i:j:-1] so that the first element of the array can be included in the slice ? Is this what you are looking for? In [11]: a = np.arange(10) In [12]: a[6::-1] Out[12]: array([6, 5, 4, 3, 2, 1, 0]) I know it's not