[Numpy-discussion] List/location of consecutive integers

josef.pktd@gmai... josef.pktd@gmai...
Mon May 25 13:13:53 CDT 2009

On Mon, May 25, 2009 at 1:57 PM, Neil Crighton <neilcrighton@gmail.com> wrote:
> Andrea Gavana <andrea.gavana <at> gmail.com> writes:
>>     this should be a very easy question but I am trying to make a
>> script run as fast as possible, so please bear with me if the solution
>> is easy and I just overlooked it.
> That's weird, I was trying to solve exactly the same problem a couple of weeks
> ago for a program I was working on. It must come up a lot.
> I ended up with a similar solution to Josef's, but it took me more than an hour
> to work it out - I should have asked here first!

Actually, I got the hint for something similar from Ray Jones earlier
in the discussion on the ndimage.measurement rewrite (find min, max
per label). It took me also more time to get the solution to work
correctly in the first place. And reading the (python part of the)
numpy source can be very instructive.


More information about the Numpy-discussion mailing list