From 9600f61e43b850b8513bb430e1225230b0c10b17 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 24 Jun 2018 01:07:41 +0200 Subject: [PATCH] Update a test to a figure-equality test. Also minor cleanups to test_lines.py. --- lib/matplotlib/tests/test_lines.py | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/lib/matplotlib/tests/test_lines.py b/lib/matplotlib/tests/test_lines.py index a1ba6e764188..4b83ac05899a 100644 --- a/lib/matplotlib/tests/test_lines.py +++ b/lib/matplotlib/tests/test_lines.py @@ -4,15 +4,16 @@ from io import BytesIO import itertools -import matplotlib.lines as mlines -import pytest -from timeit import repeat -import numpy as np +import timeit + from cycler import cycler +import numpy as np +import pytest import matplotlib +import matplotlib.lines as mlines import matplotlib.pyplot as plt -from matplotlib.testing.decorators import image_comparison +from matplotlib.testing.decorators import image_comparison, check_figures_equal # Runtimes on a loaded system are inherently flaky. Not so much that a rerun @@ -45,7 +46,7 @@ def test_invisible_Line_rendering(): # [here Interactive panning and zooming is pretty responsive] # Time the canvas drawing: - t_no_line = min(repeat(fig.canvas.draw, number=1, repeat=3)) + t_no_line = min(timeit.repeat(fig.canvas.draw, number=1, repeat=3)) # (gives about 25 ms) # Add the big invisible Line: @@ -53,7 +54,7 @@ def test_invisible_Line_rendering(): # [Now interactive panning and zooming is very slow] # Time the canvas drawing: - t_unvisible_line = min(repeat(fig.canvas.draw, number=1, repeat=3)) + t_unvisible_line = min(timeit.repeat(fig.canvas.draw, number=1, repeat=3)) # gives about 290 ms for N = 10**7 pts slowdown_factor = (t_unvisible_line/t_no_line) @@ -199,13 +200,7 @@ def test_nan_is_sorted(): assert not line._is_sorted([3, 5] + [np.nan] * 100 + [0, 2]) -def test_step_markers(): - fig, ax = plt.subplots() - ax.step([0, 1], "-o") - buf1 = BytesIO() - fig.savefig(buf1) - fig, ax = plt.subplots() - ax.plot([0, 0, 1], [0, 1, 1], "-o", markevery=[0, 2]) - buf2 = BytesIO() - fig.savefig(buf2) - assert buf1.getvalue() == buf2.getvalue() +@check_figures_equal() +def test_step_markers(fig_test, fig_ref): + fig_test.subplots().step([0, 1], "-o") + fig_ref.subplots().plot([0, 0, 1], [0, 1, 1], "-o", markevery=[0, 2]) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy