Consider an array with elements consisting exclusively of -1 or 1. How to get the ranges of all slices containing only 1 and have a minimum length t (for example, t=3 )
Example:
>>>a=np.array([-1,-1,1,1,1,1,1,-1,1,-1,-1,1,1,1,1], dtype=int) >>> a array([-1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1])
Then the desired conclusion for t=3 will be [(2,7),(11,15)] .