From 49d01846fbc3f819291f677092e223671b8fd830 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sat, 19 Mar 2016 16:17:21 -0400 Subject: [PATCH] TST: raise ImageComparisonFailure on size mismatch Previously this would result in a ValueError --- lib/matplotlib/testing/compare.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/matplotlib/testing/compare.py b/lib/matplotlib/testing/compare.py index e107021484f5..a7da655795d5 100644 --- a/lib/matplotlib/testing/compare.py +++ b/lib/matplotlib/testing/compare.py @@ -242,6 +242,11 @@ def crop_to_same(actual_path, actual_image, expected_path, expected_image): def calculate_rms(expectedImage, actualImage): "Calculate the per-pixel errors, then compute the root mean square error." + if expectedImage.shape != actualImage.shape: + raise ImageComparisonFailure( + "image sizes do not match expected size: {0} " + "actual size {1}".format(expectedImage.shape, actualImage.shape)) + num_values = np.prod(expectedImage.shape) abs_diff_image = abs(expectedImage - actualImage)