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

Skip to content

Commit d526148

Browse files
tacaswellmeeseeksmachine
authored andcommitted
Backport PR #25339: Disable discarded animation warning on save
1 parent 83bf223 commit d526148

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

lib/matplotlib/animation.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,15 @@ def func(current_frame: int, total_frames: int) -> Any
992992
is a `.MovieWriter`, a `RuntimeError` will be raised.
993993
"""
994994

995+
all_anim = [self]
996+
if extra_anim is not None:
997+
all_anim.extend(anim for anim in extra_anim
998+
if anim._fig is self._fig)
999+
1000+
# Disable "Animation was deleted without rendering" warning.
1001+
for anim in all_anim:
1002+
anim._draw_was_started = True
1003+
9951004
if writer is None:
9961005
writer = mpl.rcParams['animation.writer']
9971006
elif (not isinstance(writer, str) and
@@ -1030,11 +1039,6 @@ def func(current_frame: int, total_frames: int) -> Any
10301039
if metadata is not None:
10311040
writer_kwargs['metadata'] = metadata
10321041

1033-
all_anim = [self]
1034-
if extra_anim is not None:
1035-
all_anim.extend(anim for anim in extra_anim
1036-
if anim._fig is self._fig)
1037-
10381042
# If we have the name of a writer, instantiate an instance of the
10391043
# registered class.
10401044
if isinstance(writer, str):

lib/matplotlib/tests/test_animation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,5 +514,5 @@ def test_movie_writer_invalid_path(anim):
514514
else:
515515
match_str = re.escape("[Errno 2] No such file or directory: '/foo")
516516
with pytest.raises(FileNotFoundError, match=match_str):
517-
_ = anim.save("/foo/bar/aardvark/thiscannotreallyexist.mp4",
518-
writer=animation.FFMpegFileWriter())
517+
anim.save("/foo/bar/aardvark/thiscannotreallyexist.mp4",
518+
writer=animation.FFMpegFileWriter())

0 commit comments

Comments
 (0)