code: def blocks(data,
             min_len=2,
             max_len=np.inf,
             digits=None,
             only_nonzero=False):
      
      data = float_to_int(data, digits=digits)
  
      # find the inflection points, or locations where the array turns
      # from True to False.
      infl = np.concatenate(([0],
                             np.nonzero(np.diff(data))[0] + 1,
                             [len(data)]))
      infl_len = np.diff(infl)
      infl_ok = np.logical_and(infl_len >= min_len,
                               infl_len <= max_len)
  
      if only_nonzero:
          # check to make sure the values of each contiguous block are True,
          # by checking the first value of each block
          infl_ok = np.logical_and(infl_ok,
                                   data[infl[:-1]])
  
      # inflate start/end indexes into full ranges of values
      blocks = [np.arange(infl[i], infl[i + 1])
                for i, ok in enumerate(infl_ok) if ok]
      return blocks
docs: Given an array, find the indices of contiguous blocks
      of equal values.
  
      Parameters
      ---------
      data:    (n) array
      min_len: int, the minimum length group to be returned
      max_len: int, the maximum length group to be retuurned
      digits:  if dealing with floats, how many digits to use
      only_nonzero: bool, only return blocks of non- zero values
  
      Returns
      ---------
      blocks: (m) sequence of indices referencing data