-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"""Tests of `signal_processing` for pynapple""" | ||
|
||
import numpy as np | ||
import pytest | ||
|
||
import pynapple as nap | ||
|
||
|
||
def test_compute_spectrum(): | ||
t = np.linspace(0, 1, 1024) | ||
sig = nap.Tsd(d=np.random.random(1024), t=t) | ||
r = nap.compute_spectrum(sig) | ||
assert len(r[1]) == 1024 | ||
assert len(r[0]) == 1024 | ||
assert r[0].dtype == np.complex128 | ||
assert r[1].dtype == np.float64 | ||
|
||
|
||
def test_compute_welch_spectrum(): | ||
t = np.linspace(0, 1, 1024) | ||
sig = nap.Tsd(d=np.random.random(1024), t=t) | ||
r = nap.compute_welch_spectrum(sig) | ||
assert r[0].dtype == np.float64 | ||
assert r[1].dtype == np.float64 | ||
|
||
|
||
def test_compute_wavelet_transform(): | ||
t = np.linspace(0, 1, 1024) | ||
sig = nap.Tsd(d=np.random.random(1024), t=t) | ||
freqs = np.linspace(1, 600, 10) | ||
mwt = nap.compute_wavelet_transform(sig, fs=None, freqs=freqs) | ||
assert mwt.shape == (1024, 10) | ||
|
||
sig = nap.TsdFrame(d=np.random.random((1024, 4)), t=t) | ||
freqs = np.linspace(1, 600, 10) | ||
mwt = nap.compute_wavelet_transform(sig, fs=None, freqs=freqs) | ||
assert mwt.shape == (1024, 10, 4) |