Peak not found in an array

Issue #16 resolved
Nimrod Milo created an issue

Hi, I'm trying to locate the peak in the following example and the results are not as expected

example1 = [1,0,0,0,2,40,40,0]
print peakutils.indexes(example1)
#prints []
example2 = [1,0,0,0,2,40,41,0]
print peakutils.indexes(example2)
# prints [6]

It seems that the function is missing the case if there are two adjacent values.

Another example is if the peak is located in the end of the array

example1 = [1,0,0,0,2,40]
print peakutils.indexes(example1)
#prints []
example2 = [1,0,0,0,2,40,0]
print peakutils.indexes(example2)
# prints [5]

Comments (3)

  1. Lucas Hermann Negri repo owner

    Hi Milo,

    As for the first case, did you tested with git HEAD? It has been fixed some months ago (I should mark the next release...)

    The second case is by design, as the elements beyond the end of the array are undefined (you can't say that it is a peak if you don't know the next value!).

  2. Nimrod Milo reporter

    Hi @lucashnegri, I'm using version 1.0.3 (latest in pip). I'll try it with the HEAD and report.

    Regarding the second case, I think that this should be an available as an argument for bounded functions. The workaround I've used is to pad zeros to the start and end of the array.

    Thanks

  3. Log in to comment