| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,28 @@ | ||
| Reproducible PS and PDF output | ||
| ------------------------------ | ||
| Reproducible PS, PDF and SVG output | ||
| ----------------------------------- | ||
|
|
||
| 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}`` | ||
| will omit the timestamp altogether. | ||
|
|
||
| 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. 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 deterministic identifiers | ||
| and they end up as parts of one larger document, the identifiers can | ||
| collide and cause the different parts to affect each other. | ||
|
|
||
| These features are now enabled in the tests for the PDF and SVG | ||
| backends, so most test output files (but not all of them) are now | ||
| deterministic. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -136,6 +136,10 @@ def set_font_settings_for_testing(): | |
| rcParams['text.hinting_factor'] = 8 | ||
|
|
||
|
|
||
| def set_reproducibility_for_testing(): | ||
| rcParams['svg.hashsalt'] = 'matplotlib' | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis will also break, in a way, the determinism test.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityCan you explain in more detail? The _test_determinism_save function in test_backend_svg.py file also sets this rc parameter to a constant value.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityProbably along the same lines as @tacaswell; I was thinking it wouldn't fail if svg.hashsalt was broken. However, I see this test doesn't use the decorator anyway, so it is likely to still fail correctly.
Sorry, something went wrong.
All reactions
|
||
|
|
||
|
|
||
| def setup(): | ||
| # The baseline images are created in this locale, so we should use | ||
| # it during all of the tests. | ||
| Expand All | @@ -161,3 +165,4 @@ def setup(): | |
| rcdefaults() # Start with all defaults | ||
|
|
||
| set_font_settings_for_testing() | ||
| set_reproducibility_for_testing() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -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': | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityDoesn't this break the test of SOURCE_DATE_EPOCH ?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityNo, that test starts a separate subprocess to write the output and doesn't use the image_comparison decorator at all.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityAh, 🐑
Sorry, something went wrong.
All reactions
|
||
| kwargs.setdefault('metadata', | ||
| {'Creator': None, 'Producer': None, | ||
| 'CreationDate': None}) | ||
| fig.savefig(actual_fname, **kwargs) | ||
|
|
||
| expected_fname = self.copy_baseline(baseline, extension) | ||
| raise_on_image_difference(expected_fname, actual_fname, self.tol) | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityDo we even need the version here? It's in the Creator tag.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI 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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFair enough.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.