From 2902b272267f8901f0ca9d0580c9977341768b3f Mon Sep 17 00:00:00 2001 From: Quentin Mondon-Cancel Date: Thu, 15 Nov 2018 09:11:15 +0000 Subject: [PATCH 1/2] Added a test to default the value of Fs to 2 for Axes.specgram and mlab.specgram to match docstring and mlab._spectral_helper() default value --- lib/matplotlib/axes/_axes.py | 4 +++- lib/matplotlib/mlab.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 9037674780e2..8bba13f5a8b6 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -7513,7 +7513,7 @@ def cohere(self, x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, @_preprocess_data(replace_names=["x"], label_namer=None) @docstring.dedent_interpd - def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None, + def specgram(x, NFFT=None, Fs=None, Fc=None, detrend=None, window=None, noverlap=None, cmap=None, xextent=None, pad_to=None, sides=None, scale_by_freq=None, mode=None, scale=None, @@ -7629,6 +7629,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.specgram() if mode == 'complex': raise ValueError('Cannot plot a complex specgram') diff --git a/lib/matplotlib/mlab.py b/lib/matplotlib/mlab.py index e79d13f2a53e..d0255a9ca263 100644 --- a/lib/matplotlib/mlab.py +++ b/lib/matplotlib/mlab.py @@ -1113,6 +1113,8 @@ def specgram(x, NFFT=None, Fs=None, detrend=None, window=None, noverlap = 128 # default in _spectral_helper() is noverlap = 0 if NFFT is None: NFFT = 256 # same default as in _spectral_helper() + if Fs is None: + Fs = 2 # same default as in _spectral_helper() if len(x) <= NFFT: cbook._warn_external("Only one segment is calculated since parameter " "NFFT (=%d) >= signal length (=%d)." % From d5c44c433b3054344a15b3caa02d7a80be2c4662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malaclypse=20F=C3=A9lix?= <45031721+m4laclypse@users.noreply.github.com> Date: Fri, 16 Nov 2018 10:35:54 +0000 Subject: [PATCH 2/2] Update _axes.py --- lib/matplotlib/axes/_axes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 8bba13f5a8b6..9cff2a44d207 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -7513,7 +7513,7 @@ def cohere(self, x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, @_preprocess_data(replace_names=["x"], label_namer=None) @docstring.dedent_interpd - def specgram(x, NFFT=None, Fs=None, Fc=None, detrend=None, + def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None, window=None, noverlap=None, cmap=None, xextent=None, pad_to=None, sides=None, scale_by_freq=None, mode=None, scale=None,