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

Function test_specgram_angle

lib/matplotlib/tests/test_axes.py:6026–6057  ·  view source on GitHub ↗

Test axes.specgram in angle and phase modes.

()

Source from the content-addressed store, hash-verified

6024 "specgram_angle_noise.png", "specgram_phase_noise.png"],
6025 remove_text=True, tol=0.07, style="default")
6026def test_specgram_angle():
6027 """Test axes.specgram in angle and phase modes."""
6028
6029 # use former defaults to match existing baseline image
6030 matplotlib.rcParams['image.interpolation'] = 'nearest'
6031
6032 n = 1000
6033 Fs = 10.
6034
6035 fstims = [[Fs/4, Fs/5, Fs/11], [Fs/4.7, Fs/5.6, Fs/11.9]]
6036 NFFT_freqs = int(10 * Fs / np.min(fstims))
6037 x = np.arange(0, n, 1/Fs)
6038 y = np.sin(2 * np.pi * np.multiply.outer(fstims, x)).sum(axis=1)
6039 y[:, -1] = 1
6040 y_freqs = np.hstack(y)
6041
6042 NFFT_noise = int(10 * Fs / 11)
6043 np.random.seed(0)
6044 y_noise = np.concatenate([np.random.standard_normal(n), np.random.rand(n)])
6045
6046 all_sides = ["default", "onesided", "twosided"]
6047 for y, NFFT in [(y_freqs, NFFT_freqs), (y_noise, NFFT_noise)]:
6048 noverlap = NFFT // 2
6049 pad_to = int(2 ** np.ceil(np.log2(NFFT)))
6050 for mode in ["angle", "phase"]:
6051 for ax, sides in zip(plt.figure().subplots(3), all_sides):
6052 ax.specgram(y, NFFT=NFFT, Fs=Fs, noverlap=noverlap,
6053 pad_to=pad_to, sides=sides, mode=mode)
6054 with pytest.raises(ValueError):
6055 ax.specgram(y, NFFT=NFFT, Fs=Fs, noverlap=noverlap,
6056 pad_to=pad_to, sides=sides, mode=mode,
6057 scale="dB")
6058
6059
6060def test_specgram_fs_none():

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…