Skip to content

Commit c6d27d9

Browse files
committed
Deprecate MovieWriter.{exec,args}_key, making them private.
Builtin writer subclasses additionally define the _exec_key and _args_key attributes, which indicate the rcParams entries where the path to the executable and additional command-line arguments to the executable are stored. Third-party writers cannot meaningfully set these as they cannot extend rcParams with new keys. Hence they are really an internal way of mapping builtin writers to rcParams and should not be exposed.
1 parent 9adc431 commit c6d27d9

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

doc/api/next_api_changes/deprecations.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,7 @@ Likewise, passing the *alpha*, *boundaries*, *values*, *extend*, or *filled*
106106
parameters with a `.ContourSet` mappable, or the *alpha* parameter with an
107107
`.Artist` mappable, is deprecated, as the mappable would likewise override
108108
them.
109+
110+
``args_key`` and ``exec_key`` attributes of builtin `.MovieWriter`\s
111+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
112+
These attributes are deprecated.

lib/matplotlib/animation.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,24 @@ class MovieWriter(AbstractMovieWriter):
267267
fig : `~matplotlib.figure.Figure`
268268
The figure to capture data from.
269269
This must be provided by the sub-classes.
270-
271270
"""
272271

272+
# Builtin writer subclasses additionally define the _exec_key and _args_key
273+
# attributes, which indicate the rcParams entries where the path to the
274+
# executable and additional command-line arguments to the executable are
275+
# stored. Third-party writers cannot meaningfully set these as they cannot
276+
# extend rcParams with new keys.
277+
278+
@cbook.deprecated("3.3")
279+
@property
280+
def exec_key(self):
281+
return self._exec_key
282+
283+
@cbook.deprecated("3.3")
284+
@property
285+
def args_key(self):
286+
return self._args_key
287+
273288
def __init__(self, fps=5, codec=None, bitrate=None, extra_args=None,
274289
metadata=None):
275290
"""
@@ -409,7 +424,7 @@ def bin_path(cls):
409424
subclass. This is a class method so that the tool can be looked for
410425
before making a particular MovieWriter subclass available.
411426
"""
412-
return str(mpl.rcParams[cls.exec_key])
427+
return str(mpl.rcParams[cls._exec_key])
413428

414429
@classmethod
415430
def isAvailable(cls):
@@ -573,14 +588,14 @@ class FFMpegBase:
573588
`MovieWriterBase` sub-class.
574589
"""
575590

576-
exec_key = 'animation.ffmpeg_path'
577-
args_key = 'animation.ffmpeg_args'
591+
_exec_key = 'animation.ffmpeg_path'
592+
_args_key = 'animation.ffmpeg_args'
578593

579594
@property
580595
def output_args(self):
581596
args = ['-vcodec', self.codec]
582597
extra_args = (self.extra_args if self.extra_args is not None
583-
else mpl.rcParams[self.args_key])
598+
else mpl.rcParams[self._args_key])
584599
# For h264, the default format is yuv444p, which is not compatible
585600
# with quicktime (and others). Specifying yuv420p fixes playback on
586601
# iOS, as well as HTML5 video in firefox and safari (on both Win and
@@ -658,8 +673,8 @@ class AVConvBase(FFMpegBase):
658673
`MovieWriterBase` sub-class.
659674
"""
660675

661-
exec_key = 'animation.avconv_path'
662-
args_key = 'animation.avconv_args'
676+
_exec_key = 'animation.avconv_path'
677+
_args_key = 'animation.avconv_args'
663678

664679
# NOTE : should be removed when the same method is removed in FFMpegBase.
665680
isAvailable = classmethod(MovieWriter.isAvailable.__func__)
@@ -696,8 +711,8 @@ class ImageMagickBase:
696711
`MovieWriterBase` sub-class.
697712
"""
698713

699-
exec_key = 'animation.convert_path'
700-
args_key = 'animation.convert_args'
714+
_exec_key = 'animation.convert_path'
715+
_args_key = 'animation.convert_args'
701716

702717
@property
703718
def delay(self):
@@ -706,7 +721,7 @@ def delay(self):
706721
@property
707722
def output_args(self):
708723
extra_args = (self.extra_args if self.extra_args is not None
709-
else mpl.rcParams[self.args_key])
724+
else mpl.rcParams[self._args_key])
710725
return [*extra_args, self.outfile]
711726

712727
@classmethod
@@ -784,7 +799,7 @@ def _embedded_frames(frame_list, frame_format):
784799
@writers.register('html')
785800
class HTMLWriter(FileMovieWriter):
786801
supported_formats = ['png', 'jpeg', 'tiff', 'svg']
787-
args_key = 'animation.html_args'
802+
_args_key = 'animation.html_args'
788803

789804
@classmethod
790805
def isAvailable(cls):

0 commit comments

Comments
 (0)