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 f7ec3b1

Browse filesBrowse files
committed
Inline the with_rasterized contextmanager.
1 parent 73a82ee commit f7ec3b1
Copy full SHA for f7ec3b1

File tree

Expand file treeCollapse file tree

1 file changed

+9
-17
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-17
lines changed

‎lib/matplotlib/artist.py

Copy file name to clipboardExpand all lines: lib/matplotlib/artist.py
+9-17Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import six
55

66
from collections import OrderedDict, namedtuple
7-
from contextlib import contextmanager
87
from functools import wraps
98
import inspect
109
import re
@@ -43,30 +42,23 @@ def allow_rasterization(draw):
4342
other setup function calls, such as starting and flushing a mixed-mode
4443
renderer.
4544
"""
46-
@contextmanager
47-
def with_rasterized(artist, renderer):
48-
49-
if artist.get_rasterized():
50-
renderer.start_rasterizing()
51-
52-
if artist.get_agg_filter() is not None:
53-
renderer.start_filter()
5445

46+
# the axes class has a second argument inframe for its draw method.
47+
@wraps(draw)
48+
def draw_wrapper(artist, renderer, *args, **kwargs):
5549
try:
56-
yield
50+
if artist.get_rasterized():
51+
renderer.start_rasterizing()
52+
if artist.get_agg_filter() is not None:
53+
renderer.start_filter()
54+
55+
return draw(artist, renderer, *args, **kwargs)
5756
finally:
5857
if artist.get_agg_filter() is not None:
5958
renderer.stop_filter(artist.get_agg_filter())
60-
6159
if artist.get_rasterized():
6260
renderer.stop_rasterizing()
6361

64-
# the axes class has a second argument inframe for its draw method.
65-
@wraps(draw)
66-
def draw_wrapper(artist, renderer, *args, **kwargs):
67-
with with_rasterized(artist, renderer):
68-
return draw(artist, renderer, *args, **kwargs)
69-
7062
draw_wrapper._supports_rasterization = True
7163
return draw_wrapper
7264

0 commit comments

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