Control: forwarded -1 https://github.com/matplotlib/matplotlib/pull/6595

Le 15/06/2016 13:08, Sandro Tosi a écrit :
> can you please send this upstream? thanks!

Sure. I also included the attached patch to order keys when building the
PDF file. That is needed to get reproducible output in some situations.

Regards,
Alexis Bienvenüe.


Description: Reproducible PDF output
 Sort dict string representations to get reproducible PDF output.
Author: Alexis Bienvenüe <[email protected]>

Index: matplotlib-1.5.2~rc2/lib/matplotlib/backends/backend_pdf.py
===================================================================
--- matplotlib-1.5.2~rc2.orig/lib/matplotlib/backends/backend_pdf.py
+++ matplotlib-1.5.2~rc2/lib/matplotlib/backends/backend_pdf.py
@@ -17,6 +17,7 @@ import sys
 import time
 import warnings
 import zlib
+import collections
 from io import BytesIO
 
 import numpy as np
@@ -196,8 +197,8 @@ def pdfRepr(obj):
     # represented as Name objects.
     elif isinstance(obj, dict):
         r = [b"<<"]
-        r.extend([Name(key).pdfRepr() + b" " + pdfRepr(val)
-                  for key, val in six.iteritems(obj)])
+        r.extend(sorted([Name(key).pdfRepr() + b" " + pdfRepr(val)
+                         for key, val in six.iteritems(obj)]))
         r.append(b">>")
         return fill(r)
 
@@ -499,14 +500,14 @@ class PdfFile(object):
 
         self.alphaStates = {}   # maps alpha values to graphics state objects
         self.nextAlphaState = 1
-        self.hatchPatterns = {}
+        self.hatchPatterns = collections.OrderedDict() # reproducible writeHatches
         self.nextHatch = 1
         self.gouraudTriangles = []
 
-        self.images = {}
+        self.images = collections.OrderedDict() # reproducible writeImages
         self.nextImage = 1
 
-        self.markers = {}
+        self.markers = collections.OrderedDict() # reproducible writeMarkers
         self.multi_byte_charprocs = {}
 
         self.paths = []

Reply via email to