Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update code formatting for test_psd_window_flattop
  • Loading branch information
gapplef authored Feb 2, 2023
commit 456c4cf0f77752a7dbbd2b56108010e95f105d49
26 changes: 8 additions & 18 deletions lib/matplotlib/tests/test_mlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,15 +672,13 @@ def test_psd_window_hanning_detrend_linear(self):

def test_psd_window_flattop(self):
# flattop window
# adaption from https://github.com/scipy/scipy/blob/v1.10.0/scipy/signal/windows/_windows.py#L562-L622
if self.NFFT_density_real <= 1:
win = np.ones(self.NFFT_density_real)
else:
a = [0.21557895, 0.41663158, 0.277263158, 0.083578947, 0.006947368]
fac = np.linspace(-np.pi, np.pi, self.NFFT_density_real)
win = np.zeros(self.NFFT_density_real)
for k in range(len(a)):
win += a[k] * np.cos(k * fac)
# adaption from https://github.com/scipy/scipy/blob\
# /v1.10.0/scipy/signal/windows/_windows.py#L562-L622
a = [0.21557895, 0.41663158, 0.277263158, 0.083578947, 0.006947368]
fac = np.linspace(-np.pi, np.pi, self.NFFT_density_real)
win = np.zeros(self.NFFT_density_real)
for k in range(len(a)):
win += a[k] * np.cos(k * fac)

spec, fsp = mlab.psd(x=self.y,
NFFT=self.NFFT_density,
Expand All @@ -695,18 +693,10 @@ def test_psd_window_flattop(self):
noverlap=0,
sides=self.sides,
window=win)
# spec_b, fsp_b = mlab.psd(x=self.y * win,
# NFFT=self.NFFT_density,
# Fs=self.Fs,
# noverlap=0,
# sides=self.sides,
# window=mlab.window_none)
assert_allclose(spec*win.sum()**2,
Comment thread
gapplef marked this conversation as resolved.
spec_a*self.Fs*(win**2).sum(),
atol=1e-08)
# assert_allclose(spec*win.sum()**2,
# spec_b*self.Fs*self.NFFT_density,
# atol=1e-08)


Comment thread
gapplef marked this conversation as resolved.
Outdated
def test_psd_windowarray(self):
freqs = self.freqs_density
Expand Down