code: def peaks(x, y, lookahead=20, delta=0.00003):
      
      _max, _min = peakdetect(y, x, lookahead, delta)
      x_peaks = [p[0] for p in _max]
      y_peaks = [p[1] for p in _max]
      x_valleys = [p[0] for p in _min]
      y_valleys = [p[1] for p in _min]
      
      _peaks = [x_peaks, y_peaks]
      _valleys = [x_valleys, y_valleys]
      return {"peaks": _peaks, "valleys": _valleys}
docs: A wrapper around peakdetect to pack the return values in a nicer format