Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

MAINT: Deterministic SVG and PDF tests#7748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
QuLogic merged 7 commits intomatplotlib:masterfromjkseppan:deterministic-tests
Jan 21, 2017

Conversation

jkseppan
Copy link
Member

There has been plenty of work (at least#4434,#5671,#5766,#6597) to make it possible to have deterministic svg and pdf output, or at least closer to deterministic than before. This change adds one related feature: callers can remove the bits of pdf metadata that contain the date and matplotlib version, so that new releases don't necessarily change the result of every test. Furthermore, this change enables all the optional pdf and svg determinism features in tests.

I am developing some improvements to test-result caching on another branch, and in my tests only the following test files still change from run to run after this patch (although in my environment I get KNOWNFAIL=27, SKIP=8 so some more are possible):

clip_path_clipping.svghatching.svgpgf_bbox_inches.pdfpgf_mixedmode.pdfpgf_pdflatex.pdfpgf_rcupdate1.pdfpgf_rcupdate2.pdfpgf_xelatex.pdfbbox_inches_tight_clipping.svgimage_clip.svgscaled_lines.svgoffsetbox_clipping.svgskew_axes.pdfskew_axes.svg

And document the standard keys in PdfPages. Also insert thematplotlib version in the default value of Producer as wellas Creator, to retain a debugging clue in case the user overridesone of them.
Remove the metadata entries that depend on the date andthe exact version.
@codecov-io
Copy link

Current coverage is 62.12% (diff: 100%)

Merging#7748 intomaster will increase coverage by<.01%

@@             master      #7748   diff @@==========================================  Files           174        174            Lines         56028      56028            Methods           0          0            Messages          0          0            Branches          0          0          ==========================================+ Hits          34805      34806     +1+ Misses        21223      21222     -1  Partials          0          0

Powered byCodecov. Last update1fa4dd7...eab297c

@tacaswelltacaswell added this to the2.1 (next point release) milestoneJan 5, 2017
@@ -298,7 +298,12 @@ def compare(self, idx, baseline, extension):
remove_ticks_and_titles(fig)

actual_fname = os.path.join(self.result_dir, baseline) + '.' + extension
fig.savefig(actual_fname, **self.savefig_kwargs)
kwargs = self.savefig_kwargs.copy()
if extension == 'pdf':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Doesn't this break the test ofSOURCE_DATE_EPOCH ?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

No, that test starts a separate subprocess to write the output and doesn't use the image_comparison decorator at all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ah, 🐑

@tacaswell
Copy link
Member

the pgf tests roll their own image comparison code.

attn@astrofrog this may need to be ported topytest-mpl?

@@ -136,6 +136,10 @@ def set_font_settings_for_testing():
rcParams['text.hinting_factor'] = 8


def set_reproducibility_for_testing():
rcParams['svg.hashsalt'] = 'matplotlib'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This will also break, in a way, the determinism test.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can you explain in more detail? The_test_determinism_save function intest_backend_svg.py file also sets this rc parameter to a constant value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Probably along the same lines as@tacaswell; I was thinking itwouldn't fail ifsvg.hashsalt was broken. However, I see this test doesn't use the decorator anyway, so it is likely to still fail correctly.

jkseppan added a commit to jkseppan/matplotlib that referenced this pull requestJan 7, 2017
There is a cache of png files keyed by the MD5 hashes of correspondingsvg and pdf files, which helps reduce test suite running times for svgand pdf files that stay exactly the same from one run to the next.This patch enables caching of test results, not only expectedresults, which is only useful if the tests are mostly deterministic(seematplotlib#7748). It adds reporting of cache misses, which can be helpfulin getting tests to stay deterministic, and expiration since thetest results are going to change more often than the expectedresults.
jkseppan added a commit to jkseppan/matplotlib that referenced this pull requestJan 8, 2017
There is a cache of png files keyed by the MD5 hashes of correspondingsvg and pdf files, which helps reduce test suite running times for svgand pdf files that stay exactly the same from one run to the next.This patch enables caching of test results, not only expectedresults, which is only useful if the tests are mostly deterministic(seematplotlib#7748). It adds reporting of cache misses, which can be helpfulin getting tests to stay deterministic, and expiration since thetest results are going to change more often than the expectedresults.
Copy link
Member

@QuLogicQuLogic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Some minor corrections, but otherwise fine.

The reproducibility of the output from the PS and PDF backends has so
far been tested using various plot elements but only default values of
options such as ``{ps,pdf}.fonttype`` that can affect the output at a
low level, and not with the mathtext or usetex features. When
matplotlib calls external tools (such as PS distillers or LaTeX) their
versions need to be kept constant for reproducibility, and they may
add sources of nondeterminism outside the control of matplotlib.

For SVG output, the ``svg.hashsalt`` rc parameter has been added in an
earlier release. In can be used to change some random id values in the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

In -> It

For SVG output, the ``svg.hashsalt`` rc parameter has been added in an
earlier release. In can be used to change some random id values in the
output to be deterministic, at the cost that including multiple such
svg files in one document can lead to collisions.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

svg -> SVG

output to be deterministic, at the cost that including multiple such
svg files in one document can lead to collisions.

These features are now enabled in the tests for the pdf and svg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

pdf -> PDF
svg -> SVG


The ``SOURCE_DATE_EPOCH`` environment variable can now be used to set
the timestamp value in the PS and PDF outputs. See
https://reproducible-builds.org/specs/source-date-epoch/

Alternatively, calling ``savefig`` with ``metadata={creationDate=None}``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thisdict literal is a bit broken; should bedict(creationDate=None) or{'creationDate': None}.

@@ -484,11 +483,13 @@ def __init__(self, filename, metadata=None):

self.infoDict = {
'Creator': 'matplotlib %s, http://matplotlib.org' % __version__,
'Producer': 'matplotlib pdf backend%s' %revision,
'Producer': 'matplotlib pdf backend%s' %__version__,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Do we even need the version here? It's in theCreator tag.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I thought including the version in both would help with debugging when the user has overridden just one of these. If you use Matplotlib as a component of some larger application, you might want to override Creator and leave Producer pointing to the PDF backend.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Fair enough.

@QuLogicQuLogic changed the titleMAINT: Deterministic SVG and PDF tests[MRG+1] MAINT: Deterministic SVG and PDF testsJan 20, 2017
The reproducibility of the output from the PS and PDF backends has so
far been tested using various plot elements but only default values of
options such as ``{ps,pdf}.fonttype`` that can affect the output at a
low level, and not with the mathtext or usetex features. When
matplotlib calls external tools (such as PS distillers or LaTeX) their
versions need to be kept constant for reproducibility, and they may
add sources of nondeterminism outside the control of matplotlib.

For SVG output, the ``svg.hashsalt`` rc parameter has been added in an
earlier release. It can be used to change some random id values in the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I don't understand the following sentence:
"It can be used to change some random id values in the output to be deterministic, at the cost thatincluding multiple such SVG files in one document can lead to collisions."
Isn't there an grammar problem?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'll try to rephrase.

@NelleV
Copy link
Member

Thanks! This looks good to me.
👍

@NelleVNelleV changed the title[MRG+1] MAINT: Deterministic SVG and PDF tests[MRG+2] MAINT: Deterministic SVG and PDF testsJan 20, 2017
SVG files in one document can lead to collisions.
earlier release. This parameter changes some random identifiers in the
SVG file to be deterministic. The downside of this setting is that if
more than one file is generated using with deterministic identifiers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

using with -> using.

@QuLogicQuLogic changed the title[MRG+2] MAINT: Deterministic SVG and PDF testsMAINT: Deterministic SVG and PDF testsJan 21, 2017
@QuLogicQuLogic merged commitb6f13f1 intomatplotlib:masterJan 21, 2017
@jkseppanjkseppan deleted the deterministic-tests branchJanuary 22, 2017 07:37
jkseppan added a commit to jkseppan/matplotlib that referenced this pull requestJan 22, 2017
There is a cache of png files keyed by the MD5 hashes of correspondingsvg and pdf files, which helps reduce test suite running times for svgand pdf files that stay exactly the same from one run to the next.This patch enables caching of test results, not only expectedresults, which is only useful if the tests are mostly deterministic(seematplotlib#7748). It adds reporting of cache misses, which can be helpfulin getting tests to stay deterministic, and expiration since thetest results are going to change more often than the expectedresults.
jkseppan added a commit to jkseppan/matplotlib that referenced this pull requestJan 30, 2017
There is a cache of png files keyed by the MD5 hashes of correspondingsvg and pdf files, which helps reduce test suite running times for svgand pdf files that stay exactly the same from one run to the next.This patch enables caching of test results, not only expectedresults, which is only useful if the tests are mostly deterministic(seematplotlib#7748). It adds reporting of cache misses, which can be helpfulin getting tests to stay deterministic, and expiration since thetest results are going to change more often than the expectedresults.
jkseppan added a commit to jkseppan/matplotlib that referenced this pull requestJan 30, 2017
There is a cache of png files keyed by the MD5 hashes of correspondingsvg and pdf files, which helps reduce test suite running times for svgand pdf files that stay exactly the same from one run to the next.This patch enables caching of test results, not only expectedresults, which is only useful if the tests are mostly deterministic(seematplotlib#7748). It adds reporting of cache misses, which can be helpfulin getting tests to stay deterministic, and expiration since thetest results are going to change more often than the expectedresults.
jkseppan added a commit to jkseppan/matplotlib that referenced this pull requestFeb 18, 2017
There is a cache of png files keyed by the MD5 hashes of correspondingsvg and pdf files, which helps reduce test suite running times for svgand pdf files that stay exactly the same from one run to the next.This patch enables caching of test results, not only expectedresults, which is only useful if the tests are mostly deterministic(seematplotlib#7748). It adds reporting of cache misses, which can be helpfulin getting tests to stay deterministic, and expiration since thetest results are going to change more often than the expectedresults.
jkseppan added a commit to jkseppan/matplotlib that referenced this pull requestFeb 20, 2017
There is a cache of png files keyed by the MD5 hashes of correspondingsvg and pdf files, which helps reduce test suite running times for svgand pdf files that stay exactly the same from one run to the next.This patch enables caching of test results, not only expectedresults, which is only useful if the tests are mostly deterministic(seematplotlib#7748). It adds reporting of cache misses, which can be helpfulin getting tests to stay deterministic, and expiration since thetest results are going to change more often than the expectedresults.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@NelleVNelleVNelleV left review comments

@tacaswelltacaswelltacaswell left review comments

@QuLogicQuLogicQuLogic approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v2.1
Development

Successfully merging this pull request may close these issues.

5 participants
@jkseppan@codecov-io@tacaswell@NelleV@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp