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

Function test_spectrum

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

Source from the content-addressed store, hash-verified

6136 "phase_spectrum_noise.png"],
6137 remove_text=True, style='_classic_test')
6138def test_spectrum():
6139 n = 10000
6140 Fs = 100.
6141
6142 fstims1 = [Fs/4, Fs/5, Fs/11]
6143 NFFT = int(1000 * Fs / min(fstims1))
6144 pad_to = int(2 ** np.ceil(np.log2(NFFT)))
6145
6146 x = np.arange(0, n, 1/Fs)
6147 y_freqs = ((np.sin(2 * np.pi * np.outer(x, fstims1)) * 10**np.arange(3))
6148 .sum(axis=1))
6149 np.random.seed(0)
6150 y_noise = np.hstack([np.random.standard_normal(n), np.random.rand(n)]) - .5
6151
6152 all_sides = ["default", "onesided", "twosided"]
6153 kwargs = {"Fs": Fs, "pad_to": pad_to}
6154 for y in [y_freqs, y_noise]:
6155 for ax, sides in zip(plt.figure().subplots(3), all_sides):
6156 spec, freqs, line = ax.magnitude_spectrum(y, sides=sides, **kwargs)
6157 ax.set(xlabel="", ylabel="")
6158 for ax, sides in zip(plt.figure().subplots(3), all_sides):
6159 spec, freqs, line = ax.magnitude_spectrum(y, sides=sides, **kwargs,
6160 scale="dB")
6161 ax.set(xlabel="", ylabel="")
6162 for ax, sides in zip(plt.figure().subplots(3), all_sides):
6163 spec, freqs, line = ax.angle_spectrum(y, sides=sides, **kwargs)
6164 ax.set(xlabel="", ylabel="")
6165 for ax, sides in zip(plt.figure().subplots(3), all_sides):
6166 spec, freqs, line = ax.phase_spectrum(y, sides=sides, **kwargs)
6167 ax.set(xlabel="", ylabel="")
6168
6169
6170def test_psd_csd_edge_cases():

Callers

nothing calls this directly

Calls 6

figureMethod · 0.80
magnitude_spectrumMethod · 0.80
angle_spectrumMethod · 0.80
phase_spectrumMethod · 0.80
subplotsMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…