code: def find_local_peaks(sig, radius):
      
      # TODO: Fix flat mountain scenarios.
      if np.min(sig) == np.max(sig):
          return np.empty(0)
  
      peak_inds = []
  
      i = 0
      while i < radius + 1:
          if sig[i] == max(sig[:i + radius]):
              peak_inds.append(i)
              i += radius
          else:
              i += 1
  
      while i < len(sig):
          if sig[i] == max(sig[i - radius:i + radius]):
              peak_inds.append(i)
              i += radius
          else:
              i += 1
  
      while i < len(sig):
          if sig[i] == max(sig[i - radius:]):
              peak_inds.append(i)
              i += radius
          else:
              i += 1
  
      return (np.array(peak_inds))
docs: Find all local peaks in a signal. A sample is a local peak if it is
      the largest value within the <radius> samples on its left and right.
  
      In cases where it shares the max value with nearby samples, the
      middle sample is classified as the local peak.
  
      Parameters
      ----------
      sig : numpy array
          1d numpy array of the signal.
      radius : int
          The radius in which to search for defining local maxima.