@@ -352,14 +352,14 @@ def crop_to_same(actual_path, actual_image, expected_path, expected_image):
352
352
return actual_image , expected_image
353
353
354
354
355
- def calculate_rms (expectedImage , actualImage ):
355
+ def calculate_rms (expected_image , actual_image ):
356
356
"Calculate the per-pixel errors, then compute the root mean square error."
357
- if expectedImage .shape != actualImage .shape :
357
+ if expected_image .shape != actual_image .shape :
358
358
raise ImageComparisonFailure (
359
359
"Image sizes do not match expected size: {} "
360
- "actual size {}" .format (expectedImage .shape , actualImage .shape ))
360
+ "actual size {}" .format (expected_image .shape , actual_image .shape ))
361
361
# Convert to float to avoid overflowing finite integer types.
362
- return np .sqrt (((expectedImage - actualImage ).astype (float ) ** 2 ).mean ())
362
+ return np .sqrt (((expected_image - actual_image ).astype (float ) ** 2 ).mean ())
363
363
364
364
365
365
def compare_images (expected , actual , tol , in_decorator = False ):
@@ -428,26 +428,26 @@ def compare_images(expected, actual, tol, in_decorator=False):
428
428
expected = convert (expected , True )
429
429
430
430
# open the image files and remove the alpha channel (if it exists)
431
- expectedImage = _png .read_png_int (expected )
432
- actualImage = _png .read_png_int (actual )
433
- expectedImage = expectedImage [:, :, :3 ]
434
- actualImage = actualImage [:, :, :3 ]
431
+ expected_image = _png .read_png_int (expected )
432
+ actual_image = _png .read_png_int (actual )
433
+ expected_image = expected_image [:, :, :3 ]
434
+ actual_image = actual_image [:, :, :3 ]
435
435
436
- actualImage , expectedImage = crop_to_same (
437
- actual , actualImage , expected , expectedImage )
436
+ actual_image , expected_image = crop_to_same (
437
+ actual , actual_image , expected , expected_image )
438
438
439
439
diff_image = make_test_filename (actual , 'failed-diff' )
440
440
441
441
if tol <= 0 :
442
- if np .array_equal (expectedImage , actualImage ):
442
+ if np .array_equal (expected_image , actual_image ):
443
443
return None
444
444
445
445
# convert to signed integers, so that the images can be subtracted without
446
446
# overflow
447
- expectedImage = expectedImage .astype (np .int16 )
448
- actualImage = actualImage .astype (np .int16 )
447
+ expected_image = expected_image .astype (np .int16 )
448
+ actual_image = actual_image .astype (np .int16 )
449
449
450
- rms = calculate_rms (expectedImage , actualImage )
450
+ rms = calculate_rms (expected_image , actual_image )
451
451
452
452
if rms <= tol :
453
453
return None
@@ -481,21 +481,21 @@ def save_diff_image(expected, actual, output):
481
481
File path to save difference image to.
482
482
'''
483
483
# Drop alpha channels, similarly to compare_images.
484
- expectedImage = _png .read_png (expected )[..., :3 ]
485
- actualImage = _png .read_png (actual )[..., :3 ]
486
- actualImage , expectedImage = crop_to_same (
487
- actual , actualImage , expected , expectedImage )
488
- expectedImage = np .array (expectedImage ).astype (float )
489
- actualImage = np .array (actualImage ).astype (float )
490
- if expectedImage .shape != actualImage .shape :
484
+ expected_image = _png .read_png (expected )[..., :3 ]
485
+ actual_image = _png .read_png (actual )[..., :3 ]
486
+ actual_image , expected_image = crop_to_same (
487
+ actual , actual_image , expected , expected_image )
488
+ expected_image = np .array (expected_image ).astype (float )
489
+ actual_image = np .array (actual_image ).astype (float )
490
+ if expected_image .shape != actual_image .shape :
491
491
raise ImageComparisonFailure (
492
492
"Image sizes do not match expected size: {} "
493
- "actual size {}" .format (expectedImage .shape , actualImage .shape ))
494
- absDiffImage = np .abs (expectedImage - actualImage )
493
+ "actual size {}" .format (expected_image .shape , actual_image .shape ))
494
+ abs_diff_image = np .abs (expected_image - actual_image )
495
495
496
496
# expand differences in luminance domain
497
- absDiffImage *= 255 * 10
498
- save_image_np = np .clip (absDiffImage , 0 , 255 ).astype (np .uint8 )
497
+ abs_diff_image *= 255 * 10
498
+ save_image_np = np .clip (abs_diff_image , 0 , 255 ).astype (np .uint8 )
499
499
height , width , depth = save_image_np .shape
500
500
501
501
# The PDF renderer doesn't produce an alpha channel, but the
0 commit comments