Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7902910

Browse filesBrowse files
committed
Deprecate the 'warn' parameter to matplotlib.use().
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 ``` ...
1 parent 7d92440 commit 7902910
Copy full SHA for 7902910

File tree

Expand file treeCollapse file tree

3 files changed

+9
-2
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+9
-2
lines changed
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Deprecations
2+
````````````
3+
4+
The ``warn`` parameter to `matplotlib.use()` is deprecated (catch the
5+
`ImportError` emitted on backend switch failure and reemit a warning yourself
6+
if so desired).

‎lib/matplotlib/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/__init__.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,7 @@ def __exit__(self, exc_type, exc_value, exc_tb):
12261226

12271227

12281228
@cbook._rename_parameter("3.1", "arg", "backend")
1229+
@cbook._delete_parameter("3.1", "warn")
12291230
def use(backend, warn=False, force=True):
12301231
"""
12311232
Select the backend used for rendering and GUI integration.
@@ -1248,7 +1249,7 @@ def use(backend, warn=False, force=True):
12481249
12491250
warn : bool, optional, default: False
12501251
If True and not *force*, emit a warning if a failure-to-switch
1251-
`ImportError` has been suppressed.
1252+
`ImportError` has been suppressed. This parameter is deprecated.
12521253
12531254
force : bool, optional, default: True
12541255
If True (the default), raise an `ImportError` if the backend cannot be

‎lib/matplotlib/testing/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/testing/__init__.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def setup():
5050
"Could not set locale to English/United States. "
5151
"Some date-related tests may fail.")
5252

53-
mpl.use('Agg', force=True, warn=False) # use Agg backend for these tests
53+
mpl.use('Agg')
5454

5555
with cbook._suppress_matplotlib_deprecation_warning():
5656
mpl.rcdefaults() # Start with all defaults

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.