Skip to content
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

Catch specgram warnings during tests #7985

Merged
merged 6 commits into from
Feb 6, 2017
Merged

Catch specgram warnings during tests #7985

merged 6 commits into from
Feb 6, 2017

Conversation

DietBru
Copy link
Contributor

@DietBru DietBru commented Jan 29, 2017

This catches the specgram() warning introduced in #7845 in test_mlab. Also an additional test was added to check if the warning is raised. Closes #7967.

'07/09/83 5:17:34 PM\n' +
'06/20/2054 2:31:45 PM\n' +
'10/31/00 11:50:23 AM\n')
'03/05/76 12:00:01 AM\n' +
Copy link
Contributor

Choose a reason for hiding this comment

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

You may as well remove the "+" to rely on implicit string concatenation.

@@ -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.

Copy link
Member

@dstansby dstansby left a comment

Choose a reason for hiding this comment

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

Looks good, apart from the extra warning statement needed

def test_specgram_warn_only1seg(self):
"""Warning should be raised if len(x) <= NFFT. """
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.

@dstansby dstansby changed the title Catch specgram warnings during tests [MRG+1] Catch specgram warnings during tests Feb 2, 2017
@dstansby
Copy link
Member

dstansby commented Feb 2, 2017

This all looks good now.

To reviewer+1: I can't get the old warnings to appear using pytest on master anymore, does anyone know why this is?

@QuLogic
Copy link
Member

QuLogic commented Feb 2, 2017

I think pytest does a better job of capturing output than nose did; you can try passing -s or --capture=no to have it not swallow output. We might also consider the pytest-warnings plugin in the future to capture and summarize these things.

@dstansby
Copy link
Member

dstansby commented Feb 2, 2017

Yep, I'm picking them up with the pytest-warnings plugin now.

@QuLogic QuLogic changed the title [MRG+1] Catch specgram warnings during tests Catch specgram warnings during tests Feb 6, 2017
@QuLogic QuLogic merged commit 6a46f04 into matplotlib:master Feb 6, 2017
@QuLogic QuLogic added this to the 2.1 (next point release) milestone Feb 6, 2017
@DietBru DietBru deleted the fix_specgram_Userwarning branch February 6, 2017 23:58
@dstansby dstansby moved this from Needs review to Done in Reviewing pull requests. Feb 8, 2017
QuLogic added a commit to QuLogic/matplotlib that referenced this pull request Jun 1, 2017
The nosig_complex_twosided_nopad_to and nosig_complex_defaultsided_nopad_to
tests appear to have been mistakes, because they repeat the parameters
used in nosig_complex_twosided_noNFFT_no_pad_to and
nosig_complex_defaultsided_noNFFT_no_pad_to, so change `None` to `-1`.

The nosig_complex_defaultsided_trim test was somehow not causing
warnings and thus not "fixed" by matplotlib#7985, but change it `len_x=1024` and
`NFFT_density=512` to be consistent with the other tests.

The nosig_complex_defaultsided_oddlen test has always been different
from its sibling tests and I suspect it was an accident, so change
`NFFT_density` to 33.

Fixes matplotlib#8393.
QuLogic added a commit to QuLogic/matplotlib that referenced this pull request Jun 2, 2017
The nosig_complex_twosided_nopad_to and nosig_complex_defaultsided_nopad_to
tests appear to have been mistakes, because they repeat the parameters
used in nosig_complex_twosided_noNFFT_no_pad_to and
nosig_complex_defaultsided_noNFFT_no_pad_to, so change `None` to `-1`.

The nosig_complex_defaultsided_trim test was somehow not causing
warnings and thus not "fixed" by matplotlib#7985, but change it `len_x=1024` and
`NFFT_density=512` to be consistent with the other tests.

The nosig_complex_defaultsided_oddlen test has always been different
from its sibling tests and I suspect it was an accident, so change
`NFFT_density` to 33.

Fixes matplotlib#8393.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants