Let data_info RuntimeWarning filter on message rather than module. - #5305
Conversation
| 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'),) |
There was a problem hiding this comment.
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. 😅
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
@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 |
|
@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 |
|
@mhvk - I edited the original description to fix the PR number for future reference. |
Let data_info RuntimeWarning filter on message rather than module.
Currently,
data_infofilters 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 fromdata_infoitself rather than fromnumpy.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_infodid 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]