-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
62ad55b
Increase data length of specgram() test to remove UserWarnings (fixes…
DietBru 7893b7b
Added test to check if specgram() warning is raised if len(x)<=NFFT.
DietBru 804ade1
Typo + code beautification
DietBru 17c40aa
Test the case len(x) < NFFT for psd() to restore code coverage.
DietBru 379d128
Make sure that warning is always triggered.
DietBru 850bb2e
Restore code coverage (second attempt).
DietBru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Added test to check if specgram() warning is raised if len(x)<=NFFT.
- Loading branch information
commit 7893b7b6c2a4b65a27dd97cf9e90f4ec27207d99
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import six | ||
|
||
import tempfile | ||
import warnings | ||
|
||
from numpy.testing import (assert_allclose, assert_almost_equal, | ||
assert_array_equal) | ||
|
@@ -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). """ | ||
with warnings.catch_warnings(record=True) as w: | ||
mlab.specgram(x=self.y, NFFT=len(self.y), Fs=self.Fs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just before this line will need a line with
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<= NFFT I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of Course. Thanks.