Skip to content

Let data_info RuntimeWarning filter on message rather than module. - #5305

Merged
mhvk merged 1 commit into
astropy:masterfrom
mhvk:data-info-warning-suppression
Sep 6, 2016
Merged

Let data_info RuntimeWarning filter on message rather than module.#5305
mhvk merged 1 commit into
astropy:masterfrom
mhvk:data-info-warning-suppression

Conversation

@mhvk

@mhvk mhvk commented Sep 5, 2016

Copy link
Copy Markdown
Contributor

Currently, data_info filters out warning messages about all-NaN axes since presumably when one gathers statistics these are not useful. However, https://github.com/numpy/numpy/pull/7148/files made these message appear to originate from data_info itself rather than from numpy.lib.nanfunctions. To make this work independently of numpy version, filtering is now down by message content.

Setting milestone 1.2.2 since presumably we want that version to work well with the new numpy as well. It does not have to go back to 1.0, since data_info did not yet exist then.

@taldcroft: does this approach make sense to you?

[EDIT by TLA to fix mistake in PR number from 7985 to 7148]

IGNORE_WARNINGS = (dict(category=RuntimeWarning,
module=r'numpy\.lib\.nanfunctions'),)
IGNORE_WARNINGS = (dict(category=RuntimeWarning, message='All-NaN|'
'Mean of empty slice|Degrees of freedom <= 0'),)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I generally prefer the dict literal:

IGNORE_WARNINGS = {'category': RuntimeWarning, 
                   'message': 'All-NaN|Mean of empty slice|Degrees of freedom <= 0'}

But that's probably very subjective. 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree, but felt I should not change @taldcroft's code beyond what was strictly needed. (Note though that it still would need a tuple around it as well, as this is expected to be a tuple of dict).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note though that it still would need a tuple around it as well, as this is expected to be a tuple of dict.

ok, I missed that.

@taldcroft taldcroft self-assigned this Sep 6, 2016
@taldcroft

Copy link
Copy Markdown
Member

However, https://github.com/numpy/numpy/pull/7985/files made these message appear to originate from data_info itself rather than from numpy.lib.nanfunctions.

@mhvk - do you mean numpy/numpy#7148? The 7985 PR was confusing me because that only touches files in numpy testing. That said, I'm 👍 with this change. Doing the filtering by message content will be a bit more fragile and subject to future breakage, but with the stack-level bumping I don't see any alternative.

On the question of dict vs. {}, 👍 on maintaining the original style. I usually use {} but I think in this case I thought the data structure (tuple of dict) would be more apparent by explicitly using dict().

@mhvk

mhvk commented Sep 6, 2016

Copy link
Copy Markdown
Contributor Author

@taldcroft - sorry for having confused you; I did indeed mean the other one. Since you're OK with the approach, and prefer to keep the original style (I had indeed noticed there was a tuple around it in part because of the "odd" use of dict), I'll merge this.

@mhvk
mhvk merged commit 4103f63 into astropy:master Sep 6, 2016
@mhvk
mhvk deleted the data-info-warning-suppression branch September 6, 2016 14:15
@taldcroft

Copy link
Copy Markdown
Member

@mhvk - I edited the original description to fix the PR number for future reference.

eteq pushed a commit that referenced this pull request Dec 21, 2016
Let data_info RuntimeWarning filter on message rather than module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants