Esempio n. 1
0
def test_ampd_peaks():
    x = np.sin(np.arange(0, 20*np.pi, np.pi/20))
    noise = np.random.sample(size=x.shape)/100  # test with just a little noise
    actual_peaks = signal.argrelmax(x)[0]
    detected_peaks = discrete.ampd_peaks(x + noise)
    assert set(detected_peaks) - set(actual_peaks) == set()
    # Grant forgiveness for first and last peaks.
    assert set(actual_peaks) - set(detected_peaks) - {actual_peaks[0], actual_peaks[-1]} == set()
Esempio n. 2
0
def test_ampd_peaks_bad_input():
    with pytest.raises(ValueError):
        discrete.ampd_peaks(np.random.sample((10, 10)))