Skip to content

Commit

Permalink
Fix specgram test on NumPy 1.20.
Browse files Browse the repository at this point in the history
In NumPy 1.20, the fft is slight different (more accurate?) and returns
0 as the last entry, instead of some small number ~1e-30. This causes a
divide-by-zero warning in `log10`. However, this test doesn't really
care about the spectrogram, just the frequencies, so we can change the
scale to linear to avoid the warning.
  • Loading branch information
QuLogic committed Jan 27, 2021
1 parent 2ea0d63 commit 9925806
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7643,6 +7643,7 @@ def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
if mode == 'complex':
raise ValueError('Cannot plot a complex specgram')

_api.check_in_list([None, 'default', 'linear', 'dB'], scale=scale)
if scale is None or scale == 'default':
if mode in ['angle', 'phase']:
scale = 'linear'
Expand All @@ -7665,8 +7666,6 @@ def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
Z = 10. * np.log10(spec)
else:
Z = 20. * np.log10(spec)
else:
raise ValueError('Unknown scale %s', scale)

Z = np.flipud(Z)

Expand Down

0 comments on commit 9925806

Please sign in to comment.