Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 03d41e8

Browse files
committed
Made the code more concise by avoiding try-catch and using lambda.
1 parent d405b1c commit 03d41e8

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

lib/matplotlib/animation.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,14 +1222,11 @@ def _setup_blit(self):
12221222
# axes
12231223
self._blit_cache = dict()
12241224
self._drawn_artists = []
1225-
def remove_from_cache(ax):
1226-
try:
1227-
del self._blit_cache[ax]
1228-
except KeyError:
1229-
pass
12301225
for ax in self._fig.axes:
1231-
ax.callbacks.connect('xlim_changed', remove_from_cache)
1232-
ax.callbacks.connect('ylim_changed', remove_from_cache)
1226+
ax.callbacks.connect('xlim_changed',
1227+
lambda ax: self._blit_cache.pop(ax, None))
1228+
ax.callbacks.connect('ylim_changed',
1229+
lambda ax: self._blit_cache.pop(ax, None))
12331230
self._resize_id = self._fig.canvas.mpl_connect('resize_event',
12341231
self._handle_resize)
12351232
self._post_draw(None, self._blit)

0 commit comments

Comments
 (0)