Skip to content

Commit

Permalink
add accuracy test
Browse files Browse the repository at this point in the history
  • Loading branch information
mwprestonjr committed Apr 19, 2024
1 parent ab2374f commit 5660c89
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions neurodsp/tests/spectral/test_power.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,13 @@ def test_compute_spectrum_medfilt(tsig, tsig_sine):
_, psd_medfilt = compute_spectrum(tsig_sine, FS, method='medfilt', filt_len=0.1)
assert np.allclose(psd, psd_medfilt, atol=EPS)

def test_compute_spectrum_multitaper(tsig):

freqs, spectrum = compute_spectrum_multitaper(tsig, FS)
def test_compute_spectrum_multitaper(tsig_sine):
# Shape test
freqs, spectrum = compute_spectrum_multitaper(tsig_sine, FS)
assert freqs.shape == spectrum.shape


# Accuracy test: peak at sine frequency
idx_freq_sine = np.argmin(np.abs(freqs - FREQ_SINE))
idx_peak = np.argmax(spectrum)
assert idx_freq_sine == idx_peak

0 comments on commit 5660c89

Please sign in to comment.