Skip to content

Commit d8e791d

Browse files
committed
Support onle positional arguments
1 parent 9aa41f5 commit d8e791d

File tree

2 files changed

+5
-32
lines changed

2 files changed

+5
-32
lines changed

lib/matplotlib/contour.py

+1-18
Original file line numberDiff line numberDiff line change
@@ -1446,24 +1446,7 @@ def _contour_args(self, args, kwargs):
14461446
else:
14471447
fn = 'contour'
14481448
nargs = len(args)
1449-
if "X" in kwargs and "Y" in kwargs and "Z" in kwargs:
1450-
x, y, z = self._check_xyz(
1451-
[
1452-
kwargs.pop("X"),
1453-
kwargs.pop("Y"),
1454-
kwargs.pop("Z")
1455-
],
1456-
kwargs
1457-
)
1458-
elif (("X" in kwargs) ^ ("Y" in kwargs)) and "Z" in kwargs:
1459-
raise TypeError(
1460-
"Both or neither 'X' and 'Y' may be passed as kwargs. "
1461-
"Passing only one of 'X' or 'Y' is not allowed."
1462-
)
1463-
elif "Z" in kwargs:
1464-
z = ma.asarray(kwargs.pop("Z"), dtype=np.float64)
1465-
x, y = self._initialize_x_y(z)
1466-
elif 0 < nargs <= 2:
1449+
if 0 < nargs <= 2:
14671450
z = ma.asarray(args[0], dtype=np.float64)
14681451
x, y = self._initialize_x_y(z)
14691452
args = args[1:]

lib/matplotlib/tests/test_contour.py

+4-14
Original file line numberDiff line numberDiff line change
@@ -695,18 +695,8 @@ def test_contour_remove():
695695
assert ax.get_children() == orig_children
696696

697697

698-
def test_contour_kwargsonly():
699-
# Smoke test for GH#24743
700-
# Passing only kwargs
698+
def test_contour_no_args():
699+
fig, ax = plt.subplots()
701700
data = [[0, 1], [1, 0]]
702-
plt.contour(Z=data)
703-
plt.contour(X=data, Y=data, Z=data)
704-
705-
706-
def test_contour_either_xy():
707-
with pytest.raises(TypeError,
708-
match="Both or neither 'X' and 'Y' may be passed"):
709-
plt.contour(
710-
X=np.random.rand(30, 30),
711-
Z=np.random.rand(30, 30)
712-
)
701+
with pytest.raises(TypeError):
702+
ax.contour(Z=data)

0 commit comments

Comments
 (0)