@@ -506,21 +506,13 @@ def save_diff_image(expected, actual, output):
506
506
raise ImageComparisonFailure (
507
507
"Image sizes do not match expected size: {} "
508
508
"actual size {}" .format (expected_image .shape , actual_image .shape ))
509
- abs_diff_image = np .abs (expected_image - actual_image )
509
+ abs_diff = np .abs (expected_image - actual_image )
510
510
511
511
# expand differences in luminance domain
512
- abs_diff_image *= 255 * 10
513
- save_image_np = np .clip (abs_diff_image , 0 , 255 ).astype (np .uint8 )
514
- height , width , depth = save_image_np .shape
512
+ abs_diff *= 10
513
+ abs_diff = np .clip (abs_diff , 0 , 255 ).astype (np .uint8 )
515
514
516
- # The PDF renderer doesn't produce an alpha channel, but the
517
- # matplotlib PNG writer requires one, so expand the array
518
- if depth == 3 :
519
- with_alpha = np .empty ((height , width , 4 ), dtype = np .uint8 )
520
- with_alpha [:, :, 0 :3 ] = save_image_np
521
- save_image_np = with_alpha
515
+ if abs_diff .shape [2 ] == 4 : # Hard-code the alpha channel to fully solid
516
+ abs_diff [:, :, 3 ] = 255
522
517
523
- # Hard-code the alpha channel to fully solid
524
- save_image_np [:, :, 3 ] = 255
525
-
526
- Image .fromarray (save_image_np ).save (output , format = "png" )
518
+ Image .fromarray (abs_diff ).save (output , format = "png" )
0 commit comments