Skip to content

Commit aa0f868

Browse files
authored
Merge pull request #9916 from anntzer/agg-cleanup
MNT: backend_agg cleanup.
2 parents c1a22a1 + 5d86d45 commit aa0f868

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

lib/matplotlib/backends/backend_agg.py

+17-11
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import numpy as np
2929
from collections import OrderedDict
3030
from math import radians, cos, sin
31-
from matplotlib import rcParams, __version__
31+
from matplotlib import cbook, rcParams, __version__
3232
from matplotlib.backend_bases import (
3333
_Backend, FigureCanvasBase, FigureManagerBase, RendererBase, cursors)
3434
from matplotlib.figure import Figure
@@ -68,7 +68,11 @@ class RendererAgg(RendererBase):
6868
The renderer handles all the drawing primitives using a graphics
6969
context instance that controls the colors/styles
7070
"""
71-
debug=1
71+
72+
@property
73+
@cbook.deprecated("2.2")
74+
def debug(self):
75+
return 1
7276

7377
# we want to cache the fonts at the class level so that when
7478
# multiple figures are created we can reuse them. This helps with
@@ -79,16 +83,17 @@ class RendererAgg(RendererBase):
7983
# draw, and release it when it is done. This allows multiple
8084
# renderers to share the cached fonts, but only one figure can
8185
# draw at time and so the font cache is used by only one
82-
# renderer at a time
86+
# renderer at a time.
8387

8488
lock = threading.RLock()
89+
8590
def __init__(self, width, height, dpi):
8691
RendererBase.__init__(self)
8792

8893
self.dpi = dpi
8994
self.width = width
9095
self.height = height
91-
self._renderer = _RendererAgg(int(width), int(height), dpi, debug=False)
96+
self._renderer = _RendererAgg(int(width), int(height), dpi)
9297
self._filter_renderers = []
9398

9499
self._update_methods()
@@ -158,12 +163,14 @@ def draw_path(self, gc, path, transform, rgbFace=None):
158163
try:
159164
self._renderer.draw_path(gc, p, transform, rgbFace)
160165
except OverflowError:
161-
raise OverflowError("Exceeded cell block limit (set 'agg.path.chunksize' rcparam)")
166+
raise OverflowError("Exceeded cell block limit (set "
167+
"'agg.path.chunksize' rcparam)")
162168
else:
163169
try:
164170
self._renderer.draw_path(gc, path, transform, rgbFace)
165171
except OverflowError:
166-
raise OverflowError("Exceeded cell block limit (set 'agg.path.chunksize' rcparam)")
172+
raise OverflowError("Exceeded cell block limit (set "
173+
"'agg.path.chunksize' rcparam)")
167174

168175

169176
def draw_mathtext(self, gc, x, y, s, prop, angle):
@@ -232,8 +239,8 @@ def get_text_width_height_descent(self, s, prop, ismath):
232239

233240
flags = get_hinting_flag()
234241
font = self._get_agg_font(prop)
235-
font.set_text(s, 0.0, flags=flags) # the width and height of unrotated string
236-
w, h = font.get_width_height()
242+
font.set_text(s, 0.0, flags=flags)
243+
w, h = font.get_width_height() # width and height of unrotated string
237244
d = font.get_descent()
238245
w /= 64.0 # convert from subpixels
239246
h /= 64.0
@@ -367,9 +374,8 @@ def post_processing(image, dpi):
367374
post_processing is plotted (using draw_image) on it.
368375
"""
369376

370-
# WARNING.
371-
# For agg_filter to work, the rendere's method need
372-
# to overridden in the class. See draw_markers, and draw_path_collections
377+
# WARNING: For agg_filter to work, the renderer's method need to
378+
# overridden in the class. See draw_markers and draw_path_collections.
373379

374380
width, height = int(self.width), int(self.height)
375381

pytest.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pep8ignore =
2323
tools/subset.py E221 E231 E251 E261 E302 E501 E701 E703
2424

2525
matplotlib/backends/qt_editor/formlayout.py E301 E402 E501
26-
matplotlib/backends/backend_agg.py E225 E228 E231 E261 E301 E302 E303 E501 E701
26+
matplotlib/backends/backend_agg.py E225 E228 E231 E261 E301 E302 E303 E701
2727
matplotlib/backends/backend_cairo.py E203 E211 E221 E231 E261 E272 E302 E303 E401 E402 E501 E701 E711
2828
matplotlib/backends/backend_gdk.py E202 E203 E211 E221 E225 E231 E261 E302 E303 E402 E501 E702 E711
2929
matplotlib/backends/backend_gtk.py E201 E202 E203 E211 E221 E222 E225 E231 E251 E261 E262 E301 E302 E303 E401 E402 E501 E701 E702 E703

0 commit comments

Comments
 (0)