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 a836e2e

Browse filesBrowse files
authored
Merge pull request #24720 from tacaswell/fix/astropy_custom_draw
FIX: be more forgiving in default draw wrapper
2 parents 328468c + 42fe514 commit a836e2e
Copy full SHA for a836e2e

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

+15
-2
lines changed

‎lib/matplotlib/artist.py

Copy file name to clipboardExpand all lines: lib/matplotlib/artist.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ def _prevent_rasterization(draw):
2929
# (e.g., change in dpi).
3030

3131
@wraps(draw)
32-
def draw_wrapper(artist, renderer):
32+
def draw_wrapper(artist, renderer, *args, **kwargs):
3333
if renderer._raster_depth == 0 and renderer._rasterizing:
3434
# Only stop when we are not in a rasterized parent
3535
# and something has been rasterized since last stop.
3636
renderer.stop_rasterizing()
3737
renderer._rasterizing = False
3838

39-
return draw(artist, renderer)
39+
return draw(artist, renderer, *args, **kwargs)
4040

4141
draw_wrapper._supports_rasterization = False
4242
return draw_wrapper

‎lib/matplotlib/tests/test_artist.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_artist.py
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import matplotlib.transforms as mtransforms
1414
import matplotlib.collections as mcollections
1515
import matplotlib.artist as martist
16+
import matplotlib.backend_bases as mbackend_bases
1617
import matplotlib as mpl
1718
from matplotlib.testing.decorators import check_figures_equal, image_comparison
1819

@@ -549,3 +550,15 @@ class Gen2(Gen1):
549550

550551
assert 'draw' not in Gen2.__dict__
551552
assert Gen2.draw is Gen1.draw
553+
554+
555+
def test_draw_wraper_forward_input():
556+
class TestKlass(martist.Artist):
557+
def draw(self, renderer, extra):
558+
return extra
559+
560+
art = TestKlass()
561+
renderer = mbackend_bases.RendererBase()
562+
563+
assert 'aardvark' == art.draw(renderer, 'aardvark')
564+
assert 'aardvark' == art.draw(renderer, extra='aardvark')

0 commit comments

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