8000 Clarify error message for bad-dimensionality in pcolorfast(). by anntzer · Pull Request #27979 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
8000

Clarify error message for bad-dimensionality in pcolorfast(). #27979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6591,7 +6591,10 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
elif x.ndim == 2 and y.ndim == 2:
style = "quadmesh"
else:
raise TypeError("arguments do not match valid signatures")
raise TypeError(
f"When 3 positional parameters are passed to pcolorfast, the first "
f"two (X and Y) must be both 1D or both 2D; the given X was "
f"{x.ndim}D and the given Y was {y.ndim}D")
else:
raise _api.nargs_error('pcolorfast', '1 or 3', len(args))

Expand Down
7 changes: 7 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6450,6 +6450,13 @@ def test_pcolorfast(xy, data, cls):
assert type(ax.pcolorfast(*xy, data)) == cls


def test_pcolorfast_bad_dims():
fig, ax = plt.subplots()
with pytest.raises(
TypeError, match=("the given X was 1D and the given Y was 2D")):
ax.pcolorfast(np.empty(6), np.empty((4, 7)), np.empty((8, 8)))


def test_shared_scale():
fig, axs = plt.subplots(2, 2, sharex=True, sharey=True)

Expand Down
0