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 4bbca88

Browse filesBrowse files
committed
Simplify animation writer fallback.
The fallback now always returns PillowWriter, which is the first registered writer and is always available, so we may just as well be more explicit. (Not all writers support all output formats, but we don't have machinery to select writers based on the output format right now anyways.)
1 parent 84e872d commit 4bbca88
Copy full SHA for 4bbca88

File tree

Expand file treeCollapse file tree

1 file changed

+7
-11
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-11
lines changed

‎lib/matplotlib/animation.py

Copy file name to clipboardExpand all lines: lib/matplotlib/animation.py
+7-11Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,17 +1087,13 @@ def func(current_frame: int, total_frames: int) -> Any
10871087
# If we have the name of a writer, instantiate an instance of the
10881088
# registered class.
10891089
if isinstance(writer, str):
1090-
if writers.is_available(writer):
1091-
writer = writers[writer](fps, **writer_kwargs)
1092-
else:
1093-
alt_writer = next(iter(writers), None)
1094-
if alt_writer is None:
1095-
raise ValueError("Cannot save animation: no writers are "
1096-
"available. Please install ffmpeg to "
1097-
"save animations.")
1098-
_log.warning("MovieWriter %s unavailable; trying to use %s "
1099-
"instead.", writer, alt_writer)
1100-
writer = alt_writer(fps, **writer_kwargs)
1090+
try:
1091+
writer_cls = writers[writer]
1092+
except RuntimeError: # Raised if not available.
1093+
writer_cls = PillowWriter # Always available.
1094+
_log.warning("MovieWriter %s unavailable; using Pillow "
1095+
"instead.", writer)
1096+
writer = writer_cls(fps, **writer_kwargs)
11011097
_log.info('Animation.save using %s', type(writer))
11021098

11031099
if 'bbox_inches' in savefig_kwargs:

0 commit comments

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