Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing parameter initialization in Axes.specgram() #16947

Merged
merged 5 commits into from Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/matplotlib/axes/_axes.py
Expand Up @@ -7617,6 +7617,8 @@ def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
Fc = 0 # same default as in mlab._spectral_helper()
if noverlap is None:
noverlap = 128 # same default as in mlab.specgram()
if Fs is None:
Fs = 2 # same default as in mlab._spectral_helper()

if mode == 'complex':
raise ValueError('Cannot plot a complex specgram')
Expand Down
12 changes: 12 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Expand Up @@ -4166,6 +4166,18 @@ def test_specgram_angle():
scale="dB")


def test_specgram_fs_none():
"""Test axes.specgram when Fs is None, should not throw error."""

try:
spec, freqs, t, im = plt.specgram(np.ones(300), Fs=None)
except Exception as e:
raise pytest.fail("DID RAISE {0}".format(e))
Stefan-Mitic marked this conversation as resolved.
Show resolved Hide resolved

xmin, xmax, freq0, freq1 = im.get_extent()
assert xmin == 32 and xmax == 96


@image_comparison(
["psd_freqs.png", "csd_freqs.png", "psd_noise.png", "csd_noise.png"],
remove_text=True, tol=0.002)
Expand Down