Re: [Numpy-discussion] puzzle: generate index with many ranges

2009-02-01 Thread Raik Gruenberg
Beautiful! That should do the trick. Now let's see how this performs against the list comprehension... Thanks a lot! Raik Rick White wrote: > Here's a technique that works: > > Python 2.4.2 (#5, Nov 21 2005, 23:08:11) > [GCC 4.0.0 20041026 (Apple Computer, Inc. build 4061)] on darwin > Type "h

Re: [Numpy-discussion] puzzle: generate index with many ranges

2009-01-30 Thread Rick White
Here's a technique that works: Python 2.4.2 (#5, Nov 21 2005, 23:08:11) [GCC 4.0.0 20041026 (Apple Computer, Inc. build 4061)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import numpy as np >>> a = np.array([0,4,0,11]) >>> b = np.array([-1,11,4,15]) >>>

Re: [Numpy-discussion] puzzle: generate index with many ranges

2009-01-30 Thread Pierre GM
On Jan 30, 2009, at 1:53 PM, Raik Gruenberg wrote: > Pierre GM wrote: >> On Jan 30, 2009, at 1:11 PM, Raik Gruenberg wrote: >> >>> Mhm, I got this far. But how do I get from here to a single index >>> array >>> >>> [ 4, 5, 6, ... 10, 0, 1, 2, 3, 11, 12, 13, 14 ] ? >> >> np.concatenate([np.arange(

Re: [Numpy-discussion] puzzle: generate index with many ranges

2009-01-30 Thread Raik Gruenberg
Pierre GM wrote: > On Jan 30, 2009, at 1:11 PM, Raik Gruenberg wrote: > >> Mhm, I got this far. But how do I get from here to a single index >> array >> >> [ 4, 5, 6, ... 10, 0, 1, 2, 3, 11, 12, 13, 14 ] ? > > np.concatenate([np.arange(aa,bb) for (aa,bb) in zip(a,b)]) exactly! Now, the questio

Re: [Numpy-discussion] puzzle: generate index with many ranges

2009-01-30 Thread Pierre GM
On Jan 30, 2009, at 1:11 PM, Raik Gruenberg wrote: > > Mhm, I got this far. But how do I get from here to a single index > array > > [ 4, 5, 6, ... 10, 0, 1, 2, 3, 11, 12, 13, 14 ] ? np.concatenate([np.arange(aa,bb) for (aa,bb) in zip(a,b)]) ___ Nump

Re: [Numpy-discussion] puzzle: generate index with many ranges

2009-01-30 Thread Jim Vickroy
Raik Gruenberg wrote: Jim Vickroy wrote: Raik Gruenberg wrote: Hi there, perhaps someone has a bright idea for this one: I want to concatenate ranges of numbers into a single array (for indexing). So I have generated an array "a" with starting positions, for example: a = [4, 0, 11]

Re: [Numpy-discussion] puzzle: generate index with many ranges

2009-01-30 Thread Raik Gruenberg
Jim Vickroy wrote: > Raik Gruenberg wrote: >> Hi there, >> >> perhaps someone has a bright idea for this one: >> >> I want to concatenate ranges of numbers into a single array (for indexing). >> So I >> have generated an array "a" with starting positions, for example: >> >> a = [4, 0, 11] >> >> I

Re: [Numpy-discussion] puzzle: generate index with many ranges

2009-01-30 Thread Jim Vickroy
Raik Gruenberg wrote: > Hi there, > > perhaps someone has a bright idea for this one: > > I want to concatenate ranges of numbers into a single array (for indexing). > So I > have generated an array "a" with starting positions, for example: > > a = [4, 0, 11] > > I have an array b with stop positi

[Numpy-discussion] puzzle: generate index with many ranges

2009-01-30 Thread Raik Gruenberg
Hi there, perhaps someone has a bright idea for this one: I want to concatenate ranges of numbers into a single array (for indexing). So I have generated an array "a" with starting positions, for example: a = [4, 0, 11] I have an array b with stop positions: b = [11, 4, 15] and I would like t