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

Skip to content

Commit b663f14

Browse files
committed
TST: Parametrize 2D test_unautoscale also.
1 parent bce9c8d commit b663f14

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
@@ -6391,34 +6391,24 @@ def test_ytickcolor_is_not_markercolor():
63916391
assert tick.tick1line.get_markeredgecolor() != 'white'
63926392

63936393

6394+
@pytest.mark.parametrize('axis', ('x', 'y'))
63946395
@pytest.mark.parametrize('auto', (True, False, None))
6395-
def test_unautoscaley(auto):
6396-
fig, ax = plt.subplots()
6397-
x = np.arange(100)
6398-
y = np.linspace(-.1, .1, 100)
6399-
ax.scatter(x, y)
6400-
6401-
post_auto = ax.get_autoscaley_on() if auto is None else auto
6402-
6403-
ax.set_ylim((-.5, .5), auto=auto)
6404-
assert post_auto == ax.get_autoscaley_on()
6405-
fig.canvas.draw()
6406-
assert_array_equal(ax.get_ylim(), (-.5, .5))
6407-
6408-
6409-
@pytest.mark.parametrize('auto', (True, False, None))
6410-
def test_unautoscalex(auto):
6396+
def test_unautoscale(axis, auto):
64116397
fig, ax = plt.subplots()
64126398
x = np.arange(100)
64136399
y = np.linspace(-.1, .1, 100)
64146400
ax.scatter(y, x)
64156401

6416-
post_auto = ax.get_autoscalex_on() if auto is None else auto
6402+
get_autoscale_on = getattr(ax, f'get_autoscale{axis}_on')
6403+
set_lim = getattr(ax, f'set_{axis}lim')
6404+
get_lim = getattr(ax, f'get_{axis}lim')
6405+
6406+
post_auto = get_autoscale_on() if auto is None else auto
64176407

6418-
ax.set_xlim((-.5, .5), auto=auto)
6419-
assert post_auto == ax.get_autoscalex_on()
6408+
set_lim((-0.5, 0.5), auto=auto)
6409+
assert post_auto == get_autoscale_on()
64206410
fig.canvas.draw()
6421-
assert_array_equal(ax.get_xlim(), (-.5, .5))
6411+
assert_array_equal(get_lim(), (-0.5, 0.5))
64226412

64236413

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

0 commit comments

Comments
 (0)