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

Skip to content

Commit 9600f61

Browse files
committed
Update a test to a figure-equality test.
Also minor cleanups to test_lines.py.
1 parent 3a5d8c2 commit 9600f61

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

lib/matplotlib/tests/test_lines.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44

55
from io import BytesIO
66
import itertools
7-
import matplotlib.lines as mlines
8-
import pytest
9-
from timeit import repeat
10-
import numpy as np
7+
import timeit
8+
119
from cycler import cycler
10+
import numpy as np
11+
import pytest
1212

1313
import matplotlib
14+
import matplotlib.lines as mlines
1415
import matplotlib.pyplot as plt
15-
from matplotlib.testing.decorators import image_comparison
16+
from matplotlib.testing.decorators import image_comparison, check_figures_equal
1617

1718

1819
# Runtimes on a loaded system are inherently flaky. Not so much that a rerun
@@ -45,15 +46,15 @@ def test_invisible_Line_rendering():
4546

4647
# [here Interactive panning and zooming is pretty responsive]
4748
# Time the canvas drawing:
48-
t_no_line = min(repeat(fig.canvas.draw, number=1, repeat=3))
49+
t_no_line = min(timeit.repeat(fig.canvas.draw, number=1, repeat=3))
4950
# (gives about 25 ms)
5051

5152
# Add the big invisible Line:
5253
ax.add_line(l)
5354

5455
# [Now interactive panning and zooming is very slow]
5556
# Time the canvas drawing:
56-
t_unvisible_line = min(repeat(fig.canvas.draw, number=1, repeat=3))
57+
t_unvisible_line = min(timeit.repeat(fig.canvas.draw, number=1, repeat=3))
5758
# gives about 290 ms for N = 10**7 pts
5859

5960
slowdown_factor = (t_unvisible_line/t_no_line)
@@ -199,13 +200,7 @@ def test_nan_is_sorted():
199200
assert not line._is_sorted([3, 5] + [np.nan] * 100 + [0, 2])
200201

201202

202-
def test_step_markers():
203-
fig, ax = plt.subplots()
204-
ax.step([0, 1], "-o")
205-
buf1 = BytesIO()
206-
fig.savefig(buf1)
207-
fig, ax = plt.subplots()
208-
ax.plot([0, 0, 1], [0, 1, 1], "-o", markevery=[0, 2])
209-
buf2 = BytesIO()
210-
fig.savefig(buf2)
211-
assert buf1.getvalue() == buf2.getvalue()
203+
@check_figures_equal()
204+
def test_step_markers(fig_test, fig_ref):
205+
fig_test.subplots().step([0, 1], "-o")
206+
fig_ref.subplots().plot([0, 0, 1], [0, 1, 1], "-o", markevery=[0, 2])

0 commit comments

Comments
 (0)