8000 pgf backend cleanups. · matplotlib/matplotlib@b3609d3 · GitHub
[go: up one dir, main page]

Skip to content

Commit b3609d3

Browse files
committed
pgf backend cleanups.
Deprecate dummy renderers (which are only used with dryrun=True, which is itself deprecated). Move the image-to-stream warning to draw_image. Deprecate GraphicsContextPgf (we can just use GraphicsContextBase directly; e.g. the Agg backend does the same).
1 parent 4595bbd commit b3609d3

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

doc/api/next_api_changes/deprecations.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,9 @@ mathtext glues
247247
~~~~~~~~~~~~~~
248248
The *copy* parameter of ``mathtext.Glue`` is deprecated (the underlying glue
249249
spec is now immutable). ``mathtext.GlueSpec`` is deprecated.
250+
251+
PGF backend cleanups
252+
~~~~~~~~~~~~~~~~~~~~
253+
The *dummy* parameter of `.RendererPgf` is deprecated.
254+
255+
`.GraphicsContextPgf` is deprecated (use `.GraphicsContextBase` instead).

lib/matplotlib/backends/backend_pgf.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ def _get_image_inclusion_command():
385385

386386
class RendererPgf(RendererBase):
387387

388+
@cbook._delete_parameter("3.3", "dummy")
388389
def __init__(self, figure, fh, dummy=False):
389390
"""
390391
Creates a new PGF renderer that translates any drawing instruction
@@ -411,13 +412,6 @@ def __init__(self, figure, fh, dummy=False):
411412
for m in RendererPgf.__dict__:
412413
if m.startswith("draw_"):
413414
self.__dict__[m] = lambda *args, **kwargs: None
414-
else:
415-
# if fh does not belong to a filename, deactivate draw_image
416-
if not hasattr(fh, 'name') or not os.path.exists(fh.name):
417-
self.__dict__["draw_image"] = \
418-
lambda *args, **kwargs: cbook._warn_external(
419-
"streamed pgf-code does not support raster graphics, "
420-
"consider using the pgf-to-pdf option")
421415

422416
@cbook.deprecated("3.2")
423417
@property
@@ -645,6 +639,11 @@ def draw_image(self, gc, x, y, im, transform=None):
645639
if w == 0 or h == 0:
646640
return
647641

642+
if not os.path.exists(getattr(self.fh, "name", "")):
643+
cbook._warn_external(
644+
"streamed pgf-code does not support raster graphics, consider "
645+
"using the pgf-to-pdf option.")
646+
648647
# save the images to png files
649648
path = pathlib.Path(self.fh.name)
650649
fname_img = "%s-img%d.png" % (path.stem, self.image_counter)
@@ -755,16 +754,11 @@ def points_to_pixels(self, points):
755754
# docstring inherited
756755
return points * mpl_pt_to_in * self.dpi
757756

758-
def new_gc(self):
759-
# docstring inherited
760-
return GraphicsContextPgf()
761-
762757

758+
@cbook.deprecated("3.3", alternative="GraphicsContextBase")
763759
class GraphicsContextPgf(GraphicsContextBase):
764760
pass
765761

766-
########################################################################
767-
768762

769763
class TmpDirCleaner:
770764
remaining_tmpdirs = set()
@@ -948,7 +942,7 @@ def print_png(self, fname_or_fh, *args, **kwargs):
948942
self._print_png_to_fh(file, *args, **kwargs)
949943

950944
def get_renderer(self):
951-
return RendererPgf(self.figure, None, dummy=True)
945+
return RendererPgf(self.figure, None)
952946

953947

954948
class FigureManagerPgf(FigureManagerBase):

0 commit comments

Comments
 (0)
0