code: def group(values, min_len=0, max_len=np.inf):
      
      original = np.asanyarray(values)
  
      # save the sorted order and then apply it
      order = original.argsort()
      values = original[order]
  
      # find the indexes which are duplicates
      if values.dtype.kind == 'f':
          # for floats in a sorted array, neighbors are not duplicates
          # if the difference between them is greater than approximate zero
          nondupe = np.greater(np.abs(np.diff(values)), tol.zero)
      else:
          # for ints and strings we can check exact non- equality
          # for all other types this will only work if they defined
          # an __eq__
          nondupe = values[1:] != values[:-1]
  
      dupe_idx = np.append(0, np.nonzero(nondupe)[0] + 1)
      dupe_len = np.diff(np.concatenate((dupe_idx, [len(values)])))
      dupe_ok = np.logical_and(np.greater_equal(dupe_len, min_len),
                               np.less_equal(dupe_len, max_len))
      groups = [order[i:(i + j)]
                for i, j in zip(dupe_idx[dupe_ok],
                                dupe_len[dupe_ok])]
      groups = np.array(groups)
  
      return groups
docs: Return the indices of values that are identical
  
      Parameters
      ----------
      values:     1D array
      min_len:    int, the shortest group allowed
                  All groups will have len >= min_length
      max_len:    int, the longest group allowed
                  All groups will have len <= max_length
  
      Returns
      ----------
      groups: sequence of indices to form groups
              IE [0,1,0,1] returns [[0,2], [1,3]]