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

Skip to content

Commit 625283f

Browse files
committed
Add test to check invalid limits ignored on log scale
1 parent 677e97d commit 625283f

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

lib/matplotlib/tests/test_scale.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,21 @@ def test_logscale_nonpos_values():
121121

122122
ax4.set_yscale('log')
123123
ax4.set_xscale('log')
124+
125+
126+
def test_invalid_log_lims():
127+
# Check that invalid log scale limits are ignored
128+
fig, ax = plt.subplots()
129+
ax.scatter(range(0, 4), range(0, 4))
130+
131+
ax.set_xscale('log')
132+
original_xlim = ax.get_xlim()
133+
with pytest.warns(UserWarning):
134+
ax.set_xlim(left=0)
135+
assert ax.get_xlim() == original_xlim
136+
137+
ax.set_yscale('log')
138+
original_ylim = ax.get_ylim()
139+
with pytest.warns(UserWarning):
140+
ax.set_ylim(bottom=0)
141+
assert ax.get_ylim() == original_ylim

0 commit comments

Comments
 (0)