[Numpy-discussion] ‎ Find contiguous sequences of booleans in arrays

Kurdt Bane kurdt.bane at gmail.com
Mon Sep 17 06:18:51 EDT 2007


Hi to all,

I've got an 1-D array of bools and I'd like to find the length of the first
contiguous sequence of True values, starting from position [0] of the array.
(That's equivalent to find the position of the first occurrence of False in
the array).
The problem is trivial, but I was wondering: what's the best (fastest,
cleanest, most pythonesque) way to do it in numpy? And what if I want to get
a list of all the contiguous sequences of True values, above a given
threshold?

Thanks in advance for your advices,

Chris.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20070917/1f48d7bb/attachment.html>


More information about the NumPy-Discussion mailing list