Skip to content

Commit 427ff32

Browse files
committed
Add test for set_aspect() parameter validation
1 parent fd998cd commit 427ff32

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7527,6 +7527,18 @@ def test_bbox_aspect_axes_init():
75277527
assert_allclose(sizes, sizes[0])
75287528

75297529

7530+
def test_set_aspect_negative():
7531+
fig, ax = plt.subplots()
7532+
with pytest.raises(ValueError, match="must be finite and positive"):
7533+
ax.set_aspect(-1)
7534+
with pytest.raises(ValueError, match="must be finite and positive"):
7535+
ax.set_aspect(0)
7536+
with pytest.raises(ValueError, match="must be finite and positive"):
7537+
ax.set_aspect(np.inf)
7538+
with pytest.raises(ValueError, match="must be finite and positive"):
7539+
ax.set_aspect(-np.inf)
7540+
7541+
75307542
def test_redraw_in_frame():
75317543
fig, ax = plt.subplots(1, 1)
75327544
ax.plot([1, 2, 3])

0 commit comments

Comments
 (0)