MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_specgram

Method test_specgram

lib/matplotlib/tests/test_mlab.py:694–720  ·  view source on GitHub ↗
(self, kwargs)

Source from the content-addressed store, hash-verified

692 [{}, {'mode': 'default'}, {'mode': 'psd'}, {'mode': 'magnitude'},
693 {'mode': 'complex'}, {'mode': 'angle'}, {'mode': 'phase'}])
694 def test_specgram(self, kwargs):
695 freqs = self.freqs_specgram
696 spec, fsp, t = mlab.specgram(x=self.y,
697 NFFT=self.NFFT_specgram,
698 Fs=self.Fs,
699 noverlap=self.nover_specgram,
700 pad_to=self.pad_to_specgram,
701 sides=self.sides,
702 **kwargs)
703 if kwargs.get('mode') == 'complex':
704 spec = np.abs(spec)
705 specm = np.mean(spec, axis=1)
706
707 assert_allclose(fsp, freqs, atol=1e-06)
708 assert_allclose(t, self.t_specgram, atol=1e-06)
709
710 assert spec.shape[0] == freqs.shape[0]
711 assert spec.shape[1] == self.t_specgram.shape[0]
712
713 if kwargs.get('mode') not in ['complex', 'angle', 'phase']:
714 # using a single freq, so all time slices should be about the same
715 if np.abs(spec.max()) != 0:
716 assert_allclose(
717 np.diff(spec, axis=1).max() / np.abs(spec.max()), 0,
718 atol=1e-02)
719 if kwargs.get('mode') not in ['angle', 'phase']:
720 self.check_freqs(specm, freqs, fsp, self.fstims)
721
722 def test_specgram_warn_only1seg(self):
723 """Warning should be raised if len(x) <= NFFT."""

Callers

nothing calls this directly

Calls 4

check_freqsMethod · 0.95
specgramMethod · 0.80
maxMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected