From 9b8ec705c390ac3eb2fde8246c10eeced3c52f8c Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sat, 4 Jan 2020 16:09:59 +0100 Subject: [PATCH 1/2] Deprecate clear_temp param/attr of FileMovieWriter. It overlaps in awkward ways with frame_prefix, which effectively provides the same functionality. --- doc/api/next_api_changes/deprecations.rst | 7 +++++++ lib/matplotlib/animation.py | 17 ++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/doc/api/next_api_changes/deprecations.rst b/doc/api/next_api_changes/deprecations.rst index cd4714c84482..edcba36009c2 100644 --- a/doc/api/next_api_changes/deprecations.rst +++ b/doc/api/next_api_changes/deprecations.rst @@ -204,3 +204,10 @@ use e.g. ``ax.set_xscale("log", base=10); ax.set_yscale("log", base=2)``. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This method is deprecated. If you previously reimplemented it in a subclass, set the artist's picker instead with `.Artist.set_picker`. + +*clear_temp* parameter and attribute of `.FileMovieWriter` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The *clear_temp* parameter and attribute of `.FileMovieWriter` is +deprecated. In the future, files placed in a temporary directory (using +``frame_prefix=None``, the default) will be cleared; files placed elsewhere +will not. diff --git a/lib/matplotlib/animation.py b/lib/matplotlib/animation.py index 6d71ebe60b5f..3416209c0e8e 100644 --- a/lib/matplotlib/animation.py +++ b/lib/matplotlib/animation.py @@ -427,6 +427,7 @@ def __init__(self, *args, **kwargs): MovieWriter.__init__(self, *args, **kwargs) self.frame_format = mpl.rcParams['animation.frame_format'] + @cbook._delete_parameter("3.3", "clear_temp") def setup(self, fig, outfile, dpi=None, frame_prefix=None, clear_temp=True): """ @@ -464,11 +465,20 @@ def setup(self, fig, outfile, dpi=None, frame_prefix=None, else: self._tmpdir = None self.temp_prefix = frame_prefix - self.clear_temp = clear_temp + self._clear_temp = clear_temp self._frame_counter = 0 # used for generating sequential file names self._temp_paths = list() self.fname_format_str = '%s%%07d.%s' + @cbook.deprecated("3.3") + @property + def clear_temp(self): + return self._clear_temp + + @clear_temp.setter + def clear_temp(self, value): + self._clear_temp = value + @property def frame_format(self): """ @@ -526,7 +536,7 @@ def cleanup(self): _log.debug('MovieWriter: clearing temporary path=%s', self._tmpdir) self._tmpdir.cleanup() else: - if self.clear_temp: + if self._clear_temp: _log.debug('MovieWriter: clearing temporary paths=%s', self._temp_paths) for path in self._temp_paths: @@ -824,7 +834,8 @@ def setup(self, fig, outfile, dpi, frame_dir=None): else: frame_prefix = None - super().setup(fig, outfile, dpi, frame_prefix, clear_temp=False) + super().setup(fig, outfile, dpi, frame_prefix) + self._clear_temp = False def grab_frame(self, **savefig_kwargs): if self.embed_frames: From 6abad46301befd91ab6f70dfb2bbeca6432cf39d Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 5 Jan 2020 11:01:30 +0100 Subject: [PATCH 2/2] Update missing-references.json. --- doc/missing-references.json | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/doc/missing-references.json b/doc/missing-references.json index 3ee0e23bda78..ac77372cc7f1 100644 --- a/doc/missing-references.json +++ b/doc/missing-references.json @@ -497,10 +497,10 @@ "doc/users/prev_whats_new/whats_new_2.1.0.rst:409" ], "matplotlib.test": [ - "doc/devel/testing.rst:84" + "doc/devel/testing.rst:79" ], "matplotlib.testing.conftest.mpl_test_settings": [ - "doc/devel/testing.rst:111" + "doc/devel/testing.rst:106" ] }, "py:meth": { @@ -624,7 +624,7 @@ "doc/api/prev_api_changes/api_changes_0.91.0.rst:34" ], "matplotlib.tests.test_basic": [ - "doc/devel/testing.rst:98" + "doc/devel/testing.rst:93" ] }, "py:obj": { @@ -816,8 +816,7 @@ ], "Timer": [ "lib/matplotlib/backend_bases.py:docstring of matplotlib.backend_bases.FigureCanvasBase.new_timer:2", - "lib/matplotlib/backend_bases.py:docstring of matplotlib.backend_bases.TimerBase:14", - "lib/matplotlib/backends/backend_nbagg.py:docstring of matplotlib.backends.backend_nbagg.FigureCanvasNbAgg.new_timer:2" + "lib/matplotlib/backend_bases.py:docstring of matplotlib.backend_bases.TimerBase:14" ], "Tool": [ "doc/devel/MEP/MEP22.rst:60", @@ -1137,7 +1136,7 @@ "lib/matplotlib/animation.py:docstring of matplotlib.animation.AVConvBase.isAvailable:1::1" ], "matplotlib.animation.AVConvFileWriter.args_key": [ - "doc/api/_as_gen/matplotlib.animation.AVConvFileWriter.rst:38::1" + "doc/api/_as_gen/matplotlib.animation.AVConvFileWriter.rst:39::1" ], "matplotlib.animation.AVConvFileWriter.bin_path": [ "doc/api/_as_gen/matplotlib.animation.AVConvFileWriter.rst:28::1" @@ -1145,17 +1144,20 @@ "matplotlib.animation.AVConvFileWriter.cleanup": [ "doc/api/_as_gen/matplotlib.animation.AVConvFileWriter.rst:28::1" ], + "matplotlib.animation.AVConvFileWriter.clear_temp": [ + "doc/api/_as_gen/matplotlib.animation.AVConvFileWriter.rst:39::1" + ], "matplotlib.animation.AVConvFileWriter.exec_key": [ - "doc/api/_as_gen/matplotlib.animation.AVConvFileWriter.rst:38::1" + "doc/api/_as_gen/matplotlib.animation.AVConvFileWriter.rst:39::1" ], "matplotlib.animation.AVConvFileWriter.finish": [ "doc/api/_as_gen/matplotlib.animation.AVConvFileWriter.rst:28::1" ], "matplotlib.animation.AVConvFileWriter.frame_format": [ - "doc/api/_as_gen/matplotlib.animation.AVConvFileWriter.rst:38::1" + "doc/api/_as_gen/matplotlib.animation.AVConvFileWriter.rst:39::1" ], "matplotlib.animation.AVConvFileWriter.frame_size": [ - "doc/api/_as_gen/matplotlib.animation.AVConvFileWriter.rst:38::1" + "doc/api/_as_gen/matplotlib.animation.AVConvFileWriter.rst:39::1" ], "matplotlib.animation.AVConvFileWriter.grab_frame": [ "doc/api/_as_gen/matplotlib.animation.AVConvFileWriter.rst:28::1" @@ -1164,7 +1166,7 @@ "doc/api/_as_gen/matplotlib.animation.AVConvFileWriter.rst:28::1" ], "matplotlib.animation.AVConvFileWriter.output_args": [ - "doc/api/_as_gen/matplotlib.animation.AVConvFileWriter.rst:38::1" + "doc/api/_as_gen/matplotlib.animation.AVConvFileWriter.rst:39::1" ], "matplotlib.animation.AVConvFileWriter.saving": [ "doc/api/_as_gen/matplotlib.animation.AVConvFileWriter.rst:28::1" @@ -1173,7 +1175,7 @@ "doc/api/_as_gen/matplotlib.animation.AVConvFileWriter.rst:28::1" ], "matplotlib.animation.AVConvFileWriter.supported_formats": [ - "doc/api/_as_gen/matplotlib.animation.AVConvFileWriter.rst:38::1" + "doc/api/_as_gen/matplotlib.animation.AVConvFileWriter.rst:39::1" ], "matplotlib.animation.AVConvWriter.args_key": [ "doc/api/_as_gen/matplotlib.animation.AVConvWriter.rst:36::1" @@ -1232,6 +1234,9 @@ "matplotlib.animation.FFMpegFileWriter.cleanup": [ "doc/api/_as_gen/matplotlib.animation.FFMpegFileWriter.rst:28::1" ], + "matplotlib.animation.FFMpegFileWriter.clear_temp": [ + "lib/matplotlib/animation.py:docstring of matplotlib.animation.FFMpegFileWriter.supported_formats:1::1" + ], "matplotlib.animation.FFMpegFileWriter.exec_key": [ "lib/matplotlib/animation.py:docstring of matplotlib.animation.FFMpegFileWriter.supported_formats:1::1" ], @@ -1328,6 +1333,9 @@ "matplotlib.animation.HTMLWriter.cleanup": [ "doc/api/_as_gen/matplotlib.animation.HTMLWriter.rst:28::1" ], + "matplotlib.animation.HTMLWriter.clear_temp": [ + "lib/matplotlib/animation.py:docstring of matplotlib.animation.HTMLWriter.finish:1::1" + ], "matplotlib.animation.HTMLWriter.exec_key": [ "lib/matplotlib/animation.py:docstring of matplotlib.animation.HTMLWriter.finish:1::1" ], @@ -1349,6 +1357,9 @@ "matplotlib.animation.ImageMagickFileWriter.cleanup": [ "doc/api/_as_gen/matplotlib.animation.ImageMagickFileWriter.rst:28::1" ], + "matplotlib.animation.ImageMagickFileWriter.clear_temp": [ + "lib/matplotlib/animation.py:docstring of matplotlib.animation.ImageMagickFileWriter.supported_formats:1::1" + ], "matplotlib.animation.ImageMagickFileWriter.delay": [ "lib/matplotlib/animation.py:docstring of matplotlib.animation.ImageMagickFileWriter.supported_formats:1::1" ],