Skip to content

Fix #5777. Don't warn when applying default style - #5778

Merged
jenshnielsen merged 3 commits into
matplotlib:masterfrom
mdboom:blacklist-warning
Jan 5, 2016
Merged

jenshnielsen merged 3 commits into
matplotlib:masterfrom
mdboom:blacklist-warning

Conversation

@mdboom

@mdboom mdboom commented Jan 1, 2016

Copy link
Copy Markdown
Member

No description provided.

@mdboom mdboom added this to the next major release (2.0) milestone Jan 1, 2016
@jenshnielsen

Copy link
Copy Markdown
Member

The context manager is badly named it does not actually catch any warnings it just resets the warning filter when leaving the context. I think you have to do:

with warnings.catch_warnings(record=True):
    warnings.simplefilter("ignore", UserWarning)
    _apply_style(rcParamsDefault)

@jenshnielsen

Copy link
Copy Markdown
Member

If I understand this correctly the with warnings.catch_warnings(record=True) means that the warning is only showed once but it is still showed exactly once

@mdboom

mdboom commented Jan 4, 2016

Copy link
Copy Markdown
Member Author

If I understand this correctly the with warnings.catch_warnings(record=True) means that the warning is only showed once but it is still showed exactly once

For me, at least, the warnings aren't shown at all, due to the record=True. But on further consideration, a think a new kwarg is better -- it will be more efficient, as there's no need to generate the warning object in the first place, only to catch and suppress it elsewhere. Updating this PR...

@jenshnielsen

Copy link
Copy Markdown
Member

It's shown once in https://travis-ci.org/matplotlib/matplotlib/jobs/99718127 but that might be do to other reasons.

@mdboom

mdboom commented Jan 4, 2016

Copy link
Copy Markdown
Member Author

Let's see if the latest commit here fixes that warning in the doc build. If not, there's probably something else to track down.

@jenshnielsen

Copy link
Copy Markdown
Member

There is still a single /home/travis/build/matplotlib/matplotlib/lib/matplotlib/style/core.py:53: UserWarning: Style includes a parameter, 'backend', that is not related to style. Ignoring so that must presumably be triggered by some other code path.

jenshnielsen added a commit that referenced this pull request Jan 5, 2016
Fix #5777.  Don't warn when applying default style
@jenshnielsen
jenshnielsen merged commit fe701e3 into matplotlib:master Jan 5, 2016
jenshnielsen added a commit to jenshnielsen/matplotlib that referenced this pull request Jan 5, 2016
@jenshnielsen jenshnielsen mentioned this pull request Jan 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants