Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deprecate the 'warn' parameter to matplotlib.use(). #14144

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 1 commit into from
May 26, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented May 6, 2019

Right now, the only case where the 'warn' parameter to use() has an
observable effect is if the user calls
use(some_backend, warn=True, force=False) (the default is
warn=False, force=True) and some_backend cannot be switched to.

If they really want a warning in that case and not an exception (why?),
they can just do

try: use(some_backend)
except ImportError: warnings.warn(...)

instead.

Given the non-obvious interaction between warn and force, just
deprecate warn.

We could even deprecate force and tell user to catch ImportErrors if
they know a switch can fail and that they want to silently ignore the
switch failure, but I guess someone will complain that
use(some_backend, force=False) is so much shorter to write than

try: use(some_backend)
except ImportError: pass

...

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer anntzer added this to the v3.2.0 milestone May 6, 2019
@efiring
Copy link
Member

efiring commented May 22, 2019

I will be happy to see the "warn" kwarg go away. What has to be done to get the tests to pass with this?

@anntzer
Copy link
Contributor Author

anntzer commented May 22, 2019

someone had to remind me that the tests were failing ;)

Right now, the only case where the 'warn' parameter to use() has an
observable effect is if the user calls
`use(some_backend, warn=True, force=False)` (the default is
`warn=False, force=True`) and `some_backend` cannot be switched to.

If they really want a warning in that case and not an exception (why?),
they can just do
```
try: use(some_backend)
except ImportError: warnings.warn(...)
```
instead.

Given the non-obvious interaction between `warn` and `force`, just
deprecate `warn`.

We could even deprecate `force` and tell user to catch ImportErrors if
they know a switch can fail and that they want to silently ignore the
switch failure, but I guess someone will complain that
`use(some_backend, force=False)` is so much shorter to write than
```
try: use(some_backend)
except ImportError: pass
```
...
@efiring efiring requested a review from tacaswell May 25, 2019 20:28
@timhoffm timhoffm merged commit 7422347 into matplotlib:master May 26, 2019
@timhoffm
Copy link
Member

Sorry @tacaswell I didn't see that you were requested for review. Please let me know if merging was premature.

@anntzer anntzer deleted the useless branch May 26, 2019 20:12
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