@@ -55,8 +55,7 @@ def compare_float(expected, actual, relTol=None, absTol=None):
5555 'Actual: {actual}' ,
5656 'Abs diff: {absDiff}' ,
5757 'Abs tol: {absTol}' ]
58-
59- msg += '\n ' .join ([line .format (locals ()) for line in template ])
58+ msg += '\n ' .join ([line .format (** locals ()) for line in template ])
6059
6160 if relTol is not None :
6261 # The relative difference of the two values. If the expected value is
@@ -66,14 +65,13 @@ def compare_float(expected, actual, relTol=None, absTol=None):
6665 relDiff = relDiff / abs (expected )
6766
6867 if relTol < relDiff :
69- # The relative difference is a ratio, so it's always unitless .
68+ # The relative difference is a ratio, so it's always unit-less .
7069 template = ['' ,
7170 'Expected: {expected}' ,
7271 'Actual: {actual}' ,
7372 'Rel diff: {relDiff}' ,
7473 'Rel tol: {relTol}' ]
75-
76- msg += '\n ' .join ([line .format (locals ()) for line in template ])
74+ msg += '\n ' .join ([line .format (** locals ()) for line in template ])
7775
7876 return msg or None
7977
@@ -93,7 +91,7 @@ def get_cache_dir():
9391 return cache_dir
9492
9593
96- def get_file_hash (path , block_size = 2 ** 20 ):
94+ def get_file_hash (path , block_size = 2 ** 20 ):
9795 md5 = hashlib .md5 ()
9896 with open (path , 'rb' ) as fd :
9997 while True :
@@ -130,7 +128,7 @@ def _update_converter():
130128 '-sOutputFile=' + new , old ]
131129 converter ['pdf' ] = make_external_conversion_command (cmd )
132130 converter ['eps' ] = make_external_conversion_command (cmd )
133-
131+
134132 if matplotlib .checkdep_inkscape () is not None :
135133 cmd = lambda old , new : \
136134 ['inkscape' , '-z' , old , '--export-png' , new ]
@@ -149,7 +147,7 @@ def comparable_formats():
149147 """
150148 Returns the list of file formats that compare_images can compare
151149 on this system.
152-
150+
153151 """
154152 return ['png' ] + list (six .iterkeys (converter ))
155153
@@ -200,8 +198,8 @@ def convert(filename, cache):
200198
201199#: Maps file extensions to a function which takes a filename as its
202200#: only argument to return a list suitable for execution with Popen.
203- #: The purpose of this is so that the result file (with the given
204- #: extension) can be verified with tools such as xmllint for svg.
201+ #: The purpose of this is so that the result file (with the given
202+ #: extension) can be verified with tools such as xmllint for svg.
205203verifiers = {}
206204
207205# Turning this off, because it seems to cause multiprocessing issues
@@ -265,11 +263,11 @@ def calculate_rms(expectedImage, actualImage):
265263def compare_images (expected , actual , tol , in_decorator = False ):
266264 """
267265 Compare two "image" files checking differences within a tolerance.
268-
266+
269267 The two given filenames may point to files which are convertible to
270268 PNG via the `.converter` dictionary. The underlying RMS is calculated
271269 with the `.calculate_rms` function.
272-
270+
273271 Parameters
274272 ----------
275273 expected : str
@@ -283,7 +281,7 @@ def compare_images(expected, actual, tol, in_decorator=False):
283281 in_decorator : bool
284282 If called from image_comparison decorator, this should be
285283 True. (default=False)
286-
284+
287285 Example
288286 -------
289287 img1 = "./baseline/plot.png"
@@ -346,7 +344,7 @@ def compare_images(expected, actual, tol, in_decorator=False):
346344 'Expected: \n {expected}' ,
347345 'Actual: \n {actual}' ,
348346 'Difference:\n {diff}' ,
349- 'Tolerance: \n {tol}' ,]
347+ 'Tolerance: \n {tol}' , ]
350348 results = '\n ' .join ([line .format (** results ) for line in template ])
351349 return results
352350
0 commit comments