File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44import six
55
66import tempfile
7+ import warnings
78
89from numpy .testing import (assert_allclose , assert_almost_equal ,
910 assert_array_equal )
@@ -2103,6 +2104,14 @@ def test_specgram_phase(self):
21032104 assert spec .shape [0 ] == freqs .shape [0 ]
21042105 assert spec .shape [1 ] == self .t_specgram .shape [0 ]
21052106
2107+ def test_specgram_warn_only1seg (self ):
2108+ """Warning should be raised if len(x) <= len(NFFT). """
2109+ with warnings .catch_warnings (record = True ) as w :
2110+ mlab .specgram (x = self .y , NFFT = len (self .y ), Fs = self .Fs )
2111+ assert len (w ) == 1
2112+ assert issubclass (w [0 ].category , UserWarning )
2113+ assert str (w [0 ].message ).startswith ("Only one segment is calculated" )
2114+
21062115 def test_psd_csd_equal (self ):
21072116 freqs = self .freqs_density
21082117 Pxx , freqsxx = mlab .psd (x = self .y ,
You can’t perform that action at this time.
0 commit comments