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

Function test_specgram

lib/matplotlib/tests/test_axes.py:5953–5982  ·  view source on GitHub ↗

Test axes.specgram in default (psd) mode.

()

Source from the content-addressed store, hash-verified

5951 "specgram_noise.png", "specgram_noise_linear.png"],
5952 remove_text=True, tol=0.07, style="default")
5953def test_specgram():
5954 """Test axes.specgram in default (psd) mode."""
5955
5956 # use former defaults to match existing baseline image
5957 matplotlib.rcParams['image.interpolation'] = 'nearest'
5958
5959 n = 1000
5960 Fs = 10.
5961
5962 fstims = [[Fs/4, Fs/5, Fs/11], [Fs/4.7, Fs/5.6, Fs/11.9]]
5963 NFFT_freqs = int(10 * Fs / np.min(fstims))
5964 x = np.arange(0, n, 1/Fs)
5965 y_freqs = np.concatenate(
5966 np.sin(2 * np.pi * np.multiply.outer(fstims, x)).sum(axis=1))
5967
5968 NFFT_noise = int(10 * Fs / 11)
5969 np.random.seed(0)
5970 y_noise = np.concatenate([np.random.standard_normal(n), np.random.rand(n)])
5971
5972 all_sides = ["default", "onesided", "twosided"]
5973 for y, NFFT in [(y_freqs, NFFT_freqs), (y_noise, NFFT_noise)]:
5974 noverlap = NFFT // 2
5975 pad_to = int(2 ** np.ceil(np.log2(NFFT)))
5976 for ax, sides in zip(plt.figure().subplots(3), all_sides):
5977 ax.specgram(y, NFFT=NFFT, Fs=Fs, noverlap=noverlap,
5978 pad_to=pad_to, sides=sides)
5979 for ax, sides in zip(plt.figure().subplots(3), all_sides):
5980 ax.specgram(y, NFFT=NFFT, Fs=Fs, noverlap=noverlap,
5981 pad_to=pad_to, sides=sides,
5982 scale="linear", norm=matplotlib.colors.LogNorm())
5983
5984
5985@image_comparison(

Callers

nothing calls this directly

Calls 4

minMethod · 0.80
figureMethod · 0.80
specgramMethod · 0.80
subplotsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…