(a, tol)
return idx[:-1], np.diff(idx)
Given a sorted 1D input array `a`, e.g., [0 0, 1, 2, 3, 4, 4, 4], this
    routine returns the indices where the blocks of equal integers start and
    how long the blocks are.
Given a sorted 1D input array `a`, e.g., [0 0, 1, 2, 3, 4, 4, 4], this
    routine returns the indices where the blocks of equal integers start and
    how long the blocks are.
Given a sorted 1D input array a e . g . [ 0 0 1 2 3 4 4 4 ] this routine returns the indices where the blocks of equal integers start and how long the blocks are .
def _grp_start_len(a, tol):
    """Given a sorted 1D input array `a`, e.g., [0 0, 1, 2, 3, 4, 4, 4], this
    routine returns the indices where the blocks of equal integers start and
    how long the blocks are.
    """
    # https://stackoverflow.com/a/50394587/353337
    m = np.concatenate([[True], np.abs(a[:-1] - a[1:]) > tol, [True]])
    idx = np.flatnonzero(m)
    return idx[:-1], np.diff(idx)
def _grp_start_len ( a , tol ) : # https://stackoverflow.com/a/50394587/353337 m = np . concatenate ( [ [ True ] , np . abs ( a [ : - 1 ] - a [ 1 : ] ) > tol , [ True ] ] ) idx = np . flatnonzero ( m ) return idx [ : - 1 ] , np . diff ( idx )