[Numpy-discussion] puzzle: generate index with many ranges
Fri Jan 30 12:53:57 CST 2009
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
>> [ 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 there a way to do this only using numpy
functions (sum, repeat, ...), that means without any python "for" loop?
Sorry about being so insistent on this one but, in my experience, eliminating
those for loops makes a huge difference in terms of speed. The zip is probably
also quite costly on a very large data set.
> Numpy-discussion mailing list
Dr. Raik Gruenberg
More information about the Numpy-discussion