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

Skip to content

Commit 5780fe7

Browse files
committed
Deprecation fixes.
1) don't import matplotlib.compat.subprocess in `__init__` (as that triggers a deprecation warning). 2) using stacklevel=2 for warn_deprecated as default is not necessarily always sufficient, but will definitely be better than stacklevel=1 as default... (see https://docs.python.org/3/library/warnings.html#warnings.warn).
1 parent 438aa08 commit 5780fe7

File tree

3 files changed

+2
-5
lines changed

3 files changed

+2
-5
lines changed

lib/matplotlib/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@
142142
from . import cbook
143143
from matplotlib.cbook import (
144144
mplDeprecation, dedent, get_label, sanitize_sequence)
145-
from matplotlib.compat import subprocess
146145
from matplotlib.rcsetup import defaultParams, validate_backend, cycler
147146

148147
import numpy

lib/matplotlib/backends/backend_agg.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,7 @@ def print_tif(self, filename_or_obj, *args, **kwargs):
589589
return
590590
image = Image.frombuffer('RGBA', size, buf, 'raw', 'RGBA', 0, 1)
591591
dpi = (self.figure.dpi, self.figure.dpi)
592-
return image.save(filename_or_obj, format='tiff',
593-
dpi=dpi)
592+
return image.save(filename_or_obj, format='tiff', dpi=dpi)
594593
print_tiff = print_tif
595594

596595

lib/matplotlib/cbook/deprecation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ def warn_deprecated(
103103
"""
104104
message = _generate_deprecation_message(
105105
since, message, name, alternative, pending, obj_type)
106-
107-
warnings.warn(message, mplDeprecation, stacklevel=1)
106+
warnings.warn(message, mplDeprecation, stacklevel=2)
108107

109108

110109
def deprecated(since, message='', name='', alternative='', pending=False,

0 commit comments

Comments
 (0)