Skip to content

Commit 4134c8d

Browse files
committed
Clarify error message for bad-dimensionality in pcolorfast().
1 parent 6799367 commit 4134c8d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6591,7 +6591,10 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
65916591
elif x.ndim == 2 and y.ndim == 2:
65926592
style = "quadmesh"
65936593
else:
6594-
raise TypeError("arguments do not match valid signatures")
6594+
raise TypeError(
6595+
f"When 3 positional parameters are passed to pcolorfast, the first "
6596+
f"two (X and Y) must be both 1D or both 2D; the given X was "
6597+
f"{x.ndim}D and the given Y was {y.ndim}D")
65956598
else:
65966599
raise _api.nargs_error('pcolorfast', '1 or 3', len(args))
65976600

lib/matplotlib/tests/test_axes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6450,6 +6450,13 @@ def test_pcolorfast(xy, data, cls):
64506450
assert type(ax.pcolorfast(*xy, data)) == cls
64516451

64526452

6453+
def test_pcolorfast_bad_dims():
6454+
fig, ax = plt.subplots()
6455+
with pytest.raises(
6456+
TypeError, match=("the given X was 1D and the given Y was 2D")):
6457+
ax.pcolorfast(np.empty(6), np.empty((4, 7)), np.empty((8, 8)))
6458+
6459+
64536460
def test_shared_scale():
64546461
fig, axs = plt.subplots(2, 2, sharex=True, sharey=True)
64556462

0 commit comments

Comments
 (0)