Kurdt Bane wrote: > 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). One possibility would be to find the first True and then use cumproduct to get the length, and then create a view with the remaining elements, recursively. But this may be slow. You may be a bit smarter to get the index of the first True value for each sub-sequence by multiplying the array by itself, shifted by one, and using xor. Whether this is pythonic and clean, I don't know :)
cheers, David _______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
