File tree 1 file changed +9
-0
lines changed 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 4
4
import six
5
5
6
6
import tempfile
7
+ import warnings
7
8
8
9
from numpy .testing import (assert_allclose , assert_almost_equal ,
9
10
assert_array_equal )
@@ -2103,6 +2104,14 @@ def test_specgram_phase(self):
2103
2104
assert spec .shape [0 ] == freqs .shape [0 ]
2104
2105
assert spec .shape [1 ] == self .t_specgram .shape [0 ]
2105
2106
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
+
2106
2115
def test_psd_csd_equal (self ):
2107
2116
freqs = self .freqs_density
2108
2117
Pxx , freqsxx = mlab .psd (x = self .y ,
You can’t perform that action at this time.
0 commit comments