Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cba8e7d

Browse files
chahak13tacaswell
andcommitted
Update lib/matplotlib/contour.py
Co-authored-by: Thomas A Caswell <[email protected]>
1 parent 92a5b02 commit cba8e7d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/matplotlib/contour.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,8 +1456,10 @@ def _contour_args(self, args, kwargs):
14561456
kwargs
14571457
)
14581458
elif (("X" in kwargs) ^ ("Y" in kwargs)) and "Z" in kwargs:
1459-
raise KeyError("Both 'X' and 'Y' must be passed as kwargs. "
1460-
"Passing only one of the two is not allowed.")
1459+
raise TypeError(
1460+
"Both or neither 'X' and 'Y' may be passed as kwargs. "
1461+
"Passing only one of the two is not allowed."
1462+
)
14611463
elif "Z" in kwargs:
14621464
z = ma.asarray(kwargs.pop("Z"), dtype=np.float64)
14631465
x, y = self._initialize_x_y(z)

lib/matplotlib/tests/test_contour.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,8 @@ def test_contour_xyz_kwargsonly():
710710

711711

712712
def test_contour_either_xy():
713-
with pytest.raises(KeyError, match="Both 'X' and 'Y' must be passed"):
713+
with pytest.raises(TypeError,
714+
match="Both or neither 'X' and 'Y' may be passed"):
714715
plt.contour(
715716
X=np.random.rand(30, 30),
716717
Z=np.random.rand(30, 30)

0 commit comments

Comments
 (0)