From 7b9cdec9d52ac762e6172dd20a3c72229049c855 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Tue, 26 Jan 2021 18:24:29 -0500 Subject: [PATCH] Fix specgram test on NumPy 1.20. 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. --- lib/matplotlib/tests/test_axes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 948c3449e83f..3c0eb232ebe4 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -4452,7 +4452,7 @@ def test_specgram_angle(): def test_specgram_fs_none(): """Test axes.specgram when Fs is None, should not throw error.""" - spec, freqs, t, im = plt.specgram(np.ones(300), Fs=None) + spec, freqs, t, im = plt.specgram(np.ones(300), Fs=None, scale='linear') xmin, xmax, freq0, freq1 = im.get_extent() assert xmin == 32 and xmax == 96