10000 Don't use a mutable type (here, a dict) as default argument because i… · matplotlib/matplotlib@5f42166 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5f42166

Browse files
committed
Don't use a mutable type (here, a dict) as default argument because it only gets evaluated once when the function is defined, not during each function call (i.e. changes will persist across function calls).
1 parent 9a48efd commit 5f42166

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/matplotlib/animation.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ def _stop(self, *args):
548548

549549
def save(self, filename, writer=None, fps=None, dpi=None, codec=None,
550550
bitrate=None, extra_args=None, metadata=None, extra_anim=None,
551-
savefig_kwargs={}):
551+
savefig_kwargs=None):
552552
'''
553553
Saves a movie file by drawing every frame.
554554
@@ -595,6 +595,9 @@ def save(self, filename, writer=None, fps=None, dpi=None, codec=None,
595595
the individual frames. This can be used to set tight bounding boxes,
596596
for example.
597597
'''
598+
if savefig_kwargs is None:
599+
savefig_kwargs = {}
600+
598601
# Need to disconnect the first draw callback, since we'll be doing
599602
# draws. Otherwise, we'll end up starting the animation.
600603
if self._first_draw_id is not None:

0 commit comments

Comments
 (0)
0