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

Skip to content

Commit 854c4dd

Browse files
committed
TST: Parametrize 2D test_unautoscale also.
1 parent 242346d commit 854c4dd

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6426,34 +6426,24 @@ def test_ytickcolor_is_not_markercolor():
64266426
assert tick.tick1line.get_markeredgecolor() != 'white'
64276427

64286428

6429+
@pytest.mark.parametrize('axis', ('x', 'y'))
64296430
@pytest.mark.parametrize('auto', (True, False, None))
6430-
def test_unautoscaley(auto):
6431-
fig, ax = plt.subplots()
6432-
x = np.arange(100)
6433-
y = np.linspace(-.1, .1, 100)
6434-
ax.scatter(x, y)
6435-
6436-
post_auto = ax.get_autoscaley_on() if auto is None else auto
6437-
6438-
ax.set_ylim((-.5, .5), auto=auto)
6439-
assert post_auto == ax.get_autoscaley_on()
6440-
fig.canvas.draw()
6441-
assert_array_equal(ax.get_ylim(), (-.5, .5))
6442-
6443-
6444-
@pytest.mark.parametrize('auto', (True, False, None))
6445-
def test_unautoscalex(auto):
6431+
def test_unautoscale(axis, auto):
64466432
fig, ax = plt.subplots()
64476433
x = np.arange(100)
64486434
y = np.linspace(-.1, .1, 100)
64496435
ax.scatter(y, x)
64506436

6451-
post_auto = ax.get_autoscalex_on() if auto is None else auto
6437+
get_autoscale_on = getattr(ax, f'get_autoscale{axis}_on')
6438+
set_lim = getattr(ax, f'set_{axis}lim')
6439+
get_lim = getattr(ax, f'get_{axis}lim')
6440+
6441+
post_auto = get_autoscale_on() if auto is None else auto
64526442

6453-
ax.set_xlim((-.5, .5), auto=auto)
6454-
assert post_auto == ax.get_autoscalex_on()
6443+
set_lim((-0.5, 0.5), auto=auto)
6444+
assert post_auto == get_autoscale_on()
64556445
fig.canvas.draw()
6456-
assert_array_equal(ax.get_xlim(), (-.5, .5))
6446+
assert_array_equal(get_lim(), (-0.5, 0.5))
64576447

64586448

64596449
@check_figures_equal(extensions=["png"])

0 commit comments

Comments
 (0)