|
4 | 4 |
|
5 | 5 | from io import BytesIO
|
6 | 6 | 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 | + |
11 | 9 | from cycler import cycler
|
| 10 | +import numpy as np |
| 11 | +import pytest |
12 | 12 |
|
13 | 13 | import matplotlib
|
| 14 | +import matplotlib.lines as mlines |
14 | 15 | import matplotlib.pyplot as plt
|
15 |
| -from matplotlib.testing.decorators import image_comparison |
| 16 | +from matplotlib.testing.decorators import image_comparison, check_figures_equal |
16 | 17 |
|
17 | 18 |
|
18 | 19 | # Runtimes on a loaded system are inherently flaky. Not so much that a rerun
|
@@ -45,15 +46,15 @@ def test_invisible_Line_rendering():
|
45 | 46 |
|
46 | 47 | # [here Interactive panning and zooming is pretty responsive]
|
47 | 48 | # 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)) |
49 | 50 | # (gives about 25 ms)
|
50 | 51 |
|
51 | 52 | # Add the big invisible Line:
|
52 | 53 | ax.add_line(l)
|
53 | 54 |
|
54 | 55 | # [Now interactive panning and zooming is very slow]
|
55 | 56 | # 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)) |
57 | 58 | # gives about 290 ms for N = 10**7 pts
|
58 | 59 |
|
59 | 60 | slowdown_factor = (t_unvisible_line/t_no_line)
|
@@ -199,13 +200,7 @@ def test_nan_is_sorted():
|
199 | 200 | assert not line._is_sorted([3, 5] + [np.nan] * 100 + [0, 2])
|
200 | 201 |
|
201 | 202 |
|
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