Skip to content

Commit a046d8c

Browse files
authored
Merge pull request matplotlib#15846 from anntzer/argbind-errors
MNT: Standardize signature mismatch error messages.
2 parents ebdd7df + 72994f9 commit a046d8c

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

doc/api/next_api_changes/behaviour.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,8 @@ through it.
117117
This behavior is consistent with other figure saving methods
118118
(`.FigureCanvasAgg.print_png`, `.FigureCanvasPdf.print_pdf`,
119119
`.FigureCanvasSVG.print_svg`).
120+
121+
`.pyplot.subplot()` now raises TypeError when given an incorrect number of arguments
122+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123+
This is consistent with other signature mismatch errors. Previously a
124+
ValueError was raised.

lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5519,8 +5519,8 @@ def _pcolorargs(funcname, *args, shading='flat'):
55195519
Y = Y.data
55205520
nrows, ncols = C.shape
55215521
else:
5522-
raise TypeError(
5523-
'Illegal arguments to %s; see help(%s)' % (funcname, funcname))
5522+
raise TypeError(f'{funcname}() takes 1 or 3 positional arguments '
5523+
f'but {len(args)} were given')
55245524

55255525
Nx = X.shape[-1]
55265526
Ny = Y.shape[0]

lib/matplotlib/gridspec.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,8 @@ def _from_subplot_args(figure, args):
566566
# num - 1 for converting from MATLAB to python indexing
567567
return GridSpec(rows, cols, figure=figure)[int(num) - 1]
568568
else:
569-
raise ValueError(f"Illegal argument(s) to subplot: {args}")
569+
raise TypeError(f"subplot() takes 1 or 3 positional arguments but "
570+
f"{len(args)} were given")
570571

571572
# num2 is a property only to handle the case where it is None and someone
572573
# mutates num1.

0 commit comments

Comments
 (0)