Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Catch specgram warnings during tests #7985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 6, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added test to check if specgram() warning is raised if len(x)<=NFFT.
  • Loading branch information
DietBru committed Feb 6, 2017
commit 7893b7b6c2a4b65a27dd97cf9e90f4ec27207d99
9 changes: 9 additions & 0 deletions 9 lib/matplotlib/tests/test_mlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import six

import tempfile
import warnings

from numpy.testing import (assert_allclose, assert_almost_equal,
assert_array_equal)
Expand Down Expand Up @@ -2103,6 +2104,14 @@ def test_specgram_phase(self):
assert spec.shape[0] == freqs.shape[0]
assert spec.shape[1] == self.t_specgram.shape[0]

def test_specgram_warn_only1seg(self):
"""Warning should be raised if len(x) <= len(NFFT). """
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<= NFFT I think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of Course. Thanks.

with warnings.catch_warnings(record=True) as w:
mlab.specgram(x=self.y, NFFT=len(self.y), Fs=self.Fs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just before this line will need a line with

warnings.simplefilter('always')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Thanks.

assert len(w) == 1
assert issubclass(w[0].category, UserWarning)
assert str(w[0].message).startswith("Only one segment is calculated")

def test_psd_csd_equal(self):
freqs = self.freqs_density
Pxx, freqsxx = mlab.psd(x=self.y,
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.