jbn / ZigZag

Python library for identifying the peaks and valleys of a time series.
BSD 3-Clause "New" or "Revised" License
434 stars 174 forks source link

fix last point error #13

Closed ytian closed 2 years ago

ytian commented 2 years ago

the code has some bugs for some test cases: code:

a = np.array([1, 1.2, 1.5, 1.8, 2.4, 3.3, 2.4, 1.5, 1.6]) peak_valley_pivots(a, 0.2, -0.2)

output (wrong result)

array([-1, 0, 0, 0, 0, 1, 0, 0, 1])

output (after fix)

array([-1, 0, 0, 0, 0, 1, 0, -1, 1])

jbn commented 2 years ago

0.3.0 now has a hidden option for this.

See the issue_13.ipynb file in the repo.

I'll figure out a better solution to make it more explicit though.