1
1
import os
2
2
import sys
3
3
from pathlib import Path
4
+
4
5
from matplotlib .testing .compare import compare_images
5
- from ..exceptions import GMTImageComparisonFailure
6
+
7
+ from ..exceptions import GMTImageComparisonFailure , GMTInvalidInput
6
8
7
9
8
10
def check_figures_equal (fig_ref , fig_test , fig_prefix = None , tol = 0.0 ):
@@ -11,13 +13,13 @@ def check_figures_equal(fig_ref, fig_test, fig_prefix=None, tol=0.0):
11
13
if not fig_prefix :
12
14
try :
13
15
fig_prefix = sys ._getframe (1 ).f_code .co_name
14
- except VauleError :
16
+ except ValueError :
15
17
raise GMTInvalidInput ("fig_prefix is required." )
16
18
17
19
os .makedirs (result_dir , exist_ok = True )
18
20
19
- ref_image_path = os .path .join (result_dir , fig_prefix + ' -expected.png' )
20
- test_image_path = os .path .join (result_dir , fig_prefix + ' .png' )
21
+ ref_image_path = os .path .join (result_dir , fig_prefix + " -expected.png" )
22
+ test_image_path = os .path .join (result_dir , fig_prefix + " .png" )
21
23
22
24
fig_ref .savefig (ref_image_path )
23
25
fig_test .savefig (test_image_path )
@@ -31,5 +33,5 @@ def check_figures_equal(fig_ref, fig_test, fig_prefix=None, tol=0.0):
31
33
for key in ["actual" , "expected" ]:
32
34
err [key ] = os .path .relpath (err [key ])
33
35
raise GMTImageComparisonFailure (
34
- ' images not close (RMS %(rms).3f):\n \t %(actual)s\n \t %(expected)s '
35
- % err )
36
+ " images not close (RMS %(rms).3f):\n \t %(actual)s\n \t %(expected)s " % err
37
+ )
0 commit comments