Advertisement
nher1625

peak_finder_algo

Sep 28th, 2015
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. def peak_finder(peaks_list):
  2.     """ input must be list """
  3.     if type(peaks_list) == list:
  4.         largest_peak = None
  5.         for peak in peaks_list:
  6.             if peak >= largest_peak:
  7.                 largest_peak = peak
  8.                 break
  9.         return largest_peak
  10.     else:
  11.         raise ValueError("Input Error")
  12.  
  13. print peak_finder([1,2,45.6,45.55999])
  14.  
  15. # Algorithm traverses list in a linear fashion
  16. # It's readable but it seems generic and not very pythonic
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement