Skip to content

Commit 764cc4a

Browse files
authored
Merge pull request #14871 from anntzer/determinism
Parametrize determinism tests.
2 parents 4c8aadc + 6aee70f commit 764cc4a

File tree

6 files changed

+148
-249
lines changed

6 files changed

+148
-249
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
API changes
2+
```````````
3+
4+
The ``matplotlib.testing.determinism`` module, which exposes no public API, has
5+
been deleted.

lib/matplotlib/testing/determinism.py

Lines changed: 0 additions & 134 deletions
This file was deleted.

lib/matplotlib/tests/test_backend_pdf.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
from matplotlib.backends.backend_pdf import PdfPages
1313
from matplotlib.testing.compare import compare_images
1414
from matplotlib.testing.decorators import image_comparison
15-
from matplotlib.testing.determinism import (_determinism_source_date_epoch,
16-
_determinism_check)
1715

1816

1917
with warnings.catch_warnings():
@@ -137,36 +135,6 @@ def test_pdfpages_fspath():
137135
pdf.savefig(plt.figure())
138136

139137

140-
def test_source_date_epoch():
141-
"""Test SOURCE_DATE_EPOCH support for PDF output"""
142-
_determinism_source_date_epoch("pdf", b"/CreationDate (D:20000101000000Z)")
143-
144-
145-
def test_determinism_plain():
146-
"""Test for reproducible PDF output: simple figure"""
147-
_determinism_check('', format="pdf")
148-
149-
150-
def test_determinism_images():
151-
"""Test for reproducible PDF output: figure with different images"""
152-
_determinism_check('i', format="pdf")
153-
154-
155-
def test_determinism_hatches():
156-
"""Test for reproducible PDF output: figure with different hatches"""
157-
_determinism_check('h', format="pdf")
158-
159-
160-
def test_determinism_markers():
161-
"""Test for reproducible PDF output: figure with different markers"""
162-
_determinism_check('m', format="pdf")
163-
164-
165-
def test_determinism_all():
166-
"""Test for reproducible PDF output"""
167-
_determinism_check(format="pdf")
168-
169-
170138
@image_comparison(['hatching_legend.pdf'])
171139
def test_hatching_legend():
172140
"""Test for correct hatching on patches in legend"""

lib/matplotlib/tests/test_backend_ps.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import matplotlib.pyplot as plt
1212
from matplotlib import cbook, patheffects
1313
from matplotlib.testing.decorators import image_comparison
14-
from matplotlib.testing.determinism import (_determinism_source_date_epoch,
15-
_determinism_check)
1614

1715

1816
with warnings.catch_warnings():
@@ -98,28 +96,6 @@ def test_tilde_in_tempfilename(tmpdir):
9896
plt.savefig(base_tempdir / 'tex_demo.eps', format="ps")
9997

10098

101-
def test_source_date_epoch():
102-
"""Test SOURCE_DATE_EPOCH support for PS output"""
103-
# SOURCE_DATE_EPOCH support is not tested with text.usetex,
104-
# because the produced timestamp comes from ghostscript:
105-
# %%CreationDate: D:20000101000000Z00\'00\', and this could change
106-
# with another ghostscript version.
107-
_determinism_source_date_epoch(
108-
"ps", b"%%CreationDate: Sat Jan 01 00:00:00 2000")
109-
110-
111-
def test_determinism_all():
112-
"""Test for reproducible PS output"""
113-
_determinism_check(format="ps")
114-
115-
116-
@needs_usetex
117-
@needs_ghostscript
118-
def test_determinism_all_tex():
119-
"""Test for reproducible PS/tex output"""
120-
_determinism_check(format="ps", usetex=True)
121-
122-
12399
@image_comparison(["empty.eps"])
124100
def test_transparency():
125101
fig, ax = plt.subplots()

lib/matplotlib/tests/test_backend_svg.py

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -98,65 +98,6 @@ def test_bold_font_output_with_none_fonttype():
9898
ax.set_title('bold-title', fontweight='bold')
9999

100100

101-
def _test_determinism_save(filename, usetex):
102-
# This function is mostly copy&paste from "def test_visibility"
103-
mpl.rc('svg', hashsalt='asdf')
104-
mpl.rc('text', usetex=usetex)
105-
106-
fig = Figure() # Require no GUI.
107-
ax = fig.add_subplot(111)
108-
109-
x = np.linspace(0, 4 * np.pi, 50)
110-
y = np.sin(x)
111-
yerr = np.ones_like(y)
112-
113-
a, b, c = ax.errorbar(x, y, yerr=yerr, fmt='ko')
114-
for artist in b:
115-
artist.set_visible(False)
116-
ax.set_title('A string $1+2+\\sigma$')
117-
ax.set_xlabel('A string $1+2+\\sigma$')
118-
ax.set_ylabel('A string $1+2+\\sigma$')
119-
120-
fig.savefig(filename, format="svg")
121-
122-
123-
@pytest.mark.parametrize(
124-
"filename, usetex",
125-
# unique filenames to allow for parallel testing
126-
[("determinism_notex.svg", False),
127-
pytest.param("determinism_tex.svg", True, marks=needs_usetex)])
128-
def test_determinism(filename, usetex):
129-
import sys
130-
from subprocess import check_output, STDOUT, CalledProcessError
131-
plots = []
132-
for i in range(3):
133-
# Using check_output and setting stderr to STDOUT will capture the real
134-
# problem in the output property of the exception
135-
try:
136-
check_output(
137-
[sys.executable, '-R', '-c',
138-
'import matplotlib; '
139-
'matplotlib._called_from_pytest = True; '
140-
'matplotlib.use("svg", force=True); '
141-
'from matplotlib.tests.test_backend_svg '
142-
'import _test_determinism_save;'
143-
'_test_determinism_save(%r, %r)' % (filename, usetex)],
144-
stderr=STDOUT)
145-
except CalledProcessError as e:
146-
# it's easier to use utf8 and ask for forgiveness than try
147-
# to figure out what the current console has as an
148-
# encoding :-/
149-
print(e.output.decode(encoding="utf-8", errors="ignore"))
150-
raise e
151-
else:
152-
with open(filename, 'rb') as fd:
153-
plots.append(fd.read())
154-
finally:
155-
os.unlink(filename)
156-
for p in plots[1:]:
157-
assert p == plots[0]
158-
159-
160101
@needs_usetex
161102
def test_missing_psfont(monkeypatch):
162103
"""An error is raised if a TeX font lacks a Type-1 equivalent"""

0 commit comments

Comments
 (0)