code: def cluster_over_time(stat, time, window, argmax=numpy.argmax):
      
      logging.info('Clustering events over %s s window', window)
  
      indices = []
      time_sorting = time.argsort()
      stat = stat[time_sorting]
      time = time[time_sorting]
  
      left = numpy.searchsorted(time, time - window)
      right = numpy.searchsorted(time, time + window)
      indices = numpy.zeros(len(left), dtype=numpy.uint32)
  
      # i is the index we are inspecting, j is the next one to save
      i = 0
      j = 0
      while i < len(left):
          l = left[i]
          r = right[i]
  
          # If there are no other points to compare it is obviously the max
          if (r - l) == 1:
              indices[j] = i
              j += 1
              i += 1
              continue
  
          # Find the location of the maximum within the time interval around i
          max_loc = argmax(stat[l:r]) + l
  
          # If this point is the max, we can skip to the right boundary
          if max_loc == i:
              indices[j] = i
              i = r
              j += 1
  
          # If the max is later than i, we can skip to it
          elif max_loc > i:
              i = max_loc
  
          elif max_loc < i:
              i += 1
  
      indices = indices[:j]
  
      logging.info('%d triggers remaining', len(indices))
      return time_sorting[indices]
docs: Cluster generalized transient events over time via maximum stat over a
      symmetric sliding window
  
      Parameters
      ----------
      stat: numpy.ndarray
          vector of ranking values to maximize
      time: numpy.ndarray
          time to use for clustering
      window: float
          length to cluster over
      argmax: function
          the function used to calculate the maximum value
  
      Returns
      -------
      cindex: numpy.ndarray
          The set of indices corresponding to the surviving coincidences.