8000 Expire deprecations in backends · matplotlib/matplotlib@e1eca0a · GitHub
[go: up one dir, main page]

Skip to content

Commit e1eca0a

Browse files
committed
Expire deprecations in backends
1 parent b80bc91 commit e1eca0a

File tree

8 files changed

+27
-76
lines changed

8 files changed

+27
-76
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Removal of deprecations in ``backends``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The parameter ``resize_callback`` is removed from the Tk backend. Instead,
5+
use ``get_tk_widget().bind('<Configure>', ..., True)``.
6+
7+
The ``get_content_extents()`` and ``tostring_rgba_minimized()`` methods are
8+
removed from the Agg backend with no replacements.
9+
10+
The parameter ``dpi`` is removed from ``print_ps()`` in the PS backend and
11+
``print_pdf()`` in the PDF backend. Instead, the methods obtain the DPI from
12+
the ``savefig`` machinery.
13+
14+
The classes ``TmpDirCleaner`` and ``GraphicsContextPS`` are removed from the
15+
PGF and PS backends, respectively. For the latter, ``GraphicsContextBase`` can
16+
be used as a replacement.
17+
18+
In the WX backend, the property ``IDLE_DELAY`` is removed. In addition, the
19+
parameter ``origin`` of ``gui_repaint()`` is removed, as well as the method
20+
``get_canvas()``. No replacements are provided.

lib/matplotlib/backends/_backend_tk.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,7 @@ def _on_timer(self):
163163
class FigureCanvasTk(FigureCanvasBase):
164164
required_interactive_framework = "tk"
165165

166-
@_api.delete_parameter(
167-
"3.4", "resize_callback",
168-
alternative="get_tk_widget().bind('<Configure>', ..., True)")
169-
def __init__(self, figure=None, master=None, resize_callback=None):
166+
def __init__(self, figure=None, master=None):
170167
super().__init__(figure)
171168
self._idle_draw_id = None
172169
self._event_loop_id = None
@@ -177,7 +174,6 @@ def __init__(self, figure=None, master=None, resize_callback=None):
177174
self._tkphoto = tk.PhotoImage(
178175
master=self._tkcanvas, width=w, height=h)
179176
self._tkcanvas.create_image(w//2, h//2, image=self._tkphoto)
180-
self._resize_callback = resize_callback
181177
self._tkcanvas.bind("<Configure>", self.resize)
182178
self._tkcanvas.bind("<Map>", self._update_device_pixel_ratio)
183179
self._tkcanvas.bind("<Key>", self.key_press)
@@ -229,8 +225,6 @@ def _update_device_pixel_ratio(self, event=None):
229225

230226
def resize(self, event):
231227
width, height = event.width, event.height
232-
if self._resize_callback is not None:
233-
self._resize_callback(event)
234228

235229
# compute desired figure size in inches
236230
dpival = self.figure.dpi

lib/matplotlib/backends/backend_agg.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,6 @@ def _update_methods(self):
114114
self.draw_quad_mesh = self._renderer.draw_quad_mesh
115115
self.copy_from_bbox = self._renderer.copy_from_bbox
116116

117-
@_api.deprecated("3.4")
118-
def get_content_extents(self):
119-
orig_img = np.asarray(self.buffer_rgba())
120-
slice_y, slice_x = cbook._get_nonzero_slices(orig_img[..., 3])
121-
return (slice_x.start, slice_y.start,
122-
slice_x.stop - slice_x.start, slice_y.stop - slice_y.start)
123-
124-
@_api.deprecated("3.4")
125-
def tostring_rgba_minimized(self):
126-
extents = self.get_content_extents()
127-
bbox = [[extents[0], self.height - (extents[1] + extents[3])],
128-
[extents[0] + extents[2], self.height - extents[1]]]
129-
region = self.copy_from_bbox(bbox)
130-
return np.array(region), extents
131-
132117
def draw_path(self, gc, path, transform, rgbFace=None):
133118
# docstring inherited
134119
nmax = mpl.rcParams['agg.path.chunksize'] # here at least for testing

lib/matplotlib/backends/backend_pdf.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,13 +2738,10 @@ class FigureCanvasPdf(FigureCanvasBase):
27382738
def get_default_filetype(self):
27392739
return 'pdf'
27402740

2741-
@_api.delete_parameter("3.4", "dpi")
27422741
def print_pdf(self, filename, *,
2743-
dpi=None, # dpi to use for images
27442742
bbox_inches_restore=None, metadata=None):
27452743

2746-
if dpi is None: # always use this branch after deprecation elapses.
2747-
dpi = self.figure.get_dpi()
2744+
dpi = self.figure.get_dpi()
27482745
self.figure.set_dpi(72) # there are 72 pdf points to an inch
27492746
width, height = self.figure.get_size_inches()
27502747
if isinstance(filename, PdfPages):

lib/matplotlib/backends/backend_pgf.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -772,31 +772,6 @@ def points_to_pixels(self, points):
772772
return points * mpl_pt_to_in * self.dpi
773773

774774

775-
@_api.deprecated("3.4")
776-
class TmpDirCleaner:
777-
_remaining_tmpdirs = set()
778-
779-
@_api.classproperty
780-
@_api.deprecated("3.4")
781-
def remaining_tmpdirs(cls):
782-
return cls._remaining_tmpdirs
783-
784-
@staticmethod
785-
@_api.deprecated("3.4")
786-
def add(tmpdir):
787-
TmpDirCleaner._remaining_tmpdirs.add(tmpdir)
788-
789-
@staticmethod
790-
@_api.deprecated("3.4")
791-
@atexit.register
792-
def cleanup_remaining_tmpdirs():
793-
for tmpdir in TmpDirCleaner._remaining_tmpdirs:
794-
error_message = "error deleting tmp directory {}".format(tmpdir)
795-
shutil.rmtree(
796-
tmpdir,
797-
onerror=lambda *args: _log.error(error_message))
798-
799-
800775
class FigureCanvasPgf(FigureCanvasBase):
801776
filetypes = {"pgf": "LaTeX PGF picture",
802777
"pdf": "LaTeX compiled PGF picture",

lib/matplotlib/backends/backend_ps.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -806,15 +806,6 @@ def _draw_ps(self, ps, gc, rgbFace, *, fill=True, stroke=True):
806806
write("grestore\n")
807807

808808

809-
@_api.deprecated("3.4", alternative="GraphicsContextBase")
810-
class GraphicsContextPS(GraphicsContextBase):
811-
def get_capstyle(self):
812-
return {'butt': 0, 'round': 1, 'projecting': 2}[super().get_capstyle()]
813-
814-
def get_joinstyle(self):
815-
return {'miter': 0, 'round': 1, 'bevel': 2}[super().get_joinstyle()]
816-
817-
818809
class _Orientation(Enum):
819810
portrait, landscape = range(2)
820811

@@ -830,15 +821,13 @@ class FigureCanvasPS(FigureCanvasBase):
830821
def get_default_filetype(self):
831822
return 'ps'
832823

833-
@_api.delete_parameter("3.4", "dpi")
834824
@_api.delete_parameter("3.5", "args")
835825
def _print_ps(
836826
self, fmt, outfile, *args,
837-
dpi=None, metadata=None, papertype=None, orientation='portrait',
827+
metadata=None, papertype=None, orientation='portrait',
838828
**kwargs):
839829

840-
if dpi is None: # always use this branch after deprecation elapses.
841-
dpi = self.figure.get_dpi()
830+
dpi = self.figure.get_dpi()
842831
self.figure.set_dpi(72) # Override the dpi kwarg
843832

844833
dsc_comments = {}

lib/matplotlib/backends/backend_svg.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,9 +1281,8 @@ class FigureCanvasSVG(FigureCanvasBase):
12811281

12821282
fixed_dpi = 72
12831283

1284-
@_api.delete_parameter("3.4", "dpi")
12851284
@_api.delete_parameter("3.5", "args")
1286-
def print_svg(self, filename, *args, dpi=None, bbox_inches_restore=None,
1285+
def print_svg(self, filename, *args, bbox_inches_restore=None,
12871286
metadata=None):
12881287
"""
12891288
Parameters
@@ -1319,8 +1318,7 @@ def print_svg(self, filename, *args, dpi=None, bbox_inches_restore=None,
13191318
with cbook.open_file_cm(filename, "w", encoding="utf-8") as fh:
13201319
if not cbook.file_requires_unicode(fh):
13211320
fh = codecs.getwriter('utf-8')(fh)
1322-
if dpi is None: # always use this branch after deprecation elapses
1323-
dpi = self.figure.get_dpi()
1321+
dpi = self.figure.get_dpi()
13241322
self.figure.set_dpi(72)
13251323
width, height = self.figure.get_size_inches()
13261324
w, h = width * 72, height * 72

lib/matplotlib/backends/backend_wx.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343

4444
@_api.caching_module_getattr # module-level deprecations
4545
class __getattr__:
46-
IDLE_DELAY = _api.deprecated("3.1", obj_type="", removal="3.6")(property(
47-
lambda self: 5))
4846
cursord = _api.deprecated("3.5", obj_type="")(property(lambda self: {
4947
cursors.MOVE: wx.CURSOR_HAND,
5048
cursors.HAND: wx.CURSOR_HAND,
@@ -596,8 +594,7 @@ def _get_imagesave_wildcards(self):
596594
wildcards = '|'.join(wildcards)
597595
return wildcards, extensions, filter_index
598596

599-
@_api.delete_parameter("3.4", "origin")
600-
def gui_repaint(self, drawDC=None, origin='WX'):
597+
def gui_repaint(self, drawDC=None):
601598
"""
602599
Update the displayed image on the GUI canvas, using the supplied
603600
wx.PaintDC device context.
@@ -1087,10 +1084,6 @@ def _icon(name):
10871084
return wx.Bitmap.FromBufferRGBA(
10881085
image.shape[1], image.shape[0], image.tobytes())
10891086

1090-
@_api.deprecated("3.4")
1091-
def get_canvas(self, frame, fig):
1092-
return type(self.canvas)(frame, -1, fig)
1093-
10941087
def _update_buttons_checked(self):
10951088
if "Pan" in self.wx_ids:
10961089
self.ToggleTool(self.wx_ids["Pan"], self.mode.name == "PAN")

0 commit comments

Comments
 (0)
0