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 help,
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 positions:
b =
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 have an array b with
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]
I
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)])
___
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 question was, is
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(aa,bb) for (aa,bb)
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])
rangelen = b-a+1