Skip to content

Commit 6ce8923

Browse files
authored
Merge pull request matplotlib#21868 from anntzer/pspm
MNT: Use partialmethod for better signatures in backend_ps.
2 parents 2ccc67f + e2ddbfd commit 6ce8923

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -838,17 +838,10 @@ class FigureCanvasPS(FigureCanvasBase):
838838
def get_default_filetype(self):
839839
return 'ps'
840840

841-
@_api.delete_parameter("3.5", "args")
842-
def print_ps(self, outfile, *args, **kwargs):
843-
return self._print_ps(outfile, 'ps', **kwargs)
844-
845-
@_api.delete_parameter("3.5", "args")
846-
def print_eps(self, outfile, *args, **kwargs):
847-
return self._print_ps(outfile, 'eps', **kwargs)
848-
849841
@_api.delete_parameter("3.4", "dpi")
842+
@_api.delete_parameter("3.5", "args")
850843
def _print_ps(
851-
self, outfile, format, *,
844+
self, fmt, outfile, *args,
852845
dpi=None, metadata=None, papertype=None, orientation='portrait',
853846
**kwargs):
854847

@@ -885,12 +878,12 @@ def _print_ps(
885878
printer = (self._print_figure_tex
886879
if mpl.rcParams['text.usetex'] else
887880
self._print_figure)
888-
printer(outfile, format, dpi=dpi, dsc_comments=dsc_comments,
881+
printer(fmt, outfile, dpi=dpi, dsc_comments=dsc_comments,
889882
orientation=orientation, papertype=papertype, **kwargs)
890883

891884
@_check_savefig_extra_args
892885
def _print_figure(
893-
self, outfile, format, *,
886+
self, fmt, outfile, *,
894887
dpi, dsc_comments, orientation, papertype,
895888
bbox_inches_restore=None):
896889
"""
@@ -900,7 +893,7 @@ def _print_figure(
900893
all string containing Document Structuring Convention comments,
901894
generated from the *metadata* parameter to `.print_figure`.
902895
"""
903-
is_eps = format == 'eps'
896+
is_eps = fmt == 'eps'
904897
if not (isinstance(outfile, (str, os.PathLike))
905898
or is_writable_file_like(outfile)):
906899
raise ValueError("outfile must be a path or a file-like object")
@@ -1028,7 +1021,7 @@ def print_figure_impl(fh):
10281021

10291022
@_check_savefig_extra_args
10301023
def _print_figure_tex(
1031-
self, outfile, format, *,
1024+
self, fmt, outfile, *,
10321025
dpi, dsc_comments, orientation, papertype,
10331026
bbox_inches_restore=None):
10341027
"""
@@ -1038,7 +1031,7 @@ def _print_figure_tex(
10381031
10391032
The rest of the behavior is as for `._print_figure`.
10401033
"""
1041-
is_eps = format == 'eps'
1034+
is_eps = fmt == 'eps'
10421035

10431036
width, height = self.figure.get_size_inches()
10441037
xo = 0
@@ -1121,6 +1114,9 @@ def _print_figure_tex(
11211114

11221115
_move_path_to_path_or_stream(tmpfile, outfile)
11231116

1117+
print_ps = functools.partialmethod(_print_ps, "ps")
1118+
print_eps = functools.partialmethod(_print_ps, "eps")
1119+
11241120
def draw(self):
11251121
self.figure.draw_without_rendering()
11261122
return super().draw()

0 commit comments

Comments
 (0)