Skip to content

Commit 9de19d0

Browse files
committed
MNT: be more gentle about resetting the draw method
1 parent b358e6d commit 9de19d0

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/matplotlib/artist.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ def __init_subclass__(cls):
132132

133133
# Decorate draw() method so that all artists are able to stop
134134
# rastrization when necessary.
135-
cls.draw = _prevent_rasterization(cls.draw)
135+
136+
if not hasattr(cls.draw, "_supports_rasterization"):
137+
cls.draw = _prevent_rasterization(cls.draw)
136138

137139
# Inject custom set() methods into the subclass with signature and
138140
# docstring based on the subclasses' properties.

lib/matplotlib/tests/test_artist.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,3 +535,17 @@ def test_format_cursor_data_BoundaryNorm():
535535
assert img.format_cursor_data(v) == label
536536

537537
plt.close()
538+
539+
540+
def test_auto_no_rasterize():
541+
class Gen1(martist.Artist):
542+
...
543+
544+
assert 'draw' in Gen1.__dict__
545+
assert Gen1.__dict__['draw'] is Gen1.draw
546+
547+
class Gen2(Gen1):
548+
...
549+
550+
assert 'draw' not in Gen2.__dict__
551+
assert Gen2.draw is Gen1.draw

0 commit comments

Comments
 (0)