MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_psd_csd

Function test_psd_csd

lib/matplotlib/tests/test_axes.py:6097–6125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6095 ["psd_freqs.png", "csd_freqs.png", "psd_noise.png", "csd_noise.png"],
6096 remove_text=True, style='_classic_test', tol=0.002)
6097def test_psd_csd():
6098 n = 10000
6099 Fs = 100.
6100
6101 fstims = [[Fs/4, Fs/5, Fs/11], [Fs/4.7, Fs/5.6, Fs/11.9]]
6102 NFFT_freqs = int(1000 * Fs / np.min(fstims))
6103 x = np.arange(0, n, 1/Fs)
6104 ys_freqs = np.sin(2 * np.pi * np.multiply.outer(fstims, x)).sum(axis=1)
6105
6106 NFFT_noise = int(1000 * Fs / 11)
6107 np.random.seed(0)
6108 ys_noise = [np.random.standard_normal(n), np.random.rand(n)]
6109
6110 all_kwargs = [{"sides": "default"},
6111 {"sides": "onesided", "return_line": False},
6112 {"sides": "twosided", "return_line": True}]
6113 for ys, NFFT in [(ys_freqs, NFFT_freqs), (ys_noise, NFFT_noise)]:
6114 noverlap = NFFT // 2
6115 pad_to = int(2 ** np.ceil(np.log2(NFFT)))
6116 for ax, kwargs in zip(plt.figure().subplots(3), all_kwargs):
6117 ret = ax.psd(np.concatenate(ys), NFFT=NFFT, Fs=Fs,
6118 noverlap=noverlap, pad_to=pad_to, **kwargs)
6119 assert len(ret) == 2 + kwargs.get("return_line", False)
6120 ax.set(xlabel="", ylabel="")
6121 for ax, kwargs in zip(plt.figure().subplots(3), all_kwargs):
6122 ret = ax.csd(*ys, NFFT=NFFT, Fs=Fs,
6123 noverlap=noverlap, pad_to=pad_to, **kwargs)
6124 assert len(ret) == 2 + kwargs.get("return_line", False)
6125 ax.set(xlabel="", ylabel="")
6126
6127
6128@image_comparison(

Callers

nothing calls this directly

Calls 7

minMethod · 0.80
figureMethod · 0.80
psdMethod · 0.80
csdMethod · 0.80
subplotsMethod · 0.45
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…