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

Skip to content

Commit cd843e0

Browse files
committed
TST: Parametrize 2D test_unautoscale also.
1 parent cfb046e commit cd843e0

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

67196719

6720+
@pytest.mark.parametrize('axis', ('x', 'y'))
67206721
@pytest.mark.parametrize('auto', (True, False, None))
6721-
def test_unautoscaley(auto):
6722-
fig, ax = plt.subplots()
6723-
x = np.arange(100)
6724-
y = np.linspace(-.1, .1, 100)
6725-
ax.scatter(x, y)
6726-
6727-
post_auto = ax.get_autoscaley_on() if auto is None else auto
6728-
6729-
ax.set_ylim((-.5, .5), auto=auto)
6730-
assert post_auto == ax.get_autoscaley_on()
6731-
fig.canvas.draw()
6732-
assert_array_equal(ax.get_ylim(), (-.5, .5))
6733-
6734-
6735-
@pytest.mark.parametrize('auto', (True, False, None))
6736-
def test_unautoscalex(auto):
6722+
def test_unautoscale(axis, auto):
67376723
fig, ax = plt.subplots()
67386724
x = np.arange(100)
67396725
y = np.linspace(-.1, .1, 100)
67406726
ax.scatter(y, x)
67416727

6742-
post_auto = ax.get_autoscalex_on() if auto is None else auto
6728+
get_autoscale_on = getattr(ax, f'get_autoscale{axis}_on')
6729+
set_lim = getattr(ax, f'set_{axis}lim')
6730+
get_lim = getattr(ax, f'get_{axis}lim')
6731+
6732+
post_auto = get_autoscale_on() if auto is None else auto
67436733

6744-
ax.set_xlim((-.5, .5), auto=auto)
6745-
assert post_auto == ax.get_autoscalex_on()
6734+
set_lim((-0.5, 0.5), auto=auto)
6735+
assert post_auto == get_autoscale_on()
67466736
fig.canvas.draw()
6747-
assert_array_equal(ax.get_xlim(), (-.5, .5))
6737+
assert_array_equal(get_lim(), (-0.5, 0.5))
67486738

67496739

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

0 commit comments

Comments
 (0)