From 5dd0a949f1b5b26c51cbb4513fd165f519031573 Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Sat, 30 Apr 2016 21:49:57 -0400 Subject: [PATCH 01/14] Using common module for regression testing --- Packages/testing/__init__.py | 0 .../testing/regression.py | 23 +++++++++- Packages/testing/setup.py | 14 ++++++ testing/vcs/test_vcs_1D_datawc.py | 21 +++------ testing/vcs/test_vcs_1D_datawc_missing.py | 29 ++---------- testing/vcs/test_vcs_1D_with_manyDs.py | 30 ++---------- testing/vcs/test_vcs_1d_in_boxfill.py | 27 ++--------- ...cs_1d_marker_not_shown_if_xaxis_flipped.py | 33 ++----------- testing/vcs/test_vcs_1d_missing.py | 26 ++--------- testing/vcs/test_vcs_animate_boxfill.py | 15 ++---- testing/vcs/test_vcs_animate_isofill.py | 23 ++++------ testing/vcs/test_vcs_animate_isoline.py | 27 ++++------- .../vcs/test_vcs_animate_isoline_colored.py | 20 +++----- .../test_vcs_animate_isoline_text_labels.py | 11 ++--- ...vcs_animate_isoline_text_labels_colored.py | 10 ++-- testing/vcs/test_vcs_animate_meshfill.py | 10 +--- testing/vcs/test_vcs_antialiasing.py | 1 - testing/vcs/test_vcs_aspect_ratio.py | 35 +++++--------- testing/vcs/test_vcs_auto_time_labels.py | 23 +++------- testing/vcs/test_vcs_autot_axis_titles.py | 22 ++------- testing/vcs/test_vcs_bad_time_units.py | 12 ++--- testing/vcs/test_vcs_basic_gms.py | 19 ++------ testing/vcs/test_vcs_basic_text.py | 17 ++----- testing/vcs/test_vcs_basic_vectors.py | 19 ++------ ...st_vcs_box_custom_as_def_vistrails_exts.py | 42 +++++------------ .../test_vcs_boxfill_10x10_masked_numpy.py | 28 +++-------- testing/vcs/test_vcs_boxfill_10x10_numpy.py | 27 +++-------- testing/vcs/test_vcs_boxfill_custom.py | 21 ++------- testing/vcs/test_vcs_boxfill_custom_ext1.py | 22 ++------- .../vcs/test_vcs_boxfill_custom_ext1_ext2.py | 22 ++------- testing/vcs/test_vcs_boxfill_custom_ext2.py | 20 ++------ ...t_vcs_boxfill_custom_non_default_levels.py | 24 ++-------- .../test_vcs_boxfill_decreasing_latitude.py | 27 ++--------- testing/vcs/test_vcs_boxfill_lambert_crash.py | 17 ++----- testing/vcs/test_vcs_boxfill_lev1_lev2.py | 35 ++++---------- .../vcs/test_vcs_boxfill_lev1_lev2_ext1.py | 37 +++++---------- .../test_vcs_boxfill_lev1_lev2_ext1_ext2.py | 39 +++++----------- .../vcs/test_vcs_boxfill_lev1_lev2_ext2.py | 37 +++++---------- .../test_vcs_boxfill_lev1_lev2_ta_missing.py | 39 +++++----------- testing/vcs/test_vcs_boxfill_polar.py | 31 +++---------- testing/vcs/test_vcs_boxfill_robinson_wrap.py | 15 +----- testing/vcs/test_vcs_canvas_background.py | 19 ++------ .../vcs/test_vcs_canvas_background_update.py | 20 ++------ testing/vcs/test_vcs_click_info.py | 20 ++------ testing/vcs/test_vcs_close.py | 6 --- testing/vcs/test_vcs_colormaps_source.py | 24 ++-------- .../vcs/test_vcs_colorpicker_appearance.py | 7 +-- testing/vcs/test_vcs_configurator_resize.py | 8 ++-- testing/vcs/test_vcs_continents.py | 25 ++-------- testing/vcs/test_vcs_create_get.py | 1 - testing/vcs/test_vcs_draw_logo_on.py | 16 ++----- testing/vcs/test_vcs_fillarea_transparency.py | 17 ++----- testing/vcs/test_vcs_first_png_blank.py | 19 ++------ testing/vcs/test_vcs_flipNone.py | 26 ++--------- testing/vcs/test_vcs_flipX.py | 26 ++--------- testing/vcs/test_vcs_flipXY.py | 25 ++-------- testing/vcs/test_vcs_flipY.py | 24 ++-------- testing/vcs/test_vcs_gen_meshfill.py | 29 ++---------- .../test_vcs_gms_animate_projected_plots.py | 23 ++-------- testing/vcs/test_vcs_gms_patterns_hatches.py | 16 ++----- testing/vcs/test_vcs_hatches_patterns.py | 24 ++-------- testing/vcs/test_vcs_import.py | 1 - testing/vcs/test_vcs_infinity.py | 20 ++------ testing/vcs/test_vcs_iso_celine_part1.py | 21 +++------ testing/vcs/test_vcs_iso_celine_part2.py | 25 +++------- ...st_vcs_isofill_data_read_north_to_south.py | 22 ++------- .../vcs/test_vcs_isofill_isoline_labels.py | 29 ++---------- .../vcs/test_vcs_isofill_mask_cell_shift.py | 29 +++--------- testing/vcs/test_vcs_isoline_labels.py | 34 +++----------- .../vcs/test_vcs_isoline_labels_background.py | 26 ++--------- ..._isoline_labels_multi_label_input_types.py | 46 +++++++------------ .../vcs/test_vcs_isoline_labelskipdistance.py | 26 ++--------- testing/vcs/test_vcs_isoline_numpy.py | 22 +++------ testing/vcs/test_vcs_isoline_width_stipple.py | 27 ++--------- testing/vcs/test_vcs_issue_960_labels.py | 26 ++++------- testing/vcs/test_vcs_lambert.py | 23 ++-------- testing/vcs/test_vcs_large_pattern_hatch.py | 27 ++--------- testing/vcs/test_vcs_legend.py | 17 ++----- testing/vcs/test_vcs_lon_axes_freak_out.py | 31 +++---------- testing/vcs/test_vcs_markers.py | 26 +++-------- testing/vcs/test_vcs_matplotlib_colormap.py | 26 ++--------- testing/vcs/test_vcs_mercator_edge.py | 23 ++-------- testing/vcs/test_vcs_meshfill_draw_mesh.py | 28 ++++------- testing/vcs/test_vcs_meshfill_no_wrapping.py | 26 ++--------- testing/vcs/test_vcs_meshfill_regular_grid.py | 23 ++-------- testing/vcs/test_vcs_meshfill_vertices.py | 21 ++------- testing/vcs/test_vcs_meshfill_zoom.py | 27 +++-------- testing/vcs/test_vcs_mintics.py | 20 ++------ testing/vcs/test_vcs_missing_colorname.py | 24 ++-------- ..._vcs_monotonic_decreasing_yxvsx_default.py | 29 ++++-------- testing/vcs/test_vcs_oned_level_axis.py | 27 +++-------- testing/vcs/test_vcs_patterns.py | 22 ++------- testing/vcs/test_vcs_plot_file_var.py | 14 +++--- .../test_vcs_plot_unstructured_via_boxfill.py | 20 ++------ testing/vcs/test_vcs_png_to_base64.py | 2 +- testing/vcs/test_vcs_png_window_resize.py | 17 ++----- .../vcs/test_vcs_polar_set_opt_param_polar.py | 30 +++--------- testing/vcs/test_vcs_remove_marker_none_1d.py | 24 ++-------- testing/vcs/test_vcs_setcolormap.py | 26 ++--------- .../vcs/test_vcs_settings_color_name_rgba.py | 27 +++-------- .../test_vcs_settings_color_name_rgba_1d.py | 22 ++------- ...st_vcs_settings_color_name_rgba_boxfill.py | 23 ++-------- ...st_vcs_settings_color_name_rgba_isoline.py | 23 ++-------- ...t_vcs_settings_color_name_rgba_meshfill.py | 23 ++-------- testing/vcs/test_vcs_star_triangle_markers.py | 17 ++----- testing/vcs/test_vcs_taylor_2quads.py | 33 ++----------- testing/vcs/test_vcs_taylor_template_ctl.py | 29 ++---------- testing/vcs/test_vcs_user_passed_date.py | 17 ++----- .../test_vcs_user_passed_date_as_string.py | 17 ++----- testing/vcs/test_vcs_vectors_missing.py | 27 +++-------- testing/vcs/test_vcs_vectors_robinson.py | 16 ++----- testing/vcs/test_vcs_vectors_robinson_wrap.py | 16 ++----- testing/vcs/test_vcs_verify_boxfill_basics.py | 13 +++--- testing/vcs/test_vcs_wmo_marker.py | 17 ++----- testing/vcs/test_vcs_wmo_markers.py | 25 +++------- testing/vcs/vtk_ui/vtk_ui_test.py | 14 ++---- .../vcsaddons/test_12_plot_one_leg_per_row.py | 15 ++---- .../test_12_plot_one_leg_per_row_right.py | 16 ++----- ...test_EzTemplate_12_plots_legd_direction.py | 17 ++----- ...t_EzTemplate_12_plots_margins_thickness.py | 15 ++---- .../test_EzTemplate_12_plots_mix_glb_local.py | 14 +----- .../test_EzTemplate_12_plots_spacing.py | 16 ++----- .../test_vcs_addons_EzTemplate_2x2.py | 24 +++------- .../vcsaddons/test_vcsaddons_preview_2x2.py | 16 ++----- 124 files changed, 589 insertions(+), 2135 deletions(-) create mode 100644 Packages/testing/__init__.py rename testing/checkimage.py => Packages/testing/regression.py (84%) create mode 100755 Packages/testing/setup.py diff --git a/Packages/testing/__init__.py b/Packages/testing/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/testing/checkimage.py b/Packages/testing/regression.py similarity index 84% rename from testing/checkimage.py rename to Packages/testing/regression.py index 9871f3557c..68f381ce4d 100644 --- a/testing/checkimage.py +++ b/Packages/testing/regression.py @@ -12,9 +12,28 @@ import re import sys import logging +import vcs defaultThreshold=10.0 +def init(): + testingDir = os.path.join(os.path.dirname(__file__), "..") + sys.path.append(testingDir) + + vcsinst = vcs.init() + vcsinst.setantialiasing(0) + vcsinst.drawlogooff() + vcsinst.setbgoutputdimensions(1200,1091,units="pixels") + return vcsinst + +def run(vcsinst, fname, baseline=sys.argv[1], threshold=defaultThreshold): + vcsinst.png(fname) + sys.exit(check_result_image(fname, baseline, threshold)) + +def run_wo_terminate(vcsinst, fname, baseline=sys.argv[1], threshold=defaultThreshold): + vcsinst.png(fname) + return check_result_image(fname, baseline, threshold) + def image_compare(testImage, baselineImage): imageDiff = vtk.vtkImageDifference() imageDiff.SetInputData(testImage) @@ -53,8 +72,8 @@ def find_alternates(fname): results.append(os.path.join(dirname, i)) return results -def check_result_image(fname, baselinefname, threshold = defaultThreshold, - baseline = True, cleanup=True): +def check_result_image(fname, baselinefname=sys.argv[1], threshold=defaultThreshold, + baseline=True, cleanup=True): testImage = image_from_file(fname) if testImage is None: print "Testing image missing, test failed." diff --git a/Packages/testing/setup.py b/Packages/testing/setup.py new file mode 100755 index 0000000000..70f790d7bf --- /dev/null +++ b/Packages/testing/setup.py @@ -0,0 +1,14 @@ +import os, sys +from distutils.core import setup +import cdat_info + +sys.path.append(os.environ.get('BUILD_DIR',"build")) + +setup(name="testing", + version=cdat_info.Version, + description="Testing infrastructure for cdat", + url="http://uvcdat.llnl.gov", + packages=['testing'], + package_dir={'testing': 'testing',}, + install_requires=['numpy','vcs', 'vtk'], +) diff --git a/testing/vcs/test_vcs_1D_datawc.py b/testing/vcs/test_vcs_1D_datawc.py index 1595a6cd71..8e671bb933 100644 --- a/testing/vcs/test_vcs_1D_datawc.py +++ b/testing/vcs/test_vcs_1D_datawc.py @@ -4,15 +4,13 @@ src=sys.argv[1] pth = os.path.join(os.path.dirname(__file__),"..") sys.path.append(pth) -import checkimage -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") +import testing.regression as regression + +x = regression.init() yx =x.createyxvsx() -data = """-11.14902417 -9.17390922 -7.29515002 +data = """-11.14902417 -9.17390922 -7.29515002 -7.51774549 -8.63608171 -10.4827395 -9.93859485 -7.3394366 -5.39241468 -5.74825567 -6.74967902 -7.09622319 -5.93836983 -4.04592997 -2.65591499 @@ -30,14 +28,9 @@ data = MV2.array(data) yx.datawc_x1 = 0 yx.datawc_x2 = 80 -yx.datawc_y1 =-12 -yx.datawc_y2 = 12 +yx.datawc_y1 =-12 +yx.datawc_y2 = 12 x.plot(data,yx,bg=1) -fnm = "test_vcs_1D_datawc.png" -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, "test_vcs_1D_datawc.png", src) \ No newline at end of file diff --git a/testing/vcs/test_vcs_1D_datawc_missing.py b/testing/vcs/test_vcs_1D_datawc_missing.py index 07e6f560aa..d6caabc8e9 100644 --- a/testing/vcs/test_vcs_1D_datawc_missing.py +++ b/testing/vcs/test_vcs_1D_datawc_missing.py @@ -1,19 +1,11 @@ -import vcs,numpy,cdms2,MV2,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") - -yx =x.createyxvsx() +x = regression.init() +yx = x.createyxvsx() data = """ --999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. +-999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. 0.059503571833625334 0.059503571833625334 0.05664014775641405 0.05193557222118004 0.04777129850801233 0.0407139313814465 0.029382624830271705 @@ -42,16 +34,5 @@ """.split() data = numpy.array(data,dtype=numpy.float) data = MV2.masked_less(data,-900) -#yx.datawc_x1 = 0 -#yx.datawc_x2 = 80 -##yx.datawc_y1 =-12 -#yx.datawc_y2 = 12 - - x.plot(data,yx,bg=1) -fnm = "test_vcs_1D_datawc_missing.png" -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, "test_vcs_1D_datawc_missing.png") diff --git a/testing/vcs/test_vcs_1D_with_manyDs.py b/testing/vcs/test_vcs_1D_with_manyDs.py index 1caba446e1..28a6a7a8bc 100644 --- a/testing/vcs/test_vcs_1D_with_manyDs.py +++ b/testing/vcs/test_vcs_1D_with_manyDs.py @@ -1,31 +1,9 @@ -import vcs,numpy,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage - -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") +import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression +x = regression.init() d = numpy.sin(numpy.arange(100)) -d=numpy.reshape(d,(10,10)) - - +d = numpy.reshape(d,(10,10)) one = x.create1d() - x.plot(d,one,bg=1) - - -fnm = "test_1D_with_manyDs.png" -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) - - - +regression.run(x, "test_1D_with_manyDs.png", sys.argv[1]) \ No newline at end of file diff --git a/testing/vcs/test_vcs_1d_in_boxfill.py b/testing/vcs/test_vcs_1d_in_boxfill.py index 292fe98a3c..1da5743947 100644 --- a/testing/vcs/test_vcs_1d_in_boxfill.py +++ b/testing/vcs/test_vcs_1d_in_boxfill.py @@ -1,29 +1,8 @@ -import vcs,numpy,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage - -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") +import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression +x = regression.init() d = numpy.sin(numpy.arange(100)) - b = x.createboxfill() - x.plot(d,b,bg=1) - - -fnm = "test_1d_in_boxfill.png" -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) - - - +regression.run(x, "test_1d_in_boxfill.png", sys.argv[1]) \ No newline at end of file diff --git a/testing/vcs/test_vcs_1d_marker_not_shown_if_xaxis_flipped.py b/testing/vcs/test_vcs_1d_marker_not_shown_if_xaxis_flipped.py index c350e4c599..f850f977e2 100644 --- a/testing/vcs/test_vcs_1d_marker_not_shown_if_xaxis_flipped.py +++ b/testing/vcs/test_vcs_1d_marker_not_shown_if_xaxis_flipped.py @@ -1,42 +1,15 @@ -import vcs -import numpy -import MV2 -import cdms2 -import sys -import os -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage - -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") +import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression +x = regression.init() data = MV2.array([4,5,6,7,1,3,7,9,])+230. - p = cdms2.createAxis([2,5,100,200,500,800,850,1000]) - data.setAxis(0,p) - data.id="jim" - gm=x.create1d() - gm.linewidth=0 gm.datawc_x1=1000 gm.datawc_x2=0 - gm.markersize=30 - x.plot(data,gm,bg=1) - -fnm = "test_1d_marker_not_shown_if_xaxis_flipped.png" -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, "test_1d_marker_not_shown_if_xaxis_flipped.png", sys.argv[1]) \ No newline at end of file diff --git a/testing/vcs/test_vcs_1d_missing.py b/testing/vcs/test_vcs_1d_missing.py index 3a6880bdd5..8c124e09c6 100644 --- a/testing/vcs/test_vcs_1d_missing.py +++ b/testing/vcs/test_vcs_1d_missing.py @@ -3,15 +3,11 @@ src=sys.argv[1] pth = os.path.join(os.path.dirname(__file__),"..") sys.path.append(pth) -import checkimage +import testing.regression as regression -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") +x = regression.init() yx =x.createyxvsx() - -data = """-11.14902417 -9.17390922 -7.29515002 +data = """-11.14902417 -9.17390922 -7.29515002 -7.51774549 -8.63608171 -10.4827395 -9.93859485 -7.3394366 -5.39241468 -5.74825567 -6.74967902 -7.09622319 -5.93836983 -4.04592997 -2.65591499 @@ -30,17 +26,5 @@ data=MV2.masked_where(MV2.logical_and(data>-4,data<-2),data) -#yx.datawc_x1 = 0 -#yx.datawc_x2 = 80 -##yx.datawc_y1 =-12 -#yx.datawc_y2 = 12 - - -x.plot(data,yx,bg=1) -fnm = "test_vcs_1d_missing.png" -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +x.plot(data, yx, bg=1) +regression.run(x, "test_vcs_1d_missing.png", src) diff --git a/testing/vcs/test_vcs_animate_boxfill.py b/testing/vcs/test_vcs_animate_boxfill.py index 2bbd53c267..641b59edb2 100644 --- a/testing/vcs/test_vcs_animate_boxfill.py +++ b/testing/vcs/test_vcs_animate_boxfill.py @@ -1,20 +1,14 @@ -import vcs -import cdms2 -import os -import sys -import time +import vcs, numpy, cdms2, MV2, os, sys, time, testing.regression as regression + pth = os.path.join(os.path.dirname(__file__),"..") sys.path.append(pth) -import checkimage - f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) s=f("clt",slice(0,12)) # read only 12 times steps to speed up things -x=vcs.init() +x = regression.init() x.setantialiasing(0) x.drawlogooff() x.setbgoutputdimensions(1200,1091,units="pixels") - gm=x.createboxfill() x.plot(s,gm,bg=1) x.animate.create() @@ -26,8 +20,7 @@ pth = os.path.join(src_pth,prefix) ret = 0 for p in pngs: - print "Checking:",p - ret += checkimage.check_result_image(p,os.path.join(pth,os.path.split(p)[1]),checkimage.defaultThreshold) + ret += regression.check_result_image(p,os.path.join(pth,os.path.split(p)[1])) if ret == 0: os.removedirs(os.path.split(p)[0]) os.remove("%s.mp4" % prefix) diff --git a/testing/vcs/test_vcs_animate_isofill.py b/testing/vcs/test_vcs_animate_isofill.py index ba5ea0e8d6..591d663621 100644 --- a/testing/vcs/test_vcs_animate_isofill.py +++ b/testing/vcs/test_vcs_animate_isofill.py @@ -1,20 +1,13 @@ -import vcs -import cdms2 -import os -import sys -import time + +import vcs, numpy, cdms2, MV2, os, sys, time, testing.regression as regression + pth = os.path.join(os.path.dirname(__file__),"..") sys.path.append(pth) -import checkimage - -f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) -s=f("clt",slice(0,12)) # read only 12 times steps to speed up things -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") +f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) +s = f("clt",slice(0,12)) # read only 12 times steps to speed up things +x = regression.init() gm=x.createisofill() x.plot(s,gm,bg=1) x.animate.create() @@ -26,8 +19,8 @@ pth = os.path.join(src_pth,prefix) ret = 0 for p in pngs: - print "Checking:",p - ret += checkimage.check_result_image(p,os.path.join(pth,os.path.split(p)[1]),checkimage.defaultThreshold) + ret += regression.check_result_image(p,os.path.join(pth,os.path.split(p)[1]), + regression.defaultThreshold) if ret == 0: os.removedirs(os.path.split(p)[0]) os.remove("%s.mp4" % prefix) diff --git a/testing/vcs/test_vcs_animate_isoline.py b/testing/vcs/test_vcs_animate_isoline.py index 41e0c7318b..cea333d3bb 100644 --- a/testing/vcs/test_vcs_animate_isoline.py +++ b/testing/vcs/test_vcs_animate_isoline.py @@ -1,33 +1,24 @@ -import vcs -import cdms2 -import os -import sys -import time +import vcs, numpy, cdms2, MV2, os, sys, time, testing.regression as regression + pth = os.path.join(os.path.dirname(__file__),"..") sys.path.append(pth) -import checkimage - -f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) -s=f("clt",slice(0,12)) # read only 12 times steps to speed up things -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") +f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) +s = f("clt",slice(0,12)) # read only 12 times steps to speed up things -iso=x.createisoline() -x.plot(s,iso,bg=1) +x = regression.init() +iso = x.createisoline() +x.plot(s,iso, bg=1) x.animate.create() print "Saving now" prefix= os.path.split(__file__)[1][:-3] x.animate.save("%s.mp4"%prefix) -pngs = x.animate.close(preserve_pngs = True) # so we can look at them again +pngs = x.animate.close(preserve_pngs=True) # so we can look at them again src_pth = sys.argv[1] pth = os.path.join(src_pth,prefix) ret = 0 for p in pngs: - print "Checking:",p - ret += checkimage.check_result_image(p,os.path.join(pth,os.path.split(p)[1]),checkimage.defaultThreshold) + ret += regression.check_result_image(p,os.path.join(pth,os.path.split(p)[1])) if ret == 0: os.removedirs(os.path.split(p)[0]) os.remove("%s.mp4" % prefix) diff --git a/testing/vcs/test_vcs_animate_isoline_colored.py b/testing/vcs/test_vcs_animate_isoline_colored.py index 4fed45c864..4519ac16c0 100644 --- a/testing/vcs/test_vcs_animate_isoline_colored.py +++ b/testing/vcs/test_vcs_animate_isoline_colored.py @@ -1,19 +1,12 @@ -import vcs -import cdms2 -import os -import sys -import time +import vcs, numpy, cdms2, MV2, os, sys, time, testing.regression as regression + pth = os.path.join(os.path.dirname(__file__),"..") sys.path.append(pth) -import checkimage -f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) -s=f("clt",slice(0,12)) # read only 12 times steps to speed up things +f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) +s = f("clt",slice(0,12)) # read only 12 times steps to speed up things -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") +x = regression.init() iso=x.createisoline() levs = range(0,101,10) @@ -34,8 +27,7 @@ pth = os.path.join(src_pth,prefix) ret = 0 for p in pngs: - print "Checking:",p - ret += checkimage.check_result_image(p,os.path.join(pth,os.path.split(p)[1]),checkimage.defaultThreshold) + ret += regression.check_result_image(p,os.path.join(pth,os.path.split(p)[1])) if ret == 0: os.removedirs(os.path.split(p)[0]) os.remove("%s.mp4" % prefix) diff --git a/testing/vcs/test_vcs_animate_isoline_text_labels.py b/testing/vcs/test_vcs_animate_isoline_text_labels.py index 7a3be1fc5e..0e83c02c6a 100644 --- a/testing/vcs/test_vcs_animate_isoline_text_labels.py +++ b/testing/vcs/test_vcs_animate_isoline_text_labels.py @@ -1,11 +1,7 @@ -import vcs -import cdms2 -import os -import sys -import time +import vcs, numpy, cdms2, MV2, os, sys, time, testing.regression as regression + pth = os.path.join(os.path.dirname(__file__),"..") sys.path.append(pth) -import checkimage f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) s=f("clt",slice(0,12)) # read only 12 times steps to speed up things @@ -27,8 +23,7 @@ pth = os.path.join(src_pth,prefix) ret = 0 for p in pngs: - print "Checking:",p - ret += checkimage.check_result_image(p,os.path.join(pth,os.path.split(p)[1]),checkimage.defaultThreshold) + ret += regression.check_result_image(p,os.path.join(pth,os.path.split(p)[1])) if ret == 0: os.removedirs(os.path.split(p)[0]) os.remove("%s.mp4" % prefix) diff --git a/testing/vcs/test_vcs_animate_isoline_text_labels_colored.py b/testing/vcs/test_vcs_animate_isoline_text_labels_colored.py index cf009e4a87..02711e2196 100644 --- a/testing/vcs/test_vcs_animate_isoline_text_labels_colored.py +++ b/testing/vcs/test_vcs_animate_isoline_text_labels_colored.py @@ -1,11 +1,7 @@ -import vcs -import cdms2 -import os -import sys -import time +import vcs, numpy, cdms2, MV2, os, sys, time, testing.regression as regression + pth = os.path.join(os.path.dirname(__file__),"..") sys.path.append(pth) -import checkimage f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) s=f("clt",slice(0,12)) # read only 12 times steps to speed up things @@ -36,7 +32,7 @@ ret = 0 for p in pngs: print "Checking:",p - ret += checkimage.check_result_image(p,os.path.join(pth,os.path.split(p)[1]),checkimage.defaultThreshold) + ret += regression.check_result_image(p,os.path.join(pth,os.path.split(p)[1])) if ret == 0: os.removedirs(os.path.split(p)[0]) os.remove("%s.mp4" % prefix) diff --git a/testing/vcs/test_vcs_animate_meshfill.py b/testing/vcs/test_vcs_animate_meshfill.py index 78d6b15516..aa89a8639d 100644 --- a/testing/vcs/test_vcs_animate_meshfill.py +++ b/testing/vcs/test_vcs_animate_meshfill.py @@ -1,12 +1,7 @@ -import vcs -import cdms2 -import os -import sys -import MV2 +import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression pth = os.path.join(os.path.dirname(__file__),"..") sys.path.append(pth) -import checkimage f=cdms2.open(os.path.join(vcs.sample_data,"sampleCurveGrid4.nc")) s=f("sample") @@ -38,8 +33,7 @@ pth = os.path.join(src_pth,prefix) ret = 0 for p in pngs: - print "Checking:",p - ret += checkimage.check_result_image(p,os.path.join(pth,os.path.split(p)[1]),checkimage.defaultThreshold) + ret += regression.check_result_image(p,os.path.join(pth,os.path.split(p)[1])) if ret == 0: os.removedirs(os.path.split(p)[0]) os.remove("%s.mp4" % prefix) diff --git a/testing/vcs/test_vcs_antialiasing.py b/testing/vcs/test_vcs_antialiasing.py index 34f43e040c..f744d3e04f 100644 --- a/testing/vcs/test_vcs_antialiasing.py +++ b/testing/vcs/test_vcs_antialiasing.py @@ -1,4 +1,3 @@ - import vcs x=vcs.init() x.drawlogooff() diff --git a/testing/vcs/test_vcs_aspect_ratio.py b/testing/vcs/test_vcs_aspect_ratio.py index 1e59304a37..9e3cb37676 100644 --- a/testing/vcs/test_vcs_aspect_ratio.py +++ b/testing/vcs/test_vcs_aspect_ratio.py @@ -1,27 +1,20 @@ - -import vcs -import cdms2 -import sys -import os -import MV2 -import vcs,numpy,cdms2,MV2,os,sys -src=sys.argv[1] +import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression +src = sys.argv[1] pth0 = os.path.dirname(_file__) pth = os.path.join(pth0,"..") sys.path.append(pth) -import checkimage -f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) -s=f("clt",time=slice(0,1),squeeze=1) -gm=vcs.createisofill() +f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) +s = f("clt",time=slice(0,1),squeeze=1) +gm = vcs.createisofill() def plot_a_ratio(s,gm,ratio): ret = 0 - x=vcs.init() -x.drawlogooff() + x = regression.init() + x.drawlogooff() x.open() x.geometry(400,800) - y=vcs.init() + y = regression.init() y.open() y.geometry(800,400) for X in [x,y]: @@ -32,19 +25,13 @@ def plot_a_ratio(s,gm,ratio): orient = "port" fnm = "aspect_ratio_%s_%s.png" % (orient,ratio) X.png(fnm) - print "fnm:",fnm src = os.path.join(pth0,fnm) - print "src:",src - ret += checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) + ret += regression.check_result_image(fnm, src) return ret -ret = 0 +ret = 0 for ratio in ["1t","2t",".5t","autot"]: ret += plot_a_ratio(s,gm,ratio) -sys.exit(ret) - - - - +sys.exit(ret) \ No newline at end of file diff --git a/testing/vcs/test_vcs_auto_time_labels.py b/testing/vcs/test_vcs_auto_time_labels.py index 2dfa661a9b..e5422b29cc 100644 --- a/testing/vcs/test_vcs_auto_time_labels.py +++ b/testing/vcs/test_vcs_auto_time_labels.py @@ -1,18 +1,7 @@ -import vcs,cdms2,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) -s=f("clt",longitude=slice(34,35),squeeze=1) -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") +import vcs, cdms2, os, sys, testing.regression as regression + +f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) +s = f("clt",longitude=slice(34,35),squeeze=1) +x = regression.init() x.plot(s,bg=1) -fnm = "test_vcs_auto_time_labels.png" -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, "test_vcs_auto_time_labels.png", sys.argv[1]) \ No newline at end of file diff --git a/testing/vcs/test_vcs_autot_axis_titles.py b/testing/vcs/test_vcs_autot_axis_titles.py index ec485ccc0a..dcc0f00b14 100644 --- a/testing/vcs/test_vcs_autot_axis_titles.py +++ b/testing/vcs/test_vcs_autot_axis_titles.py @@ -1,7 +1,4 @@ -import vcs -import cdms2 -import os -import sys +import vcs, cdms2, os, sys, testing.regression as regression testConfig = {'a_boxfill': ('clt.nc', 'clt'), 'a_mollweide_boxfill': ('clt.nc', 'clt'), @@ -11,10 +8,6 @@ 'a_robinson_isoline': ('clt.nc', 'clt')} # Tests if ratio=autot works correctly for background and foreground plots -src = sys.argv[1] -bg = 1 -if (sys.argv[2] == 'foreground'): - bg = 0 plot = sys.argv[3] x_over_y = sys.argv[4] if (x_over_y == '0.5'): @@ -26,12 +19,9 @@ pth = os.path.join(os.path.dirname(__file__), "..") sys.path.append(pth) -import checkimage - f = cdms2.open(vcs.sample_data + "/" + testConfig[plot][0]) s = f(testConfig[plot][1]) - -x = vcs.init(bg=bg, geometry=(xSize, ySize)) +x = regression.init(bg=bg, geometry=(xSize, ySize)) # graphics method if (plot.find('boxfill') != -1): @@ -50,10 +40,4 @@ x.drawlogooff() x.plot(s, gm, ratio="autot") name = "test_autot_axis_titles_" + plot[2:] + "_" + x_over_y + "_" + str(bg) + ".png" -x.png(name) - -print "name:", name -print "src:", src - -ret = checkimage.check_result_image(name, src, checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, name, sys.argv[1]) \ No newline at end of file diff --git a/testing/vcs/test_vcs_bad_time_units.py b/testing/vcs/test_vcs_bad_time_units.py index b89c2f7a77..0bdcd16c2c 100644 --- a/testing/vcs/test_vcs_bad_time_units.py +++ b/testing/vcs/test_vcs_bad_time_units.py @@ -1,8 +1,8 @@ -import cdms2,vcs -import os,sys +import cdms2, vcs +import os, sys -f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) -s=f("clt",slice(0,1)) +f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) +s = f("clt",slice(0,1)) s.getTime().units="XXX-))rvv" -x=vcs.init() -x.plot(s,bg=1) +x = vcs.init() +x.plot(s, bg=1) diff --git a/testing/vcs/test_vcs_basic_gms.py b/testing/vcs/test_vcs_basic_gms.py index daa144d9dd..2cffb86e64 100644 --- a/testing/vcs/test_vcs_basic_gms.py +++ b/testing/vcs/test_vcs_basic_gms.py @@ -1,6 +1,4 @@ - -import sys,os -import argparse +import argparse, os, sys, cdms2, MV2, testing.regression as regression, vcs, vtk p = argparse.ArgumentParser(description="Basic gm testing code for vcs") p.add_argument("--source", dest="src", help="source image file") @@ -25,20 +23,9 @@ gm_type= args.gm src = args.src -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage - -import vcs -import sys -import cdms2 -import vtk -import os -import MV2 - bg = not args.show -x=vcs.init() +x = vcs.init() x.setantialiasing(0) x.drawlogooff() if bg: @@ -143,7 +130,7 @@ print "src:",src if args.show: raw_input("Press Enter") -ret = checkimage.check_result_image(fnm+'.png',src,20., cleanup=not args.keep) +ret = regression.check_result_image(fnm+'.png',src,20., cleanup=not args.keep) if args.show: raw_input("Press Enter") sys.exit(ret) diff --git a/testing/vcs/test_vcs_basic_text.py b/testing/vcs/test_vcs_basic_text.py index d46bd4f48c..d69f37ce00 100644 --- a/testing/vcs/test_vcs_basic_text.py +++ b/testing/vcs/test_vcs_basic_text.py @@ -1,11 +1,6 @@ -import vcs,numpy,cdms2,MV2,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage - -x=vcs.init() +import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression +x = regression.init() x.drawlogooff() x.setbgoutputdimensions(1200,1091,units="pixels") txt=x.createtext() @@ -16,10 +11,4 @@ txt.valign="base" txt.angle=45 x.plot(txt,bg=1) -fnm = "test_basic_text.png" -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, "test_basic_text.png", sys.argv[1]) diff --git a/testing/vcs/test_vcs_basic_vectors.py b/testing/vcs/test_vcs_basic_vectors.py index 561f7f2d83..37626e670f 100644 --- a/testing/vcs/test_vcs_basic_vectors.py +++ b/testing/vcs/test_vcs_basic_vectors.py @@ -1,6 +1,5 @@ +import argparse, os, sys, numpy, cdms2, MV2, vcs, vtk -import sys,os -import argparse p = argparse.ArgumentParser(description="Basic gm testing code for vcs") p.add_argument("--source", dest="src", help="source image file") @@ -18,21 +17,11 @@ if not args.show: src = args.src - pth = os.path.join(os.path.dirname(__file__),"..") - sys.path.append(pth) - import checkimage - -import vcs -import sys -import cdms2 -import vtk -import os -import MV2 -import numpy + import testing.regression as regression bg = not args.show -x=vcs.init() +x = vcs.init() x.setantialiasing(0) x.drawlogooff() if bg: @@ -95,7 +84,7 @@ x.png(fnm) print "fnm:",fnm print "src:",src - ret = checkimage.check_result_image(fnm+'.png',src,checkimage.defaultThreshold, cleanup=not args.keep) + ret = regression.check_result_image(fnm+'.png',src, regression.defaultThreshold, cleanup=not args.keep) if args.show: raw_input("Press Enter") sys.exit(ret) diff --git a/testing/vcs/test_vcs_box_custom_as_def_vistrails_exts.py b/testing/vcs/test_vcs_box_custom_as_def_vistrails_exts.py index c012c09ca7..7d81b89817 100644 --- a/testing/vcs/test_vcs_box_custom_as_def_vistrails_exts.py +++ b/testing/vcs/test_vcs_box_custom_as_def_vistrails_exts.py @@ -1,30 +1,12 @@ -import vcs -import cdms2 -import os -import sys -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage - -f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) -s=f("clt",slice(0,1),squeeze=1) - -x=vcs.init() -x.drawlogooff() -x.setantialiasing(0) -x.setbgoutputdimensions(1200,1091,units="pixels") - -gm=x.createboxfill() -gm.boxfill_type="custom" -gm.levels=[1.e20,1.e20] -gm.ext_1="y" -gm.ext_2="y" - -x.plot(s,gm,bg=1) -fnm = "test_box_custom_as_def_vistrails_exts.png" -src =sys.argv[1] -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +import os, sys, cdms2, vcs, testing.regression as regression + +f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) +s = f("clt",slice(0,1),squeeze=1) +x = regression.init() +gm = x.createboxfill() +gm.boxfill_type = "custom" +gm.levels = [1.e20,1.e20] +gm.ext_1 = "y" +gm.ext_2 = "y" +x.plot(s, gm, bg=1) +regression.run(x, "test_box_custom_as_def_vistrails_exts.png", sys.argv[1]) \ No newline at end of file diff --git a/testing/vcs/test_vcs_boxfill_10x10_masked_numpy.py b/testing/vcs/test_vcs_boxfill_10x10_masked_numpy.py index b2cdf8319a..2444cc8a82 100644 --- a/testing/vcs/test_vcs_boxfill_10x10_masked_numpy.py +++ b/testing/vcs/test_vcs_boxfill_10x10_masked_numpy.py @@ -1,23 +1,9 @@ +import vcs, numpy, os, sys, testing.regression as regression -import vcs,numpy,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +s = numpy.sin(numpy.arange(100)) +s = numpy.reshape(s,(10,10)) +s = numpy.ma.masked_greater(s,.5) -s= numpy.sin(numpy.arange(100)) -s=numpy.reshape(s,(10,10)) -s=numpy.ma.masked_greater(s,.5) -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") -x.plot(s,bg=1) -fnm= "test_vcs_boxfill_10x10_masked_numpy.png" - -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +x = regression.init() +x.plot(s, bg=1) +regression.run(x, "test_vcs_boxfill_10x10_masked_numpy.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_boxfill_10x10_numpy.py b/testing/vcs/test_vcs_boxfill_10x10_numpy.py index 0791051984..a45aa5889d 100644 --- a/testing/vcs/test_vcs_boxfill_10x10_numpy.py +++ b/testing/vcs/test_vcs_boxfill_10x10_numpy.py @@ -1,22 +1,7 @@ +import vcs, numpy, os, sys, testing.regression as regression -import vcs,numpy,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage - -s= numpy.sin(numpy.arange(100)) -s=numpy.reshape(s,(10,10)) -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") -x.plot(s,bg=1) -fnm= "test_vcs_boxfill_10x10_numpy.png" - -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +s = numpy.sin(numpy.arange(100)) +s = numpy.reshape(s,(10,10)) +x = regression.init() +x.plot(s) +regression.run(x, "test_vcs_boxfill_10x10_numpy.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_boxfill_custom.py b/testing/vcs/test_vcs_boxfill_custom.py index 16685d9715..5330a11037 100644 --- a/testing/vcs/test_vcs_boxfill_custom.py +++ b/testing/vcs/test_vcs_boxfill_custom.py @@ -1,7 +1,4 @@ -import cdms2 -import os -import sys -import vcs +import cdms2, os, sys, vcs, testing.regression as regression # Load the clt data: dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) @@ -10,10 +7,7 @@ time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0')) # Initialize canvas: -canvas = vcs.init() -canvas.setantialiasing(0) -canvas.setbgoutputdimensions(1200,1091,units="pixels") -canvas.drawlogooff() +canvas = regression.init() # Create and plot quick boxfill with default settings: boxfill=canvas.createboxfill() @@ -24,14 +18,5 @@ canvas.plot(clt, boxfill, bg=1) # Load the image testing module: -testingDir = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(testingDir) -import checkimage - # Create the test image and compare: -baseline = sys.argv[1] -testFile = "test_boxfill_custom.png" -canvas.png(testFile) -ret = checkimage.check_result_image(testFile, baseline, - checkimage.defaultThreshold) -sys.exit(ret) +regression.run(canvas, "test_boxfill_custom.png") diff --git a/testing/vcs/test_vcs_boxfill_custom_ext1.py b/testing/vcs/test_vcs_boxfill_custom_ext1.py index dd16ab8376..7a5e2005ec 100644 --- a/testing/vcs/test_vcs_boxfill_custom_ext1.py +++ b/testing/vcs/test_vcs_boxfill_custom_ext1.py @@ -1,7 +1,4 @@ -import cdms2 -import os -import sys -import vcs +import cdms2, os, sys, vcs, testing.regression as regression # Load the clt data: dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) @@ -10,10 +7,7 @@ time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0')) # Initialize canvas: -canvas = vcs.init() -canvas.setantialiasing(0) -canvas.setbgoutputdimensions(1200,1091,units="pixels") -canvas.drawlogooff() +canvas = regression.init() # Create and plot quick boxfill with default settings: boxfill=canvas.createboxfill() @@ -28,14 +22,4 @@ canvas.plot(clt, boxfill, bg=1) # Load the image testing module: -testingDir = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(testingDir) -import checkimage - -# Create the test image and compare: -baseline = sys.argv[1] -testFile = "test_boxfill_custom_ext1.png" -canvas.png(testFile) -ret = checkimage.check_result_image(testFile, baseline, - checkimage.defaultThreshold) -sys.exit(ret) +regression.run(canvas, "test_boxfill_custom_ext1.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_boxfill_custom_ext1_ext2.py b/testing/vcs/test_vcs_boxfill_custom_ext1_ext2.py index 68b5a9a41d..7440716716 100644 --- a/testing/vcs/test_vcs_boxfill_custom_ext1_ext2.py +++ b/testing/vcs/test_vcs_boxfill_custom_ext1_ext2.py @@ -1,7 +1,4 @@ -import cdms2 -import os -import sys -import vcs +import os, sys, cdms2, vcs, testing.regression as regression # Load the clt data: dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) @@ -10,10 +7,7 @@ time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0')) # Initialize canvas: -canvas = vcs.init() -canvas.setantialiasing(0) -canvas.setbgoutputdimensions(1200,1091,units="pixels") -canvas.drawlogooff() +canvas = regression.init() # Create and plot quick boxfill with default settings: boxfill=canvas.createboxfill() @@ -29,14 +23,4 @@ canvas.plot(clt, boxfill, bg=1) # Load the image testing module: -testingDir = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(testingDir) -import checkimage - -# Create the test image and compare: -baseline = sys.argv[1] -testFile = "test_boxfill_custom_ext1_ext2.png" -canvas.png(testFile) -ret = checkimage.check_result_image(testFile, baseline, - checkimage.defaultThreshold) -sys.exit(ret) +regression.run(canvas, "test_boxfill_custom_ext1_ext2.png") diff --git a/testing/vcs/test_vcs_boxfill_custom_ext2.py b/testing/vcs/test_vcs_boxfill_custom_ext2.py index 959fc2c6c0..d45950bdbb 100644 --- a/testing/vcs/test_vcs_boxfill_custom_ext2.py +++ b/testing/vcs/test_vcs_boxfill_custom_ext2.py @@ -3,6 +3,8 @@ import sys import vcs +import testing.regression as regression + # Load the clt data: dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) clt = dataFile("clt") @@ -10,10 +12,7 @@ time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0')) # Initialize canvas: -canvas = vcs.init() -canvas.setantialiasing(0) -canvas.setbgoutputdimensions(1200,1091,units="pixels") -canvas.drawlogooff() +canvas = regression.init() # Create and plot quick boxfill with default settings: boxfill=canvas.createboxfill() @@ -27,15 +26,4 @@ canvas.plot(clt, boxfill, bg=1) -# Load the image testing module: -testingDir = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(testingDir) -import checkimage - -# Create the test image and compare: -baseline = sys.argv[1] -testFile = "test_boxfill_custom_ext2.png" -canvas.png(testFile) -ret = checkimage.check_result_image(testFile, baseline, - checkimage.defaultThreshold) -sys.exit(ret) +regression.run(canvas, "test_boxfill_custom_ext2.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_boxfill_custom_non_default_levels.py b/testing/vcs/test_vcs_boxfill_custom_non_default_levels.py index 7363d22508..b84db2bb52 100644 --- a/testing/vcs/test_vcs_boxfill_custom_non_default_levels.py +++ b/testing/vcs/test_vcs_boxfill_custom_non_default_levels.py @@ -1,7 +1,4 @@ -import cdms2 -import os -import sys -import vcs +import cdms2, os, sys, vcs, testing.regression as regression # Load the clt data: dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) @@ -10,10 +7,7 @@ time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0')) # Initialize canvas: -canvas = vcs.init() -canvas.setantialiasing(0) -canvas.setbgoutputdimensions(1200,1091,units="pixels") -canvas.drawlogooff() +canvas = regression.init() # Create and plot quick boxfill with default settings: boxfill=canvas.createboxfill() @@ -25,16 +19,4 @@ boxfill.fillareacolors=vcs.getcolors(levels) canvas.plot(clt, boxfill, bg=1) - -# Load the image testing module: -testingDir = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(testingDir) -import checkimage - -# Create the test image and compare: -baseline = sys.argv[1] -testFile = "test_boxfill_custom_no_default_levels.png" -canvas.png(testFile) -ret = checkimage.check_result_image(testFile, baseline, - checkimage.defaultThreshold) -sys.exit(ret) +regression.run(canvas, "test_boxfill_custom_no_default_levels.png") diff --git a/testing/vcs/test_vcs_boxfill_decreasing_latitude.py b/testing/vcs/test_vcs_boxfill_decreasing_latitude.py index 009b947a9e..1f727e3b56 100755 --- a/testing/vcs/test_vcs_boxfill_decreasing_latitude.py +++ b/testing/vcs/test_vcs_boxfill_decreasing_latitude.py @@ -1,23 +1,10 @@ #!/usr/bin/env python -import cdms2 -import cdutil -import os -import sys -import vcs - -pth = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(pth) -import checkimage +import cdms2, cdutil, os, sys, vcs, testing.regression as regression f = cdms2.open(sys.argv[2]) ice = f("variable_6") -x = vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200, 900, units="pixels") +x = regression.init() -#gm = x.createisofill() -#gm.label = "y" gm = x.createboxfill() gm.boxfill_type = "custom" @@ -44,12 +31,8 @@ tmpl.legend.y2 = .055 tmpl.max.priority = 1 -#tmpl.crdate.priority=1 -#tmpl.crdate.x=.8 -#tmpl.crdate.y=.95 txt = x.createtext() txt.height = 20 -#txt.color=242 txt.valign = "half" txt.halign = "center" @@ -69,8 +52,4 @@ gm.datawc_y1 = 90 x.plot(ice, gm, tmpl, bg = 1) -fnm = "test_boxfill_decreasing_latitude.png" -x.png(fnm) -ret = checkimage.check_result_image(fnm, sys.argv[1], checkimage.defaultThreshold) -sys.exit(ret) - +regression.run(x, "test_boxfill_decreasing_latitude.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_boxfill_lambert_crash.py b/testing/vcs/test_vcs_boxfill_lambert_crash.py index f1827882f1..f445ba5551 100644 --- a/testing/vcs/test_vcs_boxfill_lambert_crash.py +++ b/testing/vcs/test_vcs_boxfill_lambert_crash.py @@ -1,17 +1,10 @@ #!/usr/bin/env python -import cdms2 -import os -import sys -import vcs - -pth = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(pth) -import checkimage +import cdms2, os, sys, vcs, testing.regression as regression f = cdms2.open(sys.argv[2]) -a=f("Z3") +a = f("Z3") -x=vcs.init() +x = regression.init() x.setantialiasing(0) x.drawlogooff() x.setbgoutputdimensions(1200, 900, units="pixels") @@ -24,6 +17,4 @@ fileName = os.path.basename(__file__) fileName = os.path.splitext(fileName)[0] fileName += '.png' -x.png(fileName) -ret = checkimage.check_result_image(fileName, sys.argv[1], checkimage.defaultThreshold) -sys.exit(ret) +ret = regression.run(x, fileName) diff --git a/testing/vcs/test_vcs_boxfill_lev1_lev2.py b/testing/vcs/test_vcs_boxfill_lev1_lev2.py index 5c69d7af3d..c5b5cbcbee 100644 --- a/testing/vcs/test_vcs_boxfill_lev1_lev2.py +++ b/testing/vcs/test_vcs_boxfill_lev1_lev2.py @@ -1,25 +1,10 @@ - -import cdms2,sys,vcs,sys,os -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -f=cdms2.open(vcs.sample_data+"/clt.nc") -s=f("clt",slice(0,1),squeeze=1) -b=x.createboxfill() -b.level_1=.5 -b.level_2=14.5 -x.plot(s,b,bg=1) - -fnm= "test_boxfill_lev1_lev2.png" - -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) - +import os, sys, cdms2, vcs, testing.regression as regression + +x = regression.init() +f = cdms2.open(vcs.sample_data+"/clt.nc") +s = f("clt",slice(0,1),squeeze=1) +b = x.createboxfill() +b.level_1 = .5 +b.level_2 = 14.5 +x.plot(s, b, bg=1) +regression.run(x, "test_boxfill_lev1_lev2.png") diff --git a/testing/vcs/test_vcs_boxfill_lev1_lev2_ext1.py b/testing/vcs/test_vcs_boxfill_lev1_lev2_ext1.py index 5949492380..67f87029e9 100644 --- a/testing/vcs/test_vcs_boxfill_lev1_lev2_ext1.py +++ b/testing/vcs/test_vcs_boxfill_lev1_lev2_ext1.py @@ -1,26 +1,11 @@ - -import cdms2,sys,vcs,sys,os -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -f=cdms2.open(vcs.sample_data+"/clt.nc") -s=f("clt",slice(0,1),squeeze=1) -b=x.createboxfill() -b.level_1=20 -b.level_2=80 -b.ext_1="y" -x.plot(s,b,bg=1) - -fnm= "test_boxfill_lev1_lev2_ext1.png" - -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) - +import os, sys, cdms2, vcs, testing.regression as regression + +x = regression.init() +f = cdms2.open(vcs.sample_data+"/clt.nc") +s = f("clt",slice(0,1),squeeze=1) +b = x.createboxfill() +b.level_1 = 20 +b.level_2 = 80 +b.ext_1 = "y" +x.plot(s, b, bg=1) +regression.run(x, "test_boxfill_lev1_lev2_ext1.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_boxfill_lev1_lev2_ext1_ext2.py b/testing/vcs/test_vcs_boxfill_lev1_lev2_ext1_ext2.py index 9e355d1e18..dc7958c596 100644 --- a/testing/vcs/test_vcs_boxfill_lev1_lev2_ext1_ext2.py +++ b/testing/vcs/test_vcs_boxfill_lev1_lev2_ext1_ext2.py @@ -1,27 +1,12 @@ - -import cdms2,sys,vcs,sys,os -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -f=cdms2.open(vcs.sample_data+"/clt.nc") -s=f("clt",slice(0,1),squeeze=1) -b=x.createboxfill() -b.level_1=20 -b.level_2=80 -b.ext_1="y" -b.ext_2="y" -x.plot(s,b,bg=1) - -fnm= "test_boxfill_lev1_lev2_ext1_ext2.png" - -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) - +import os, sys, cdms2, vcs, testing.regression as regression + +x = regression.init() +f = cdms2.open(vcs.sample_data+"/clt.nc") +s = f("clt", slice(0,1), squeeze=1) +b = x.createboxfill() +b.level_1 = 20 +b.level_2 = 80 +b.ext_1 = "y" +b.ext_2 = "y" +x.plot(s, b, bg=1) +regression.run(x, "test_boxfill_lev1_lev2_ext1_ext2.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_boxfill_lev1_lev2_ext2.py b/testing/vcs/test_vcs_boxfill_lev1_lev2_ext2.py index 375c93d8aa..398325eab8 100644 --- a/testing/vcs/test_vcs_boxfill_lev1_lev2_ext2.py +++ b/testing/vcs/test_vcs_boxfill_lev1_lev2_ext2.py @@ -1,26 +1,11 @@ - -import cdms2,sys,vcs,sys,os -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -f=cdms2.open(vcs.sample_data+"/clt.nc") -s=f("clt",slice(0,1),squeeze=1) -b=x.createboxfill() -b.level_1=20 -b.level_2=80 -b.ext_2="y" -x.plot(s,b,bg=1) - -fnm= "test_boxfill_lev1_lev2_ext2.png" - -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) - +import os, sys, cdms2, vcs, testing.regression as regression + +x = regression.init() +f = cdms2.open(vcs.sample_data+"/clt.nc") +s = f("clt",slice(0,1),squeeze=1) +b = x.createboxfill() +b.level_1 = 20 +b.level_2 = 80 +b.ext_2 = "y" +x.plot(s, b, bg=1) +regression.run(x, "test_boxfill_lev1_lev2_ext2.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_boxfill_lev1_lev2_ta_missing.py b/testing/vcs/test_vcs_boxfill_lev1_lev2_ta_missing.py index 984179e5ce..d2a39a1ba2 100644 --- a/testing/vcs/test_vcs_boxfill_lev1_lev2_ta_missing.py +++ b/testing/vcs/test_vcs_boxfill_lev1_lev2_ta_missing.py @@ -1,28 +1,11 @@ - -import cdms2,sys,vcs,sys,os -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") -f=cdms2.open(vcs.sample_data+"/ta_ncep_87-6-88-4.nc") -s=f("ta",slice(0,1),longitude=slice(34,35),squeeze=1)-273.15 -s=cdms2.MV2.masked_less(s,-45.) -b=x.createboxfill() -b.level_1=-40 -b.level_2=40 -x.plot(s,b,bg=1) - -fnm= "test_boxfill_lev1_lev2_ta_missing.png" - -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) -raw_input() - +import os, sys, cdms2, vcs, testing.regression as regression + +x = regression.init() +f = cdms2.open(vcs.sample_data+"/ta_ncep_87-6-88-4.nc") +s = f("ta",slice(0,1),longitude=slice(34,35),squeeze=1)-273.15 +s = cdms2.MV2.masked_less(s,-45.) +b = x.createboxfill() +b.level_1 = -40 +b.level_2 = 40 +x.plot(s, b, bg=1) +regression.run(x, "test_boxfill_lev1_lev2_ta_missing.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_boxfill_polar.py b/testing/vcs/test_vcs_boxfill_polar.py index e4f534c9dc..869d09802c 100644 --- a/testing/vcs/test_vcs_boxfill_polar.py +++ b/testing/vcs/test_vcs_boxfill_polar.py @@ -1,33 +1,16 @@ -#!/usr/bin/env python -import cdms2 -import os -import sys -import vcs +import os, sys, cdms2, vcs, testing.regression as regression -pth = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(pth) -import checkimage f = cdms2.open(vcs.sample_data + "/clt.nc") -a=f("clt") +a = f("clt") -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200, 900, units="pixels") - -p=x.getprojection("polar") -b=x.createboxfill() -b.projection=p -#b.datawc_y1 = 90 -#b.datawc_y2 = -90 - -x.setbgoutputdimensions(1200,1091,units="pixels") +x = regression.init() +p = x.getprojection("polar") +b = x.createboxfill() +b.projection = p x.plot(a(latitude=(90,-90)), b, bg=1) fileName = os.path.basename(__file__) fileName = os.path.splitext(fileName)[0] fileName += '.png' -x.png(fileName) -ret = checkimage.check_result_image(fileName, sys.argv[1], checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, fileName) \ No newline at end of file diff --git a/testing/vcs/test_vcs_boxfill_robinson_wrap.py b/testing/vcs/test_vcs_boxfill_robinson_wrap.py index 81b3206bdf..de66e516cc 100644 --- a/testing/vcs/test_vcs_boxfill_robinson_wrap.py +++ b/testing/vcs/test_vcs_boxfill_robinson_wrap.py @@ -1,15 +1,7 @@ -#!/usr/bin/env python -import cdms2, cdutil, genutil -import vcs,os -import sys +import os, sys, cdms2, cdutil, genutil, vcs, testing.regression as regression # This tests if extending the longitude to more than 360 decrees is handled correctly by # proj4. See https://github.com/UV-CDAT/uvcdat/issues/1728 for more information. -pth = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(pth) -import checkimage - - cdmsfile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) clt2 = cdmsfile('clt') clt3 = clt2(latitude=(-90.0, 90.0),squeeze=1,longitude=(-180, 200.0),time=('1979-01', '1988-12'),) @@ -19,7 +11,4 @@ kwargs[ 'cdmsfile' ] = cdmsfile.id kwargs['bg'] = 1 canvas.plot(clt3, gmBoxfill, **kwargs) -fnm = "test_robinson_wrap.png" -canvas.png(fnm) -ret = checkimage.check_result_image(fnm, sys.argv[1], checkimage.defaultThreshold) -sys.exit(ret) +regression.run(canvas, "test_robinson_wrap.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_canvas_background.py b/testing/vcs/test_vcs_canvas_background.py index 1d39b330d2..2c72b51f3d 100644 --- a/testing/vcs/test_vcs_canvas_background.py +++ b/testing/vcs/test_vcs_canvas_background.py @@ -1,19 +1,6 @@ -import vcs, cdms2, os, sys - -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage - -x = vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(500,500,units="pixels") +import os, sys, cdms2, vcs, testing.regression as regression +x = regression.init() x.backgroundcolor = (255, 255, 255) x.open() -fnm = "test_backgroundcolor_white.png" -x.png(fnm) - -src=sys.argv[1] -ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, "test_backgroundcolor_white.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_canvas_background_update.py b/testing/vcs/test_vcs_canvas_background_update.py index 454f0ef099..a28c087137 100644 --- a/testing/vcs/test_vcs_canvas_background_update.py +++ b/testing/vcs/test_vcs_canvas_background_update.py @@ -1,22 +1,8 @@ -import vcs, cdms2, os, sys - -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage - -x = vcs.init() - -x.drawlogooff() -x.setbgoutputdimensions(500,500, units="pixels") +import os, sys, cdms2, vcs, testing.regression as regression +x = regression.init() x.backgroundcolor = (255, 255, 255) x.open() x.backgroundcolor = (255, 255, 0) x.update() -fnm = "test_backgroundcolor_yellow.png" -x.png(fnm) - -src=sys.argv[1] -ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold) - -sys.exit(ret) +regression.run(x, "test_backgroundcolor_yellow.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_click_info.py b/testing/vcs/test_vcs_click_info.py index 0fe587792b..c16a6c0d4c 100644 --- a/testing/vcs/test_vcs_click_info.py +++ b/testing/vcs/test_vcs_click_info.py @@ -1,7 +1,4 @@ -import cdms2 -import sys -import vcs -import os +import os, sys, cdms2, vcs, testing.regression as regression testConfig = {'a_boxfill': ('clt.nc', 'clt', (200, 200)), 'a_mollweide_boxfill': ('clt.nc', 'clt', (222, 322)), @@ -11,15 +8,7 @@ # Tests if the info produced when clicking on a map is correct. src = sys.argv[1] plot = sys.argv[2] -pth = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(pth) -import checkimage -x = vcs.init() -x.setantialiasing(0) -x.drawlogooff() -# Needs to set the size of window so it is consistent accross -# test platforms -x.open(814, 606) +x = regression.init() # data f = cdms2.open(vcs.sample_data + "/" + testConfig[plot][0]) @@ -47,7 +36,4 @@ fileName = os.path.splitext(fileName)[0] fileName += '.png' -x.png(fileName, width=814, height= 606) - -ret = checkimage.check_result_image(fileName, src, checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, fileName) \ No newline at end of file diff --git a/testing/vcs/test_vcs_close.py b/testing/vcs/test_vcs_close.py index 7bf0072249..3457a648ea 100644 --- a/testing/vcs/test_vcs_close.py +++ b/testing/vcs/test_vcs_close.py @@ -1,7 +1,5 @@ import os, sys, vcs, cdms2 -#import checkimage -#src=sys.argv[1] pth = os.path.join(os.path.dirname(__file__),"..") sys.path.append(pth) cdmsfile = cdms2.open(vcs.sample_data+"/clt.nc") @@ -9,8 +7,4 @@ x = vcs.init() x.plot(data, bg=1) x.close() -#x.plot(data[4][1:89], bg=1) -#fnm = "test_vcs_close.png" -#x.png(fnm) -#ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold) sys.exit(0) diff --git a/testing/vcs/test_vcs_colormaps_source.py b/testing/vcs/test_vcs_colormaps_source.py index 1dcc7d8807..2cfc027217 100644 --- a/testing/vcs/test_vcs_colormaps_source.py +++ b/testing/vcs/test_vcs_colormaps_source.py @@ -1,27 +1,12 @@ -import vcs -import argparse -import cdms2 -import os -import sys - - -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import argparse, os, sys, cdms2, vcs, testing.regression as regression parser = argparse.ArgumentParser() - parser.add_argument("-g",dest="gm",default="boxfill",choices = ["boxfill","isofill","meshfill","isoline","vector","1d"]) parser.add_argument("-s",dest="src",default="vcs",choices=["vcs","canvas","gm"]) parser.add_argument("-b",dest="baseline") - - args = parser.parse_args() -x=vcs.init() -x.setantialiasing(0) -x.setbgoutputdimensions(1200, 1091, units="pixels") -x.drawlogooff() +x = regression.init() exec("gm = x.create%s()" % args.gm) @@ -55,7 +40,4 @@ fnm = "test_vcs_colormaps_source_%s_%s.png" % (args.gm,args.src) x.png(fnm) baselineImage = args.baseline -ret = checkimage.check_result_image(fnm, baselineImage, - checkimage.defaultThreshold) - -sys.exit(ret) +ret = regression.run(x, fnm, baselineImage) \ No newline at end of file diff --git a/testing/vcs/test_vcs_colorpicker_appearance.py b/testing/vcs/test_vcs_colorpicker_appearance.py index c925340711..4ccba61fd2 100644 --- a/testing/vcs/test_vcs_colorpicker_appearance.py +++ b/testing/vcs/test_vcs_colorpicker_appearance.py @@ -1,7 +1,6 @@ import vcs, vtk picker = vcs.colorpicker.ColorPicker(500, 250, None, 0) - win = picker.render_window win.Render() @@ -16,8 +15,6 @@ import sys, os if len(sys.argv) > 1: - src = sys.argv[1] - sys.path.append(os.path.join(os.path.dirname(__file__), "..")) - import checkimage - ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold) + import testing.regression as regression + ret = regression.check_result_image(fnm, sys.argv[1]) sys.exit(ret) diff --git a/testing/vcs/test_vcs_configurator_resize.py b/testing/vcs/test_vcs_configurator_resize.py index b6179626d4..7692e6218c 100644 --- a/testing/vcs/test_vcs_configurator_resize.py +++ b/testing/vcs/test_vcs_configurator_resize.py @@ -20,9 +20,7 @@ import sys, os if len(sys.argv) > 1: - pth = os.path.join(os.path.dirname(__file__), "..") - sys.path.append(pth) - import checkimage + import testing.regression as regression src = sys.argv[1] - ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold) - sys.exit(ret) + ret = regression.check_result_image(fnm, src) + sys.exit(ret) \ No newline at end of file diff --git a/testing/vcs/test_vcs_continents.py b/testing/vcs/test_vcs_continents.py index 9ae3d62de2..c102df9de4 100644 --- a/testing/vcs/test_vcs_continents.py +++ b/testing/vcs/test_vcs_continents.py @@ -1,22 +1,14 @@ -import cdms2 -import os -import sys -import vcs -import EzTemplate +import os, sys, EzTemplate, cdms2, vcs, testing.regression as regression # Load the clt data: dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) clt = dataFile("clt", time="1979-1-1", squeeze=1) - # Zero out the array so we can see the continents clearly clt[:] = 0 # Initialize canvas: -canvas = vcs.init() -canvas.setantialiasing(0) -canvas.setbgoutputdimensions(1200, 1091, units="pixels") -canvas.drawlogooff() +canvas = regression.init() # Create and plot quick boxfill with default settings: boxfill = canvas.createboxfill() @@ -64,15 +56,4 @@ canvas.plot(clt, template, boxfill, continents=7, continents_line=cont_line, bg=1) os.environ["UVCDAT_DIR"] = current_dotdir -# Load the image testing module: -testingDir = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(testingDir) -import checkimage - -# Create the test image and compare: -baseline = sys.argv[1] -testFile = "test_continents.png" -canvas.png(testFile) -ret = checkimage.check_result_image(testFile, baseline, - 25) -sys.exit(ret) +regression.run(canvas, "test_continents.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_create_get.py b/testing/vcs/test_vcs_create_get.py index ec525d1b4d..adb879d640 100644 --- a/testing/vcs/test_vcs_create_get.py +++ b/testing/vcs/test_vcs_create_get.py @@ -1,4 +1,3 @@ - import vcs x=vcs.init() x.drawlogooff() diff --git a/testing/vcs/test_vcs_draw_logo_on.py b/testing/vcs/test_vcs_draw_logo_on.py index 65271eb151..4a0c28d2cd 100644 --- a/testing/vcs/test_vcs_draw_logo_on.py +++ b/testing/vcs/test_vcs_draw_logo_on.py @@ -1,19 +1,9 @@ -import vcs,numpy,cdms2,MV2,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression -x=vcs.init() -x.setantialiasing(0) -x.setbgoutputdimensions(1200,1091,units="pixels") +x = vcs.init() a=numpy.arange(100) a.shape=(10,10) x.plot(a,bg=1) fnm = "test_vcs_draw_logo_on.png" x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.check_result_image(fnm, sys.argv[1]) diff --git a/testing/vcs/test_vcs_fillarea_transparency.py b/testing/vcs/test_vcs_fillarea_transparency.py index dc3a8bf4bd..831b3e029f 100644 --- a/testing/vcs/test_vcs_fillarea_transparency.py +++ b/testing/vcs/test_vcs_fillarea_transparency.py @@ -1,13 +1,6 @@ -import vcs -import sys,os -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import vcs, sys, os, testing.regression as regression -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1090,units="pixels") +x = regression.init() fa1 = x.createfillarea() @@ -29,8 +22,4 @@ x.plot(fa2,bg=True) fnm = os.path.split(__file__[:-2]+"png")[-1] -x.png(fnm) -src = sys.argv[1] - -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, fnm) \ No newline at end of file diff --git a/testing/vcs/test_vcs_first_png_blank.py b/testing/vcs/test_vcs_first_png_blank.py index d11c59e6d5..1e0bd8e280 100644 --- a/testing/vcs/test_vcs_first_png_blank.py +++ b/testing/vcs/test_vcs_first_png_blank.py @@ -1,20 +1,7 @@ +import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression -import vcs,numpy,cdms2,MV2,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) T=f('clt') -v = vcs.init() -v.setantialiasing(0) -v.setbgoutputdimensions(1200,1091,units="pixels") +v = regression.init() v.plot(T,bg=1) -# This will write a blank plot to a file: -fnm = "first_png_blank.png" -v.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(v, 'first_png_blank.png') \ No newline at end of file diff --git a/testing/vcs/test_vcs_flipNone.py b/testing/vcs/test_vcs_flipNone.py index a76e271f1f..79b69ffddb 100644 --- a/testing/vcs/test_vcs_flipNone.py +++ b/testing/vcs/test_vcs_flipNone.py @@ -1,26 +1,8 @@ +import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression -import vcs,numpy,cdms2,MV2,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() - -x.setbgoutputdimensions(1200,1091,units="pixels") - -f=cdms2.open(os.path.join(vcs.sample_data,"ta_ncep_87-6-88-4.nc")) - - +x = regression.init() +f = cdms2.open(os.path.join(vcs.sample_data,"ta_ncep_87-6-88-4.nc")) vr = "ta" s=f(vr,slice(0,1),longitude=slice(90,91),squeeze=1,level=(0,10000)) x.plot(s,bg=1) -fnm = "test_vcs_flipNone.png" -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) - - +regression.run(x, 'test_vcs_flipNone.png') \ No newline at end of file diff --git a/testing/vcs/test_vcs_flipX.py b/testing/vcs/test_vcs_flipX.py index 0de7001aac..e211bf16a7 100644 --- a/testing/vcs/test_vcs_flipX.py +++ b/testing/vcs/test_vcs_flipX.py @@ -1,26 +1,8 @@ +import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression -import vcs,numpy,cdms2,MV2,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() - -x.setbgoutputdimensions(1200,1091,units="pixels") - -f=cdms2.open(os.path.join(vcs.sample_data,"ta_ncep_87-6-88-4.nc")) - - +x = regression.init() +f = cdms2.open(os.path.join(vcs.sample_data,"ta_ncep_87-6-88-4.nc")) vr = "ta" s=f(vr,slice(0,1),longitude=slice(90,91),squeeze=1,latitude=(90,-90),level=(0,10000)) x.plot(s,bg=1) -fnm = "test_vcs_flipX.png" -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) - - +regression.run(x, 'test_vcs_flipX.png') \ No newline at end of file diff --git a/testing/vcs/test_vcs_flipXY.py b/testing/vcs/test_vcs_flipXY.py index 8dd0f8d893..779a0fe7e5 100644 --- a/testing/vcs/test_vcs_flipXY.py +++ b/testing/vcs/test_vcs_flipXY.py @@ -1,26 +1,9 @@ +import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression -import vcs,numpy,cdms2,MV2,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() - -x.setbgoutputdimensions(1200,1091,units="pixels") - -f=cdms2.open(os.path.join(vcs.sample_data,"ta_ncep_87-6-88-4.nc")) - +x = regression.init() +f = cdms2.open(os.path.join(vcs.sample_data,"ta_ncep_87-6-88-4.nc")) vr = "ta" s=f(vr,slice(0,1),longitude=slice(90,91),squeeze=1,latitude=(90,-90)) x.plot(s,bg=1) -fnm = "test_vcs_flipXY.png" -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) - - +regression.run(x, 'test_vcs_flipXY.png') \ No newline at end of file diff --git a/testing/vcs/test_vcs_flipY.py b/testing/vcs/test_vcs_flipY.py index 7194f3f306..5efa577451 100644 --- a/testing/vcs/test_vcs_flipY.py +++ b/testing/vcs/test_vcs_flipY.py @@ -1,26 +1,8 @@ +import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression -import vcs,numpy,cdms2,MV2,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() - -x.setbgoutputdimensions(1200,1091,units="pixels") - +x = regression.init() f=cdms2.open(os.path.join(vcs.sample_data,"ta_ncep_87-6-88-4.nc")) - - vr = "ta" s=f(vr,slice(0,1),longitude=slice(90,91),squeeze=1) x.plot(s,bg=1) -fnm = "test_vcs_flipY.png" -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) - - +regression.run(x, 'test_vcs_flipY.png') \ No newline at end of file diff --git a/testing/vcs/test_vcs_gen_meshfill.py b/testing/vcs/test_vcs_gen_meshfill.py index b726a20a69..e599405546 100644 --- a/testing/vcs/test_vcs_gen_meshfill.py +++ b/testing/vcs/test_vcs_gen_meshfill.py @@ -1,39 +1,16 @@ +import os, sys, numpy, vcs, testing.regression as regression -import vcs,numpy,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage - -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") - +x = regression.init() data = numpy.array([1,2,3,4]) - blon = numpy.array([-1,1,1,0,-1]) blat = numpy.array([0,0,1,2,1]) - acell=numpy.array([blat,blon]) bcell = numpy.array([blat,blon+2.5]) ccell = numpy.array([blat+2.5,blon+2.5]) dcell = numpy.array([blat+2.5,blon]) - mesh = numpy.array([acell,bcell,ccell,dcell]) - m=x.createmeshfill() x.plot(data,mesh,m,bg=1) - - -fnm = "test_vcs_gen_meshfill.png" -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) - - +regression.run(x, "test_vcs_gen_meshfill.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_gms_animate_projected_plots.py b/testing/vcs/test_vcs_gms_animate_projected_plots.py index 2e521cd4ad..3de234e418 100644 --- a/testing/vcs/test_vcs_gms_animate_projected_plots.py +++ b/testing/vcs/test_vcs_gms_animate_projected_plots.py @@ -1,15 +1,5 @@ # Test animation of projected plots - -import argparse -import cdms2 -import MV2 -import os -import sys -import vcs - -pth = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(pth) -import checkimage # noqa +import argparse, os, sys, cdms2, MV2, vcs, testing.regression as regression p = argparse.ArgumentParser(description="Testing animation of projected plots") p.add_argument("--gm_type", dest="gm", help="gm to test") @@ -19,18 +9,13 @@ p.add_argument("--keep", dest="keep", action="store_true", default=False, help="Save images, even if baseline matches.") p.add_argument("--threshold", dest="threshold", type=int, - default=checkimage.defaultThreshold, + default=regression.defaultThreshold, help="Threshold value for image differnces") args = p.parse_args(sys.argv[1:]) gm_type = args.gm - -x = vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200, 1091, units="pixels") - +x = regression.init() s = None if gm_type == "meshfill": @@ -72,7 +57,7 @@ ret = 0 pdir = os.path.split(pngs[0])[0] p = pdir + os.sep + "anim_0.png" -ret = checkimage.check_result_image(p, args.src, args.threshold) +ret = regression.check_result_image(p, args.src, args.threshold) if ret == 0 and not args.keep: for f in pngs: if os.path.isfile(f): diff --git a/testing/vcs/test_vcs_gms_patterns_hatches.py b/testing/vcs/test_vcs_gms_patterns_hatches.py index 4030429a0d..a7681a4205 100644 --- a/testing/vcs/test_vcs_gms_patterns_hatches.py +++ b/testing/vcs/test_vcs_gms_patterns_hatches.py @@ -1,14 +1,4 @@ -# Test the use of patterns/hatches for plots - -import argparse -import cdms2 -import os -import sys -import vcs - -pth = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(pth) -import checkimage # noqa +import argparse, os, sys, cdms2, vcs, testing.regression as regression p = argparse.ArgumentParser(description="Patterns/hatches testing code for vcs gms") p.add_argument("--source", dest="src", help="source image file") @@ -22,7 +12,7 @@ p.add_argument("--lon1", dest="lon1", default=-180, type=float, help="First Longitude") p.add_argument("--lon2", dest="lon2", default=180, type=float, help="Last Longitude") p.add_argument("--keep", dest="keep", action="store_true", help="Save image, even if baseline matches.") -p.add_argument("--threshold", dest="threshold", type=int, default=checkimage.defaultThreshold, +p.add_argument("--threshold", dest="threshold", type=int, default=regression.defaultThreshold, help="Default threshold") p.add_argument("--non-contiguous", dest="contig", default=True, action="store_false", help="use non contiguous levels") @@ -98,7 +88,7 @@ x.png(fnm) print "fnm:", fnm print "src:", src -ret = checkimage.check_result_image(fnm+'.png', src, +ret = regression.check_result_image(fnm+'.png', src, args.threshold, cleanup=not args.keep) if args.show: diff --git a/testing/vcs/test_vcs_hatches_patterns.py b/testing/vcs/test_vcs_hatches_patterns.py index 8cd1766f0d..8a467259c8 100644 --- a/testing/vcs/test_vcs_hatches_patterns.py +++ b/testing/vcs/test_vcs_hatches_patterns.py @@ -1,17 +1,6 @@ -import os -import sys -import vcs +import os, sys, vcs, testing.regression as regression -pth = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(pth) -import checkimage - -baselineImage = sys.argv[1] - -# Initialize the graphics canvas -x = vcs.init() -x.setantialiasing(0) -x.setbgoutputdimensions(1200, 1091, units="pixels") +x = regression.init() # Create a test plot for listing all the hatches and patterns style_list = [] @@ -77,11 +66,4 @@ x.plot(plot_title, bg=1) x.plot(fill_test, bg=1) x.plot(fill_info, bg=1) - -testImage = os.path.abspath("test_vcs_hatches_patterns.png") -x.png(testImage) - -ret = checkimage.check_result_image(testImage, baselineImage, - checkimage.defaultThreshold) - -sys.exit(ret) +regression.run(x, "test_vcs_hatches_patterns.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_import.py b/testing/vcs/test_vcs_import.py index c122421251..01c3d0447c 100644 --- a/testing/vcs/test_vcs_import.py +++ b/testing/vcs/test_vcs_import.py @@ -1,3 +1,2 @@ - import vcs diff --git a/testing/vcs/test_vcs_infinity.py b/testing/vcs/test_vcs_infinity.py index 235f551ebd..daf4060168 100644 --- a/testing/vcs/test_vcs_infinity.py +++ b/testing/vcs/test_vcs_infinity.py @@ -1,28 +1,16 @@ - -import vcs,numpy,cdms2,MV2,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -import numpy +import os, sys, numpy, MV2, cdms2, testing.regression as regression s= numpy.sin(numpy.arange(100)) -s=numpy.reshape(s,(10,10)) +s = numpy.reshape(s,(10,10)) s[4,6] = numpy.inf s[7,9] = numpy.NINF s[9,2] = numpy.nan -x=vcs.init() +x = regression.init() x.setantialiasing(0) x.drawlogooff() x.setbgoutputdimensions(1200,1091,units="pixels") x.plot(s,bg=1) fnm = "infinity.png" -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) - +regression.run(x, fnm) \ No newline at end of file diff --git a/testing/vcs/test_vcs_iso_celine_part1.py b/testing/vcs/test_vcs_iso_celine_part1.py index 586918d36a..a8fcc5ae72 100644 --- a/testing/vcs/test_vcs_iso_celine_part1.py +++ b/testing/vcs/test_vcs_iso_celine_part1.py @@ -1,22 +1,13 @@ +import os,sys, MV2, numpy, vcs, cdms2, testing.regression as regression -import vcs,numpy,cdms2,MV2,os,sys src=sys.argv[1] pth0 = os.path.dirname(__file__) -pth = os.path.join(pth0,"..") -sys.path.append(pth) -import checkimage -f=cdms2.open(os.path.join(pth0,"celine.nc")) -s=f("data") -x=vcs.init() +f = cdms2.open(os.path.join(pth0,"celine.nc")) +s = f("data") +x = regression.init() x.setantialiasing(0) -x.drawlogooff() x.scriptrun(os.path.join(pth0,"celine.json")) -i=x.getisofill("celine") +i = x.getisofill("celine") x.plot(s,i,bg=1) fnm = "test_celine_iso.png" -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, fnm) \ No newline at end of file diff --git a/testing/vcs/test_vcs_iso_celine_part2.py b/testing/vcs/test_vcs_iso_celine_part2.py index f99f821da9..c1c1df5b1c 100644 --- a/testing/vcs/test_vcs_iso_celine_part2.py +++ b/testing/vcs/test_vcs_iso_celine_part2.py @@ -1,26 +1,15 @@ +import os, sys, MV2, numpy, vcs, cdms2, testing.regression as regression -import vcs,numpy,cdms2,MV2,os,sys -src=sys.argv[1] pth0 = os.path.dirname(__file__) -pth = os.path.join(pth0,"..") -sys.path.append(pth) -import checkimage -f=cdms2.open(os.path.join(pth0,"celine.nc")) -s=f("data") -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() +f = cdms2.open(os.path.join(pth0,"celine.nc")) +s = f("data") +x = regression.init() x.scriptrun(os.path.join(pth0,"celine.json")) -i=x.getisofill("celine") -b=vcs.createboxfill() +i = x.getisofill("celine") +b = vcs.createboxfill() b.levels=i.levels b.fillareacolors=i.fillareacolors b.boxfill_type="custom" x.plot(s,b,bg=1) fnm = "test_celine_iso_2.png" -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, fnm) \ No newline at end of file diff --git a/testing/vcs/test_vcs_isofill_data_read_north_to_south.py b/testing/vcs/test_vcs_isofill_data_read_north_to_south.py index 5f12f65b0b..8d1cc949c1 100644 --- a/testing/vcs/test_vcs_isofill_data_read_north_to_south.py +++ b/testing/vcs/test_vcs_isofill_data_read_north_to_south.py @@ -1,24 +1,10 @@ -import cdms2 -import vcs -import sys -import os -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import os, sys, cdms2, vcs, testing.regression as regression + f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) clt = f("clt",latitude=(80.0, 38.0),squeeze=1,longitude=(-180.0, 180.0),time=slice(0,1)) -x = vcs.init() -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") -x.setantialiasing(0) +x = regression.init() gm = vcs.createisofill() gm.projection="polar" x.plot( clt,gm,bg=1) fnm = os.path.split(__file__)[-1][:-2]+"png" -src= sys.argv[1] -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, fnm) \ No newline at end of file diff --git a/testing/vcs/test_vcs_isofill_isoline_labels.py b/testing/vcs/test_vcs_isofill_isoline_labels.py index d230fc8fc4..192ffc4bf9 100644 --- a/testing/vcs/test_vcs_isofill_isoline_labels.py +++ b/testing/vcs/test_vcs_isofill_isoline_labels.py @@ -1,24 +1,10 @@ -import vcs,cdms2,sys,os - -baselineImage = sys.argv[1] - -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import os, sys, cdms2, vcs, testing.regression as regression dataset = cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) data = dataset("clt") - -canvas = vcs.init() -canvas.setantialiasing(0) -canvas.setbgoutputdimensions(1200, 1091, units="pixels") -canvas.drawlogooff() - +canvas = regression.init() isofill = canvas.createisofill() - -# First plot the isofill canvas.plot(data, isofill, bg=1) - isoline = canvas.createisoline() isoline.label="y" texts=[] @@ -35,13 +21,6 @@ isoline.text = texts isoline.linecolors = colors -# Next plot the isolines with labels +# Plot the isolines with labels canvas.plot(data, isoline, bg=1) - -testImage = os.path.abspath("test_isofill_isoline_labels.png") -canvas.png(testImage) - -ret = checkimage.check_result_image(testImage, baselineImage, - checkimage.defaultThreshold) - -sys.exit(ret) +regression.run(canvas, "test_isofill_isoline_labels.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_isofill_mask_cell_shift.py b/testing/vcs/test_vcs_isofill_mask_cell_shift.py index 9bc8671131..199b1586d4 100644 --- a/testing/vcs/test_vcs_isofill_mask_cell_shift.py +++ b/testing/vcs/test_vcs_isofill_mask_cell_shift.py @@ -1,25 +1,8 @@ -import os,sys -import MV2 -import vcs -import cdms2 -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() - -x.setbgoutputdimensions(1200,1091,units="pixels") - -f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) -s=f("clt",slice(0,1),latitude=(30,70),longitude=(-130,-60)) -s2=MV2.masked_greater(s,65.) +import os, sys, MV2, cdms2, vcs, testing.regression as regression +x = regression.init() +f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) +s = f("clt",slice(0,1),latitude=(30, 70),longitude=(-130, -60)) +s2 = MV2.masked_greater(s, 65.) x.plot(s2,"default","isofill",bg=1) -fnm = "test_vcs_isofill_mask_cell_shift.png" -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, "test_vcs_isofill_mask_cell_shift.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_isoline_labels.py b/testing/vcs/test_vcs_isoline_labels.py index 77033f2c82..4602354316 100644 --- a/testing/vcs/test_vcs_isoline_labels.py +++ b/testing/vcs/test_vcs_isoline_labels.py @@ -1,20 +1,8 @@ -import vcs,cdms2,sys,os - -# ('/path/to/filename', '.extension') -baseline = os.path.splitext(sys.argv[1]) - -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import os, sys, cdms2, vcs, testing.regression as regression dataset = cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) data = dataset("clt") - -canvas = vcs.init() -canvas.setantialiasing(0) -canvas.setbgoutputdimensions(1200, 1091, units="pixels") -canvas.drawlogooff() - +canvas = regression.init() isoline = canvas.createisoline() isoline.label="y" texts=[] @@ -33,24 +21,17 @@ # First test using isoline.text[...].color canvas.plot(data, isoline, bg=1) +baseline = os.path.splitext(sys.argv[1]) baselineImage = "%s%s"%baseline -testImage = os.path.abspath("test_isoline_labels.png") -canvas.png(testImage) - -ret = checkimage.check_result_image(testImage, baselineImage, - checkimage.defaultThreshold) +ret = regression.run_wo_terminate(canvas, "test_isoline_labels.png", baselineImage) # Now set isoline.linecolors and test again. canvas.clear() isoline.linecolors = colors canvas.plot(data, isoline, bg=1) - baselineImage = "%s%d%s"%(baseline[0], 2, baseline[1]) testImage = os.path.abspath("test_isoline_labels2.png") -canvas.png(testImage) - -ret += checkimage.check_result_image(testImage, baselineImage, - checkimage.defaultThreshold) +ret += regression.run_wo_terminate(canvas, testImage, baselineImage) # Now set isoline.textcolors and test again. canvas.clear() @@ -59,9 +40,6 @@ baselineImage = "%s%d%s"%(baseline[0], 3, baseline[1]) testImage = os.path.abspath("test_isoline_labels3.png") -canvas.png(testImage) - -ret += checkimage.check_result_image(testImage, baselineImage, - checkimage.defaultThreshold) +ret += regression.run_wo_terminate(canvas, testImage, baselineImage) sys.exit(ret) diff --git a/testing/vcs/test_vcs_isoline_labels_background.py b/testing/vcs/test_vcs_isoline_labels_background.py index da1d1e6ac9..08088836ad 100644 --- a/testing/vcs/test_vcs_isoline_labels_background.py +++ b/testing/vcs/test_vcs_isoline_labels_background.py @@ -1,26 +1,13 @@ -import cdms2 -import os -import sys -import vcs +import os, sys, cdms2, vcs, testing.regression as regression import random -# ('/path/to/filename', '.extension') -baseline = os.path.splitext(sys.argv[1]) - -pth = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(pth) -import checkimage - (latmin, latmax, lonmin, lonmax) = (-90, 90, -180, 180) dataset = cdms2.open(os.path.join(vcs.sample_data, "tas_cru_1979.nc")) data = dataset("tas", time=slice(0, 1), latitude=(latmin, latmax), longitude=(lonmin, lonmax, 'co'), squeeze=1) dataset.close() -canvas = vcs.init() -canvas.setantialiasing(0) -canvas.setbgoutputdimensions(1200, 1091, units="pixels") -canvas.drawlogooff() +canvas = regression.init() canvas.backgroundcolor = [100, 105, 105] isoline = canvas.createisoline() @@ -50,11 +37,6 @@ # First test using isoline.text[...].color canvas.plot(data, isoline, bg=1) - +baseline = os.path.splitext(sys.argv[1]) baselineImage = "%s%s" % baseline -testImage = os.path.abspath("test_isoline_labels_background.png") -canvas.png(testImage) - -ret = checkimage.check_result_image(testImage, baselineImage, - checkimage.defaultThreshold) -sys.exit(ret) +regression.run(canvas, baselineImage) \ No newline at end of file diff --git a/testing/vcs/test_vcs_isoline_labels_multi_label_input_types.py b/testing/vcs/test_vcs_isoline_labels_multi_label_input_types.py index da5e5d3c37..8c6e13a7e9 100644 --- a/testing/vcs/test_vcs_isoline_labels_multi_label_input_types.py +++ b/testing/vcs/test_vcs_isoline_labels_multi_label_input_types.py @@ -1,30 +1,18 @@ -import vcs -import cdms2 -import os,sys -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) -s=f("clt") -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") -iso=x.createisoline() -t=x.createtext() -t.color=243 -t.height=25 -to=x.createtextorientation() -to.height = 55 -tt=x.createtexttable() -tt.color=245 -iso.textcolors=[None,None,None,242,244] -iso.text=[t,tt,to] -iso.label="y" -x.plot(s,iso,bg=1) -x.png("test_vcs_isoline_labels_multi_label_input_types.png") - -src=sys.argv[1] +import os, sys, cdms2, vcs, testing.regression as regression -ret = checkimage.check_result_image('test_vcs_isoline_labels_multi_label_input_types.png',src,checkimage.defaultThreshold) -sys.exit(ret) +f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) +s = f("clt") +x = regression.init() +iso = x.createisoline() +t = x.createtext() +t.color = 243 +t.height = 25 +to = x.createtextorientation() +to.height = 55 +tt = x.createtexttable() +tt.color = 245 +iso.textcolors = [None,None,None,242,244] +iso.text = [t,tt,to] +iso.label = "y" +x.plot(s, iso, bg=1) +regression.run(x, "test_vcs_isoline_labels_multi_label_input_types.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_isoline_labelskipdistance.py b/testing/vcs/test_vcs_isoline_labelskipdistance.py index 04ecdfabb4..4b119e0bc3 100644 --- a/testing/vcs/test_vcs_isoline_labelskipdistance.py +++ b/testing/vcs/test_vcs_isoline_labelskipdistance.py @@ -1,21 +1,8 @@ -import cdms2 -import os -import sys -import vcs - -baselineImage = sys.argv[1] - -pth = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(pth) -import checkimage +import os, sys, cdms2, vcs, testing.regression as regression dataset = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) data = dataset("clt") - -canvas = vcs.init() -canvas.setantialiasing(0) -canvas.setbgoutputdimensions(1200, 1091, units="pixels") -canvas.drawlogooff() +canvas = regression.init() isoline = canvas.createisoline() isoline.label = "y" @@ -36,11 +23,4 @@ # Next plot the isolines with labels canvas.plot(data, isoline, bg=1) - -testImage = os.path.abspath("test_isoline_labelskipdistance.png") -canvas.png(testImage) - -ret = checkimage.check_result_image(testImage, baselineImage, - checkimage.defaultThreshold) - -sys.exit(ret) +regression.run(canvas, "test_isoline_labelskipdistance.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_isoline_numpy.py b/testing/vcs/test_vcs_isoline_numpy.py index ced140e773..147f2f4996 100644 --- a/testing/vcs/test_vcs_isoline_numpy.py +++ b/testing/vcs/test_vcs_isoline_numpy.py @@ -1,21 +1,13 @@ -import vcs,cdms2,sys,os -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -x=vcs.init() +import os, sys, cdms2, vcs, testing.regression as regression + +x = regression.init() x.setantialiasing(0) x.setbgoutputdimensions(1200,1091,units="pixels") x.drawlogooff() fnm = os.path.join(vcs.sample_data,'clt.nc') -f=cdms2.open(fnm) - -s=f("clt") -gm=x.createisofill() +f = cdms2.open(fnm) +s = f("clt") +gm = x.createisofill() x.plot(s.filled(),gm,bg=1) fnm = "test_vcs_isoline_numpy.png" -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, fnm) \ No newline at end of file diff --git a/testing/vcs/test_vcs_isoline_width_stipple.py b/testing/vcs/test_vcs_isoline_width_stipple.py index b563436c26..5da8f91f48 100644 --- a/testing/vcs/test_vcs_isoline_width_stipple.py +++ b/testing/vcs/test_vcs_isoline_width_stipple.py @@ -1,22 +1,8 @@ -import cdms2 -import os -import sys -import vcs - -baselineImage = sys.argv[1] - -pth = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(pth) -import checkimage # noqa +import os, sys, cdms2, vcs, testing.regression as regression dataset = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) data = dataset("clt") - -canvas = vcs.init() -canvas.setantialiasing(0) -canvas.setbgoutputdimensions(1200, 1091, units="pixels") -canvas.drawlogooff() - +canvas = regression.init() isoline = canvas.createisoline() isoline.label = "y" texts = [] @@ -35,15 +21,8 @@ isoline.levels = levels isoline.text = texts isoline.linecolors = colors - isoline.linewidths = (1, 2, 3, 4, 1) isoline.line = ('dot', 'dash', 'solid', 'dash-dot', 'long-dash', 'dot', 'dash') - # Next plot the isolines with labels canvas.plot(data, isoline, bg=1) - -testImage = os.path.abspath("test_isoline_width_stipple.png") -canvas.png(testImage) - -ret = checkimage.check_result_image(testImage, baselineImage, 30) -sys.exit(ret) +regression.run(canvas, "test_isoline_width_stipple.png") diff --git a/testing/vcs/test_vcs_issue_960_labels.py b/testing/vcs/test_vcs_issue_960_labels.py index ee45216cdc..7da2104ff4 100644 --- a/testing/vcs/test_vcs_issue_960_labels.py +++ b/testing/vcs/test_vcs_issue_960_labels.py @@ -1,29 +1,19 @@ -import sys,os,cdms2,vcs -import vcs -src1=sys.argv[1] -src2=sys.argv[2] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") +import os, sys, cdms2, vcs, testing.regression as regression + +src1 = sys.argv[1] +src2 = sys.argv[2] +x = regression.init() f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) s=f("clt",time=slice(0,1),latitude=(-7,5),squeeze=1) x.plot(s,bg=1) fnm = "test_vcs_issue_960_labels_1.png" x.png(fnm) -print "fnm:",fnm -print "src:",src1 -ret = checkimage.check_result_image(fnm,src1,checkimage.defaultThreshold) +ret = regression.check_result_image(fnm, src1) b=x.createboxfill() b.datawc_y1=-7 b.datawc_y2=5 x.plot(s,b,bg=1) fnm = "test_vcs_issue_960_labels_2.png" x.png(fnm) -print "fnm:",fnm -print "src:",src2 -ret += checkimage.check_result_image(fnm,src2,checkimage.defaultThreshold) -sys.exit(ret) +ret += regression.check_result_image(fnm, src2) +sys.exit(ret) \ No newline at end of file diff --git a/testing/vcs/test_vcs_lambert.py b/testing/vcs/test_vcs_lambert.py index 17a50209f8..c78e71e9b5 100644 --- a/testing/vcs/test_vcs_lambert.py +++ b/testing/vcs/test_vcs_lambert.py @@ -1,27 +1,10 @@ -import vcs,cdms2 -import os,sys +import os, sys, cdms2, vcs, testing.regression as regression f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) s = f("clt") -x = vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1090,units="pixels") +x = regression.init() iso = x.createisofill() p=x.createprojection() p.type="lambert" - iso.projection = p x.plot(s(latitude=(20, 60),longitude=(-140,-20)), iso, bg=True) - -# Load the image testing module: -testingDir = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(testingDir) -import checkimage - -# Create the test image and compare: -baseline = sys.argv[1] -testFile = "test_vcs_lambert.png" -x.png(testFile) -ret = checkimage.check_result_image(testFile, baseline, - checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, "test_vcs_lambert.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_large_pattern_hatch.py b/testing/vcs/test_vcs_large_pattern_hatch.py index 3bcf0827da..782cfb14b9 100644 --- a/testing/vcs/test_vcs_large_pattern_hatch.py +++ b/testing/vcs/test_vcs_large_pattern_hatch.py @@ -1,31 +1,12 @@ -import vcs -import sys -import os - -baseline = sys.argv[1] - -pth = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(pth) -import checkimage - -canvas = vcs.init() -canvas.setantialiasing(0) -canvas.setbgoutputdimensions(1200,1090, units="pixels") -canvas.drawlogooff() +import os, sys, vcs, testing.regression as regression +canvas = regression.init() fillarea = vcs.createfillarea() fillarea.x = [[0, .33, .33, 0], [.33, .67, .67, .33], [.67, 1, 1, .67]] fillarea.y = [[0, 0, 1, 1]] * 3 fillarea.style = ["solid", "pattern", "hatch"] fillarea.index = [1, 5, 5] fillarea.color = [50, 50, 50] - canvas.plot(fillarea, bg=True) - -testImage = os.path.abspath("test_vcs_large_pattern_hatch.png") -canvas.png(testImage) - -ret = checkimage.check_result_image(testImage, baseline, - checkimage.defaultThreshold) - -sys.exit(ret) +fnm = os.path.abspath("test_vcs_large_pattern_hatch.png") +regression.run(canvas, fnm) \ No newline at end of file diff --git a/testing/vcs/test_vcs_legend.py b/testing/vcs/test_vcs_legend.py index 26beec7e5e..a352bc080a 100644 --- a/testing/vcs/test_vcs_legend.py +++ b/testing/vcs/test_vcs_legend.py @@ -1,5 +1,4 @@ -import sys,os -import argparse +import os, sys, argparse, cdms2, MV2, vcs, testing.regression as regression p = argparse.ArgumentParser(description="Basic gm testing code for vcs") p.add_argument("--source", dest="src", help="source image file") @@ -14,20 +13,10 @@ gm_type= args.gm src = args.src -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage - -import vcs -import sys -import cdms2 -import vtk -import os -import MV2 bg = not args.show -x=vcs.init() +x = vcs.init() x.setantialiasing(0) x.drawlogooff() if bg: @@ -81,7 +70,7 @@ x.png(fnm) print "fnm:",fnm print "src:",src -ret = checkimage.check_result_image(fnm+'.png',src,checkimage.defaultThreshold, cleanup=not args.keep) +ret = regression.check_result_image(fnm+'.png', src,regression.defaultThreshold, cleanup=not args.keep) if args.show: raw_input("Press Enter") sys.exit(ret) diff --git a/testing/vcs/test_vcs_lon_axes_freak_out.py b/testing/vcs/test_vcs_lon_axes_freak_out.py index ecb63f2a5d..f18328f582 100644 --- a/testing/vcs/test_vcs_lon_axes_freak_out.py +++ b/testing/vcs/test_vcs_lon_axes_freak_out.py @@ -1,30 +1,11 @@ -import os,sys,vcs,cdms2 -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import os, sys, cdms2, vcs, testing.regression as regression +f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) +s = f("clt") +s3 = f("clt",longitude=(0,360)) -f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) -s=f("clt") -s3=f("clt",longitude=(0,360)) - -print s.shape,s3.shape - - -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") - +x = regression.init() x.plot(s,bg=1) x.clear() x.plot(s3,bg=1) - -fnm = "test_lon_axes_freak_out.png" - -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, "test_lon_axes_freak_out.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_markers.py b/testing/vcs/test_vcs_markers.py index 50f4f00d1b..21b7a671bc 100644 --- a/testing/vcs/test_vcs_markers.py +++ b/testing/vcs/test_vcs_markers.py @@ -1,28 +1,14 @@ +import os, sys, numpy, cdms2, MV2, vcs, testing.regression as regression -import vcs,numpy,cdms2,MV2,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage - -x=vcs.init() -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") - +x = regression.init() m = x.createmarker() -m.x=[[0.,],[5,],[10.,],[15.]] -m.y=[[0.,],[5,],[10.,],[15.]] +m.x = [[0.,],[5,],[10.,],[15.]] +m.y = [[0.,],[5,],[10.,],[15.]] m.worldcoordinate=[-5,20,-5,20] + #m.worldcoordinate=[-10,10,0,10] m.type=['plus','diamond','square_fill',"hurricane"] m.color=[242,243,244,242] m.size=[20,20,20,5] x.plot(m,bg=1) -fnm= "test_markers.png" - -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, "test_markers.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_matplotlib_colormap.py b/testing/vcs/test_vcs_matplotlib_colormap.py index 06b9f49b9b..baf0e1bb07 100644 --- a/testing/vcs/test_vcs_matplotlib_colormap.py +++ b/testing/vcs/test_vcs_matplotlib_colormap.py @@ -1,7 +1,4 @@ -import cdms2 -import os -import sys -import vcs +import os, sys, cdms2, vcs, testing.regression as regression # Load the clt data: dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) @@ -10,24 +7,7 @@ time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0')) # Initialize canvas: -canvas = vcs.init() -canvas.setantialiasing(0) -canvas.setbgoutputdimensions(1200,1091,units="pixels") -canvas.drawlogooff() - +canvas = regression.init() canvas.setcolormap(vcs.matplotlib2vcs("viridis")) - canvas.plot(clt, bg=1) - -# Load the image testing module: -testingDir = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(testingDir) -import checkimage - -# Create the test image and compare: -baseline = sys.argv[1] -testFile = "test_matplotlib_colormap.png" -canvas.png(testFile) -ret = checkimage.check_result_image(testFile, baseline, - checkimage.defaultThreshold) -sys.exit(ret) +regression.run(canvas, "test_matplotlib_colormap.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_mercator_edge.py b/testing/vcs/test_vcs_mercator_edge.py index eb6d79cdb7..31f6cb83bb 100644 --- a/testing/vcs/test_vcs_mercator_edge.py +++ b/testing/vcs/test_vcs_mercator_edge.py @@ -1,24 +1,9 @@ -import vcs,cdms2 -import os,sys +import os, sys, cdms2, vcs, testing.regression as regression + f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) s = f("clt") -x = vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") +x = regression.init() iso = x.createisofill() iso.projection = "mercator" x.plot(s(latitude=(-90, 90)), iso, bg=1) - -# Load the image testing module: -testingDir = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(testingDir) -import checkimage - -# Create the test image and compare: -baseline = sys.argv[1] -testFile = "test_vcs_mercator_edge.png" -x.png(testFile) -ret = checkimage.check_result_image(testFile, baseline, - checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, "test_vcs_mercator_edge.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_meshfill_draw_mesh.py b/testing/vcs/test_vcs_meshfill_draw_mesh.py index ef214e6485..08801d7a6d 100644 --- a/testing/vcs/test_vcs_meshfill_draw_mesh.py +++ b/testing/vcs/test_vcs_meshfill_draw_mesh.py @@ -1,23 +1,11 @@ -import vcs,cdms2,sys,os -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -x=vcs.init() -x.setantialiasing(0) -x.setbgoutputdimensions(1200,1091,units="pixels") -x.drawlogooff() -fnmcurv = os.path.join(vcs.sample_data,'sampleCurveGrid4.nc') -f=cdms2.open(fnmcurv) +import os, sys, cdms2, vcs, testing.regression as regression -s=f("sample") -m=x.createmeshfill() -m.mesh=True +x = regression.init() +fnmcurv = os.path.join(vcs.sample_data,'sampleCurveGrid4.nc') +f = cdms2.open(fnmcurv) +s = f("sample") +m = x.createmeshfill() +m.mesh = True x.plot(s,m,bg=1) -fnm = "test_meshfill_draw_mesh.png" -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, "test_meshfill_draw_mesh.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_meshfill_no_wrapping.py b/testing/vcs/test_vcs_meshfill_no_wrapping.py index 967758c786..9ee4a99f1c 100755 --- a/testing/vcs/test_vcs_meshfill_no_wrapping.py +++ b/testing/vcs/test_vcs_meshfill_no_wrapping.py @@ -1,23 +1,7 @@ -#!/usr/bin/env python -import cdms2 -import os -import sys -import vcs - -pth = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(pth) -import checkimage - - -f=cdms2.open(sys.argv[2]) -h=f("heat") -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200, 900, units="pixels") +import os, sys, cdms2, vcs, testing.regression as regression +f = cdms2.open(sys.argv[2]) +h = f("heat") +x = regression.init() x.plot(h, bg=1) -fnm = "vcs_test_meshfill_no_wrapping.png" -x.png(fnm) -ret = checkimage.check_result_image(fnm, sys.argv[1], checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, "vcs_test_meshfill_no_wrapping.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_meshfill_regular_grid.py b/testing/vcs/test_vcs_meshfill_regular_grid.py index 9a955f9fff..77a390b221 100644 --- a/testing/vcs/test_vcs_meshfill_regular_grid.py +++ b/testing/vcs/test_vcs_meshfill_regular_grid.py @@ -1,22 +1,7 @@ -import vcs, cdms2, os, sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() +import os, sys, cdms2, vcs, testing.regression as regression -x.setbgoutputdimensions(1200,1091,units="pixels") -x = vcs.init() -x.setantialiasing(0) +x = regression.init() f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) s = f("clt") -x.meshfill(s,bg=1) -fnm = "test_meshfill_regular_grid.png" -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +x.meshfill(s, bg=1) +regression.run(x, "test_meshfill_regular_grid.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_meshfill_vertices.py b/testing/vcs/test_vcs_meshfill_vertices.py index 6317ef0719..103e681094 100644 --- a/testing/vcs/test_vcs_meshfill_vertices.py +++ b/testing/vcs/test_vcs_meshfill_vertices.py @@ -1,19 +1,8 @@ -import numpy -import vcs -import sys -import os -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import os, sys, numpy, vcs, testing.regression as regression -x=vcs.init() - -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200, 1090, units="pixels") +x = regression.init() data_values = [ 25, 45, 55.] - data_lon = [ 5., 10., 15.] data_lat = [ 5., 10., 15.] @@ -50,8 +39,4 @@ m.mesh = True x.plot(numpy.array(data_values,),mesh,m,bg=True) -x.png("test_vcs_meshfill_vertices_issue.png") -src = sys.argv[1] -ret = checkimage.check_result_image("test_vcs_meshfill_vertices_issue.png", - src, checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, "test_vcs_meshfill_vertices_issue.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_meshfill_zoom.py b/testing/vcs/test_vcs_meshfill_zoom.py index 1026f0ff08..c366d80100 100644 --- a/testing/vcs/test_vcs_meshfill_zoom.py +++ b/testing/vcs/test_vcs_meshfill_zoom.py @@ -1,14 +1,4 @@ -#!/usr/bin/env python -import cdms2 -import os -import sys -import vcs - -# We test if gm.datawc zooms in correctly into the plot. This works only for -# data using a linear projection. It does not work for geographic projections. -pth = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(pth) -import checkimage +import os, sys, cdms2, vcs, testing.regression as regression flip = False if (len(sys.argv) == 3): @@ -19,12 +9,10 @@ if (flip): fileName = fileName + '_flip' fileName = fileName + '.png' -f=cdms2.open(os.path.join(vcs.sample_data, "sampleCurveGrid4.nc")) -s=f("sample") -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -m=x.createmeshfill() +f = cdms2.open(os.path.join(vcs.sample_data, "sampleCurveGrid4.nc")) +s = f("sample") +x = regression.init() +m = x.createmeshfill() # m.mesh = True m.datawc_x1 = -20 m.datawc_x2 = 20 @@ -33,7 +21,4 @@ m.datawc_y1 = -20 m.datawc_y2 = 20 x.plot(s,m, bg=1) -x.png(fileName) -ret = checkimage.check_result_image(fileName, sys.argv[1], checkimage.defaultThreshold) -sys.exit(ret) - +regression.run(x, fileName) \ No newline at end of file diff --git a/testing/vcs/test_vcs_mintics.py b/testing/vcs/test_vcs_mintics.py index 01f65848b2..302c22fd49 100644 --- a/testing/vcs/test_vcs_mintics.py +++ b/testing/vcs/test_vcs_mintics.py @@ -1,16 +1,10 @@ -import vcs,numpy,cdms2,MV2,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import os, sys, numpy, cdms2, MV2, vcs, testing.regression as regression -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") +x = regression.init() f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) s = f("clt") box = x.createboxfill() + # Should ignore the string here box.xmtics1 = {i:"Test" for i in range(-180, 180, 15) if i % 30 != 0} box.ymtics1 = {i:"Test" for i in range(-90, 90, 5) if i % 10 != 0} @@ -23,10 +17,4 @@ template.xmintic2.y2 += template.xmintic1.y1 - template.xmintic1.y2 template.ymintic2.priority = 1 x.plot(s, template, box, bg=1) -fnm = "test_vcs_mintics.png" -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, "test_vcs_mintics.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_missing_colorname.py b/testing/vcs/test_vcs_missing_colorname.py index 1ed68b4750..9b3db75458 100644 --- a/testing/vcs/test_vcs_missing_colorname.py +++ b/testing/vcs/test_vcs_missing_colorname.py @@ -1,7 +1,4 @@ -import cdms2 -import os -import sys -import vcs +import os, sys, cdms2, vcs, testing.regression as regression # Load the clt data: dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) @@ -11,10 +8,7 @@ clt.mask = [[True if i % 2 else False for i in range(width)] for _ in range(height)] # Initialize canvas: -canvas = vcs.init() -canvas.setantialiasing(0) -canvas.setbgoutputdimensions(1200,1091,units="pixels") -canvas.drawlogooff() +canvas = regression.init() # Create and plot quick boxfill with default settings: # Only have to test boxfill because all 2D methods use the same code @@ -25,16 +19,4 @@ boxfill.missing = "Medium Aquamarine" canvas.plot(clt, boxfill, bg=1) - -# Load the image testing module: -testingDir = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(testingDir) -import checkimage - -# Create the test image and compare: -baseline = sys.argv[1] -testFile = "test_vcs_missing_colorname.png" -canvas.png(testFile) -ret = checkimage.check_result_image(testFile, baseline, - checkimage.defaultThreshold) -sys.exit(ret) +regression.run(canvas, "test_vcs_missing_colorname.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_monotonic_decreasing_yxvsx_default.py b/testing/vcs/test_vcs_monotonic_decreasing_yxvsx_default.py index 9f30f40ae4..4dcd059a02 100644 --- a/testing/vcs/test_vcs_monotonic_decreasing_yxvsx_default.py +++ b/testing/vcs/test_vcs_monotonic_decreasing_yxvsx_default.py @@ -1,27 +1,14 @@ -import vcs,numpy,cdms2,MV2,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -x=vcs.init() -x.setantialiasing(0) +import os, sys, numpy, cdms2, MV2, vcs, testing.regression as regression -x.setbgoutputdimensions(1200,1091,units="pixels") - -t=cdms2.createAxis(numpy.arange(120)) +x = regression.init() +t = cdms2.createAxis(numpy.arange(120)) t.designateTime() -t.id="time" -t.units="months since 2014" +t.id = "time" +t.units = "months since 2014" data = MV2.arange(120,0,-1) -data.id="data" +data.id = "data" data.setAxis(0,t) -x=vcs.init() -x.setantialiasing(0) +x = regression.init() x.plot(data,bg=1) fnm = 'test_vcs_monotonic_decreasing_yxvsx_default.png' - -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, fnm) \ No newline at end of file diff --git a/testing/vcs/test_vcs_oned_level_axis.py b/testing/vcs/test_vcs_oned_level_axis.py index 25479a56b9..ecb708c773 100644 --- a/testing/vcs/test_vcs_oned_level_axis.py +++ b/testing/vcs/test_vcs_oned_level_axis.py @@ -1,24 +1,9 @@ +import os, sys, vcs, cdms2, cdutil, testing.regression as regression -import sys,cdutil -import vcs -import os -import cdms2 -src = sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage - -f=cdms2.open(os.path.join(vcs.sample_data,"ta_ncep_87-6-88-4.nc")) -ta=f("ta",time=slice(0,1),squeeze=1) -ta=cdutil.averager(ta,axis="yx") -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") +f = cdms2.open(os.path.join(vcs.sample_data,"ta_ncep_87-6-88-4.nc")) +ta = f("ta",time=slice(0,1),squeeze=1) +ta = cdutil.averager(ta,axis="yx") +x = regression.init() x.plot(ta,bg=1) fnm = "test_oned_level_axis.png" -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, fnm) \ No newline at end of file diff --git a/testing/vcs/test_vcs_patterns.py b/testing/vcs/test_vcs_patterns.py index fed4f41a83..c407f7cfee 100644 --- a/testing/vcs/test_vcs_patterns.py +++ b/testing/vcs/test_vcs_patterns.py @@ -1,19 +1,8 @@ -import cdms2 -import os -import sys -import vcs - -src = sys.argv[1] -pth = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(pth) -import checkimage +import os, sys, vcs, cdms2, testing.regression as regression f = cdms2.open(vcs.sample_data+"/clt.nc") s = f("clt", time=slice(0, 1), squeeze=1) -x = vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200, 1090, units="pixels") +x = regression.init() iso = vcs.createisofill("isoleg") iso.levels = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100] iso.fillareastyle = "pattern" @@ -21,9 +10,4 @@ iso.fillareaindices = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20] x.plot(s, iso, bg=1) fnm = "test_vcs_patterns.png" -x.png(fnm) - -print "fnm:", fnm -print "src:", src -ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold+5.) -sys.exit(ret) +regression.run(x, fnm, threshold=regression.defaultThreshold+5.) \ No newline at end of file diff --git a/testing/vcs/test_vcs_plot_file_var.py b/testing/vcs/test_vcs_plot_file_var.py index e20f947a67..0dd68945d9 100644 --- a/testing/vcs/test_vcs_plot_file_var.py +++ b/testing/vcs/test_vcs_plot_file_var.py @@ -1,8 +1,6 @@ -import vcs -import os -import sys -import cdms2 -f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) -V=f("clt") -x=vcs.init() -x.plot(V,bg=1) +import os, sys, vcs, cdms2 + +f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) +V = f("clt") +x = vcs.init() +x.plot(V, bg=1) diff --git a/testing/vcs/test_vcs_plot_unstructured_via_boxfill.py b/testing/vcs/test_vcs_plot_unstructured_via_boxfill.py index 4aa1d24eba..535ff432ec 100644 --- a/testing/vcs/test_vcs_plot_unstructured_via_boxfill.py +++ b/testing/vcs/test_vcs_plot_unstructured_via_boxfill.py @@ -1,21 +1,7 @@ -import vcs -import os,sys -import cdms2 - -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) - -import checkimage +import vcs, os, sys, cdms2, testing.regression as regression f = cdms2.open(os.path.join(vcs.sample_data,"sampleCurveGrid4.nc")) s = f("sample") -x = vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") +x = regression.init() x.plot(s,bg=1) -fnm = "test_plot_unstructured_via_boxfill.png" -src = sys.argv[1] -x.png(fnm) -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, "test_plot_unstructured_via_boxfill.png") diff --git a/testing/vcs/test_vcs_png_to_base64.py b/testing/vcs/test_vcs_png_to_base64.py index 6b88b35114..f6d78e2fa9 100644 --- a/testing/vcs/test_vcs_png_to_base64.py +++ b/testing/vcs/test_vcs_png_to_base64.py @@ -1,4 +1,4 @@ -import vcs,numpy,cdms2,MV2,os,sys +import vcs, numpy, cdms2, MV2, os, sys x = vcs.init() x.drawlogooff() diff --git a/testing/vcs/test_vcs_png_window_resize.py b/testing/vcs/test_vcs_png_window_resize.py index 0adeeb66ba..a6346ca282 100644 --- a/testing/vcs/test_vcs_png_window_resize.py +++ b/testing/vcs/test_vcs_png_window_resize.py @@ -1,20 +1,9 @@ -import vcs -import sys -import os +import vcs, sys, os, testing.regression as regression -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -x=vcs.init() +x = regression.init() x.setantialiasing(0) x.drawlogooff() x.open(814,628) x.plot([1,2,3,4,5,6,7]) fnm = __file__[:-3]+".png" -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, fnm) \ No newline at end of file diff --git a/testing/vcs/test_vcs_polar_set_opt_param_polar.py b/testing/vcs/test_vcs_polar_set_opt_param_polar.py index 8c508ca3c0..4e777fb2b3 100644 --- a/testing/vcs/test_vcs_polar_set_opt_param_polar.py +++ b/testing/vcs/test_vcs_polar_set_opt_param_polar.py @@ -1,29 +1,13 @@ +import vcs, cdms2, sys, os, testing.regression as regression -import vcs -import cdms2 -import sys -import os - -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage - -f=cdms2.open(os.path.join(vcs.sample_data,'clt.nc')) -s=f("clt",slice(0,1),squeeze=1) -x=vcs.init() +f = cdms2.open(os.path.join(vcs.sample_data,'clt.nc')) +s = f("clt",slice(0,1),squeeze=1) +x = regression.init() x.setantialiasing(0) x.drawlogooff() x.setbgoutputdimensions(1200,1091,units="pixels") -i=x.createisofill() -p=x.getprojection("polar") +i = x.createisofill() +p = x.getprojection("polar") i.projection=p x.plot(s,i,bg=1) -fnm= "test_polar_set_opt_param_polar.png" -x.png(fnm) - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) - +regression.run(x, "test_polar_set_opt_param_polar.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_remove_marker_none_1d.py b/testing/vcs/test_vcs_remove_marker_none_1d.py index f868361b0f..e112f86bc5 100644 --- a/testing/vcs/test_vcs_remove_marker_none_1d.py +++ b/testing/vcs/test_vcs_remove_marker_none_1d.py @@ -3,31 +3,13 @@ # # J-Y Peterschmitt - LSCE - 03/2015 -import vcs,numpy,cdms2,MV2,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression dummy_data = numpy.arange(50, dtype=numpy.float32) - -x = vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") - +x = regression.init() gm = x.createyxvsx('test_yxvsx') - -# Remove the marker gm.marker = None - x.plot(gm, dummy_data,bg=1) - fnm = "test_remove_marker_none_1d.png" -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) -# The end +regression.run(x, fnm) \ No newline at end of file diff --git a/testing/vcs/test_vcs_setcolormap.py b/testing/vcs/test_vcs_setcolormap.py index c3e6396600..78d7fad817 100644 --- a/testing/vcs/test_vcs_setcolormap.py +++ b/testing/vcs/test_vcs_setcolormap.py @@ -1,32 +1,12 @@ -import cdms2 -import os -import sys -import vcs - -baselineFilename = sys.argv[1] -checkImagePath = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(checkImagePath) -import checkimage +import cdms2, os, sys, vcs, testing.regression as regression cdmsfile = cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) data = cdmsfile('clt') - -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") - +x = regression.init() t=x.gettemplate('default') x.plot(data, t, bg=True) # This should force the image to update x.setcolormap('bl_to_drkorang') - -testFilename = "test_vcs_setcolormap.png" -x.png(testFilename) - -ret = checkimage.check_result_image(testFilename, - baselineFilename, - checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, "test_vcs_setcolormap.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_settings_color_name_rgba.py b/testing/vcs/test_vcs_settings_color_name_rgba.py index 0b6aeef22f..0fa6ec2884 100644 --- a/testing/vcs/test_vcs_settings_color_name_rgba.py +++ b/testing/vcs/test_vcs_settings_color_name_rgba.py @@ -1,28 +1,13 @@ -import vcs -import numpy -import os -import sys -import cdms2 -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import vcs, numpy, os, sys, cdms2, testing.regression as regression -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1090,units="pixels") +x = regression.init() -f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) -data=f("clt",slice(0,1,)) +f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) +data = f("clt",slice(0,1,)) gm = x.createisofill() gm.levels = range(0,110,10) gm.fillareacolors = ["green","red","blue","bisque","yellow","grey", [100,0,0,50], [0,100,0],"salmon",[0,0,100,75]] x.plot(data,gm,bg=True) -fnm = 'test_vcs_settings_color_name_rgba_isofill.png' -src = sys.argv[1] -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +fnm = "test_vcs_settings_color_name_rgba_isofill.png" +regression.run(x, fnm) \ No newline at end of file diff --git a/testing/vcs/test_vcs_settings_color_name_rgba_1d.py b/testing/vcs/test_vcs_settings_color_name_rgba_1d.py index 0fe844c203..8bca782a68 100644 --- a/testing/vcs/test_vcs_settings_color_name_rgba_1d.py +++ b/testing/vcs/test_vcs_settings_color_name_rgba_1d.py @@ -1,16 +1,6 @@ -import vcs -import numpy -import os -import sys -import cdms2 -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import vcs, numpy, os, sys, cdms2, testing.regression as regression -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1090,units="pixels") +x = regression.init() f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) data=f("clt")[:,5,8] @@ -18,10 +8,4 @@ gm.linecolor="salmon" gm.markercolor = [0,0,100] x.plot(data,gm,bg=True) -fnm = 'test_vcs_settings_color_name_rgba_1d.png' -src = sys.argv[1] -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, 'test_vcs_settings_color_name_rgba_1d.png') \ No newline at end of file diff --git a/testing/vcs/test_vcs_settings_color_name_rgba_boxfill.py b/testing/vcs/test_vcs_settings_color_name_rgba_boxfill.py index 043d331c8a..34228513e5 100644 --- a/testing/vcs/test_vcs_settings_color_name_rgba_boxfill.py +++ b/testing/vcs/test_vcs_settings_color_name_rgba_boxfill.py @@ -1,17 +1,6 @@ -import vcs -import numpy -import os -import sys -import cdms2 -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage - -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1090,units="pixels") +import vcs, numpy, os, sys, cdms2, testing.regression as regression +x = regression.init() f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) data=f("clt",slice(0,1,)) gm = x.createboxfill() @@ -20,10 +9,4 @@ gm.fillareacolors = ["green","red","blue","bisque","yellow","grey", [100,0,0,50], [0,100,0],"salmon",[0,0,100,75]] x.plot(data,gm,bg=True) -fnm = 'test_vcs_settings_color_name_rgba_boxfill.png' -src = sys.argv[1] -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, 'test_vcs_settings_color_name_rgba_boxfill.png') \ No newline at end of file diff --git a/testing/vcs/test_vcs_settings_color_name_rgba_isoline.py b/testing/vcs/test_vcs_settings_color_name_rgba_isoline.py index 200293dbee..c23edc2a6f 100644 --- a/testing/vcs/test_vcs_settings_color_name_rgba_isoline.py +++ b/testing/vcs/test_vcs_settings_color_name_rgba_isoline.py @@ -1,17 +1,6 @@ -import vcs -import numpy -import os -import sys -import cdms2 -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage - -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1090,units="pixels") +import vcs, numpy, os, sys, cdms2, testing.regression as regression +x=regression.init() f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) data=f("clt",slice(0,1,)) gm = x.createisoline() @@ -19,10 +8,4 @@ gm.linecolors = ["green","red","blue","bisque","yellow","grey", [100,0,0,50], [0,100,0],"salmon",[0,0,100,75]] x.plot(data,gm,bg=True) -fnm = 'test_vcs_settings_color_name_rgba_isoline.png' -src = sys.argv[1] -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, 'test_vcs_settings_color_name_rgba_isoline.png') \ No newline at end of file diff --git a/testing/vcs/test_vcs_settings_color_name_rgba_meshfill.py b/testing/vcs/test_vcs_settings_color_name_rgba_meshfill.py index 4a0858d1d1..0b3ffc8716 100644 --- a/testing/vcs/test_vcs_settings_color_name_rgba_meshfill.py +++ b/testing/vcs/test_vcs_settings_color_name_rgba_meshfill.py @@ -1,17 +1,6 @@ -import vcs -import numpy -import os -import sys -import cdms2 -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage - -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1090,units="pixels") +import vcs, numpy, os, sys, cdms2, testing.regression as regression +x = regression.init() f=cdms2.open(os.path.join(vcs.sample_data,"sampleCurveGrid4.nc")) data=f("sample") gm = x.createmeshfill() @@ -19,10 +8,4 @@ gm.fillareacolors = ["green","red","blue","bisque","yellow","grey", [100,0,0,50], [0,100,0],"salmon",[0,0,100,75]] x.plot(data,gm,bg=True) -fnm = 'test_vcs_settings_color_name_rgba_meshfill.png' -src = sys.argv[1] -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +ret = regression.run(x, 'test_vcs_settings_color_name_rgba_meshfill.png') \ No newline at end of file diff --git a/testing/vcs/test_vcs_star_triangle_markers.py b/testing/vcs/test_vcs_star_triangle_markers.py index 4564e4059c..2d75e05d06 100644 --- a/testing/vcs/test_vcs_star_triangle_markers.py +++ b/testing/vcs/test_vcs_star_triangle_markers.py @@ -1,9 +1,5 @@ -import vcs,numpy,cdms2,MV2,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression x=vcs.init() x.drawlogooff() @@ -16,12 +12,5 @@ m.y = [[.1], [.3], [.5], [.7], [.9]] m.color = [200, 150, 160, 175, 125] m.size = [50, 50, 50, 50, 50] -x.plot(m,bg=1) -fnm = "test_star_triangle_markers.png" -x.png(fnm) - -print "fnm:",fnm -print "src:",src - -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +x.plot(m, bg=1) +regression.run(x, "test_star_triangle_markers.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_taylor_2quads.py b/testing/vcs/test_vcs_taylor_2quads.py index 3458acb911..84f1026156 100644 --- a/testing/vcs/test_vcs_taylor_2quads.py +++ b/testing/vcs/test_vcs_taylor_2quads.py @@ -1,17 +1,6 @@ -import sys,os -src = sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -import vcs, MV2 +import sys, os, vcs, MV2, testing.regression as regression - -bg=True - -# -# First create some sample data -# data = MV2.array([[-0.50428531,-0.8505522 ,], [ 0.70056821,-0.27235352,], [ 0.05106154, 0.23012322,], @@ -19,20 +8,8 @@ [ 0.85760801,-0.08336641,], [ 1.14083397,-0.78326507,]]) -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() - -if bg: - x.setbgoutputdimensions(1200,1091,units="pixels") - -td=x.createtaylordiagram('new') - +x = regression.init() +td = x.createtaylordiagram('new') td.quadrans = 2 -x.plot(data,td,skill = td.defaultSkillFunction,bg=bg) -fnm = "test_vcs_taylor_2quads.png" -x.png(fnm) -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -if not bg: - raw_input("Press Enter") -sys.exit(ret) +x.plot(data, td, skill = td.defaultSkillFunction, bg=1) +regression.run(x, "test_vcs_taylor_2quads.png") diff --git a/testing/vcs/test_vcs_taylor_template_ctl.py b/testing/vcs/test_vcs_taylor_template_ctl.py index 40b78f0dce..b6f610c7da 100644 --- a/testing/vcs/test_vcs_taylor_template_ctl.py +++ b/testing/vcs/test_vcs_taylor_template_ctl.py @@ -1,20 +1,8 @@ -import sys,os -src = sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -import vcs,MV2 +import sys, os, vcs, MV2 +import testing.regression as regression -bg=True - -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -if bg: - x.setbgoutputdimensions(1200,1091,units="pixels") -if not bg: - x.open() +x = regression.init() ## Create a template from the default taylor diagram t=x.createtemplate('mytaylor','deftaylor') @@ -61,12 +49,5 @@ # Create some dummy data for display purposes data=MV2.array([[1.52,.52,],[.83,.84]]) -x.plot(data,t,td,bg=bg) -fnm="test_vcs_taylor_template_ctl.png" -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -if not bg: - raw_input("Press Enter") -sys.exit(ret) +x.plot(data, t, td, bg=1) +regression.run(x, "test_vcs_taylor_template_ctl.png") diff --git a/testing/vcs/test_vcs_user_passed_date.py b/testing/vcs/test_vcs_user_passed_date.py index 643d2019cd..bb5b18a0d3 100644 --- a/testing/vcs/test_vcs_user_passed_date.py +++ b/testing/vcs/test_vcs_user_passed_date.py @@ -1,18 +1,9 @@ import vcs,cdms2,os,sys,cdtime -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import testing.regression as regression + f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) s=f("clt",squeeze=1) -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") +x=regression.init() x.plot(s,bg=1,time=cdtime.comptime(2015)) fnm = os.path.split(__file__)[1][:-3]+".png" -x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, fnm) diff --git a/testing/vcs/test_vcs_user_passed_date_as_string.py b/testing/vcs/test_vcs_user_passed_date_as_string.py index cd5d777f3d..e9bdf83e62 100644 --- a/testing/vcs/test_vcs_user_passed_date_as_string.py +++ b/testing/vcs/test_vcs_user_passed_date_as_string.py @@ -1,18 +1,11 @@ import vcs,cdms2,os,sys,cdtime -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import testing.regression as regression + +x = regression.init() + f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) s=f("clt",squeeze=1) -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") x.plot(s,bg=1,time='2015-02-23') fnm = os.path.split(__file__)[1][:-3]+".png" x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, fnm) diff --git a/testing/vcs/test_vcs_vectors_missing.py b/testing/vcs/test_vcs_vectors_missing.py index fd53c97e11..5e8b08e5be 100644 --- a/testing/vcs/test_vcs_vectors_missing.py +++ b/testing/vcs/test_vcs_vectors_missing.py @@ -1,6 +1,6 @@ -import sys,os -import argparse +import sys, os, argparse +import vcs, cdms2, vtk, MV2, numpy, testing.regression as regression p = argparse.ArgumentParser(description="Basic gm testing code for vcs") p.add_argument("--source", dest="src", help="source image file") @@ -14,28 +14,17 @@ src = args.src pth = os.path.join(os.path.dirname(__file__),"..") sys.path.append(pth) - import checkimage - -import vcs -import sys -import cdms2 -import vtk -import os -import MV2 -import numpy - bg = not args.show - -x=vcs.init() +x = vcs.init() x.setantialiasing(0) x.drawlogooff() if bg: x.setbgoutputdimensions(1200,1091,units="pixels") x.setcolormap("rainbow") -gm=vcs.createvector() +gm = vcs.createvector() gm.scale = args.scale -nm_xtra="" +nm_xtra = "" xtra = {} import cdms2 import os @@ -52,14 +41,12 @@ pass #x.interact() else: - fnm = "test_vcs_vectors_missing" + fnm = "test_vcs_vectors_missing" if args.scale!=1.: fnm+="_%.1g" % args.scale fnm+=nm_xtra x.png(fnm) - print "fnm:",fnm - print "src:",src - ret = checkimage.check_result_image(fnm+'.png',src,checkimage.defaultThreshold, cleanup=not args.keep) + ret = regression.check_result_image(fnm+'.png', src, regression.defaultThreshold, cleanup=not args.keep) if args.show: raw_input("Press Enter") sys.exit(ret) diff --git a/testing/vcs/test_vcs_vectors_robinson.py b/testing/vcs/test_vcs_vectors_robinson.py index 49052c679f..5cde92c82c 100644 --- a/testing/vcs/test_vcs_vectors_robinson.py +++ b/testing/vcs/test_vcs_vectors_robinson.py @@ -1,13 +1,7 @@ import vcs, cdms2, numpy, os, sys -src = sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import testing.regression as regression -x = vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200, 1091, units="pixels") +x = regression.init() f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) u = f("u") v = f("v") @@ -16,8 +10,4 @@ p.type = "robinson" V.projection = p x.plot(u,v,V, bg=1) - -fnm = "test_vcs_vectors_robinson.png" -x.png(fnm) -ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, "test_vcs_vectors_robinson.png") diff --git a/testing/vcs/test_vcs_vectors_robinson_wrap.py b/testing/vcs/test_vcs_vectors_robinson_wrap.py index 86491cc2f1..3cb30f06ff 100644 --- a/testing/vcs/test_vcs_vectors_robinson_wrap.py +++ b/testing/vcs/test_vcs_vectors_robinson_wrap.py @@ -1,13 +1,7 @@ import vcs, cdms2, numpy, os, sys -src = sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import testing.regression as regression -x = vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200, 1091, units="pixels") +x = regression.init() f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) lon1 = -180 u = f("clt") @@ -19,8 +13,4 @@ p.type = "robinson" V.projection = p x.plot(u,v,V, bg=1) - -fnm = "test_vcs_vectors_robinson_wrap.png" -x.png(fnm) -ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, "test_vcs_vectors_robinson_wrap.png") diff --git a/testing/vcs/test_vcs_verify_boxfill_basics.py b/testing/vcs/test_vcs_verify_boxfill_basics.py index 7d08a2b75f..0d7c4c2d0c 100644 --- a/testing/vcs/test_vcs_verify_boxfill_basics.py +++ b/testing/vcs/test_vcs_verify_boxfill_basics.py @@ -1,4 +1,3 @@ - import vcs import numpy import cdtime @@ -12,12 +11,12 @@ assert(b.projection == "linear") assert(b.xticlabels1 == "*") assert(b.xticlabels2 == "*") -assert(b.xmtics1 == "") +assert(b.xmtics1 == "") assert(b.xmtics2 == "") assert(b.yticlabels1 == "*") assert(b.yticlabels2 == "*") -assert(b.ymtics1 == "") -assert(b.ymtics2 == "") +assert(b.ymtics1 == "") +assert(b.ymtics2 == "") assert(numpy.allclose(b.datawc_x1, 1e+20)) assert(numpy.allclose(b.datawc_x2, 1e+20)) assert(numpy.allclose(b.datawc_y1, 1e+20)) @@ -71,12 +70,12 @@ assert(b.projection == "test_bfill") assert(b.xticlabels1 == {23:"Hi"}) assert(b.xticlabels2 == {23:"Hi"}) -assert(b.xmtics1 == {23:"Hi"}) +assert(b.xmtics1 == {23:"Hi"}) assert(b.xmtics2 == {23:"Hi"}) assert(b.yticlabels1 == {23:"Hi"}) assert(b.yticlabels2 == {23:"Hi"}) -assert(b.ymtics1 == {23:"Hi"}) -assert(b.ymtics2 == {23:"Hi"}) +assert(b.ymtics1 == {23:"Hi"}) +assert(b.ymtics2 == {23:"Hi"}) assert(numpy.allclose(b.datawc_x1, 56.7)) assert(numpy.allclose(b.datawc_x2, 56.7)) assert(numpy.allclose(b.datawc_y1, 56.7)) diff --git a/testing/vcs/test_vcs_wmo_marker.py b/testing/vcs/test_vcs_wmo_marker.py index b4478372f0..854e4a9bee 100644 --- a/testing/vcs/test_vcs_wmo_marker.py +++ b/testing/vcs/test_vcs_wmo_marker.py @@ -1,14 +1,10 @@ import vcs,numpy,cdms2,MV2,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") + +import testing.regression as regression +x = regression.init() + m = x.createmarker() M=1 @@ -22,8 +18,5 @@ fnm = 'wmo_marker.png' x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +regression.run(x, "wmo_marker.png") diff --git a/testing/vcs/test_vcs_wmo_markers.py b/testing/vcs/test_vcs_wmo_markers.py index 5785e09255..5162eeeee5 100644 --- a/testing/vcs/test_vcs_wmo_markers.py +++ b/testing/vcs/test_vcs_wmo_markers.py @@ -1,26 +1,20 @@ import vcs,numpy,cdms2,MV2,os,sys -src=sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import testing.regression as regression wmo = ['w00', 'w01', 'w02', 'w03', 'w04', 'w05', 'w06', 'w07', 'w08', 'w09', 'w10', 'w11', 'w12', 'w13', 'w14', 'w15', 'w16', 'w17', 'w18', 'w19', - 'w20', 'w21', 'w22', 'w23', 'w24', 'w25', 'w26', 'w27', 'w28', 'w29', + 'w20', 'w21', 'w22', 'w23', 'w24', 'w25', 'w26', 'w27', 'w28', 'w29', 'w30', 'w31', 'w32', 'w33', 'w34', 'w35', 'w36', 'w37', 'w38', 'w39', 'w40', 'w41', 'w42', 'w43', 'w44', 'w45', 'w46', 'w47', 'w48', 'w49', 'w50', 'w51', 'w52', 'w53', 'w54', 'w55', 'w56', 'w57', 'w58', 'w59', - 'w60', 'w61', 'w62', 'w63', 'w64', 'w65', 'w66', 'w67', 'w68', 'w69', + 'w60', 'w61', 'w62', 'w63', 'w64', 'w65', 'w66', 'w67', 'w68', 'w69', 'w70', 'w71', 'w72', 'w73', 'w74', 'w75', 'w76', 'w77', 'w78', 'w79', 'w80', 'w81', 'w82', 'w83', 'w84', 'w85', 'w86', 'w87', 'w88', 'w89', 'w90', 'w91', 'w92', 'w93', 'w94', 'w95', 'w96', 'w97', 'w98', 'w99', 'w100', 'w101', 'w102'] -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") +x = regression.init() m = x.createmarker() M=7 @@ -37,13 +31,6 @@ m.x = xs m.y = ys m.list() -x.plot(m,bg=1) -fnm = "wmo_markers.png" -x.png(fnm) - - -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) -sys.exit(ret) +x.plot(m, bg=1) +regression.run(x, "wmo_markers.png"); diff --git a/testing/vcs/vtk_ui/vtk_ui_test.py b/testing/vcs/vtk_ui/vtk_ui_test.py index facfd7f451..40bbeaef1e 100644 --- a/testing/vcs/vtk_ui/vtk_ui_test.py +++ b/testing/vcs/vtk_ui/vtk_ui_test.py @@ -1,8 +1,4 @@ -import vtk -import vcs.vtk_ui -import os -import sys -import time +import, os, sys, time, vcs.vtk_ui, vtk def init(): @@ -101,15 +97,13 @@ def do_test(self): def check_image(self, compare_against): """ Checks the current render window's output against the image specified in the argument, - returns the result of checkimage.check_result_image + returns the result of regression.check_result_image """ generate_png(self.win, self.test_file) pth = os.path.join(os.path.dirname(__file__), "../..") sys.path.append(pth) - import checkimage - print "fnm:", self.test_file - print "src:", compare_against - return checkimage.check_result_image(self.test_file, compare_against, checkimage.defaultThreshold) + import regression + return regression.check_result_image(self.test_file, compare_against) def test(self): self.do_test() diff --git a/testing/vcsaddons/test_12_plot_one_leg_per_row.py b/testing/vcsaddons/test_12_plot_one_leg_per_row.py index b3cfa0fba6..0c02985277 100644 --- a/testing/vcsaddons/test_12_plot_one_leg_per_row.py +++ b/testing/vcsaddons/test_12_plot_one_leg_per_row.py @@ -1,14 +1,7 @@ - -import sys,os -src = sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -import EzTemplate,vcs -## 12 plot one legend per row +import os, sys, EzTemplate, vcs, testing.regression as regression ## Initialize VCS -x=vcs.init() +x = vcs.init() x.drawlogooff() bg = True @@ -20,9 +13,7 @@ t.legend.priority=0 # Turn off legend fnm = "test_12_plot_one_leg_per_row.png" M.preview(fnm,bg=bg) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) +ret = regression.check_result_image(fnm, sys.argv[1]) if not bg: raw_input("Press Enter") sys.exit(ret) diff --git a/testing/vcsaddons/test_12_plot_one_leg_per_row_right.py b/testing/vcsaddons/test_12_plot_one_leg_per_row_right.py index 42e0f64e4c..b57b767245 100644 --- a/testing/vcsaddons/test_12_plot_one_leg_per_row_right.py +++ b/testing/vcsaddons/test_12_plot_one_leg_per_row_right.py @@ -1,17 +1,13 @@ +import os, sys, testing.regression as regression -import sys,os -src = sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage import EzTemplate,vcs import cdms,EzTemplate,vcs,sys ## 12 plots 1 legend per row on the right ## Initialize VCS -x=vcs.init() +x = vcs.init() x.drawlogooff() -bg=True -M=EzTemplate.Multi(rows=4,columns=3) +bg = True +M = EzTemplate.Multi(rows=4,columns=3) M.legend.direction='vertical' for i in range(12): t=M.get(legend='local') @@ -19,9 +15,7 @@ t.legend.priority=0 # Turn off legend fnm = "test_12_plot_one_leg_per_row_right.png" M.preview(fnm,bg=bg) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) +ret = regression.check_result_image(fnm, sys.argv[1]) if not bg: raw_input("Press Enter") sys.exit(ret) diff --git a/testing/vcsaddons/test_EzTemplate_12_plots_legd_direction.py b/testing/vcsaddons/test_EzTemplate_12_plots_legd_direction.py index b6ca9eb34f..d46e7b9acd 100644 --- a/testing/vcsaddons/test_EzTemplate_12_plots_legd_direction.py +++ b/testing/vcsaddons/test_EzTemplate_12_plots_legd_direction.py @@ -1,14 +1,7 @@ - -import sys,os -src = sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -import EzTemplate,vcs -## 12 plot one legend per row +import os, sys, EzTemplate, vcs, testing.regression as regression ## Initialize VCS -x=vcs.init() +x = vcs.init() x.drawlogooff() bg = True @@ -26,10 +19,8 @@ t=M.get() fnm = "test_EzTemplate_12_plots_legd_direction.png" -M.preview(fnm,bg=bg) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) +M.preview(fnm, bg=bg) +ret = regression.check_result_image(fnm, sys.argv[1]) if not bg: raw_input("Press Enter") sys.exit(ret) diff --git a/testing/vcsaddons/test_EzTemplate_12_plots_margins_thickness.py b/testing/vcsaddons/test_EzTemplate_12_plots_margins_thickness.py index 40899f264b..73b7c8dbf7 100644 --- a/testing/vcsaddons/test_EzTemplate_12_plots_margins_thickness.py +++ b/testing/vcsaddons/test_EzTemplate_12_plots_margins_thickness.py @@ -1,14 +1,7 @@ - -import sys,os -src = sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -import EzTemplate,vcs -## 12 plot one legend per row +import os, sys, EzTemplate, vcs, testing.regression as regression ## Initialize VCS -x=vcs.init() +x = vcs.init() x.drawlogooff() bg = True @@ -25,9 +18,7 @@ t=M.get() fnm = "test_EzTemplate_12_plots_margins_thickness.png" M.preview(fnm,bg=bg) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) +ret = regression.check_result_image(fnm, sys.argv[1]) if not bg: raw_input("Press Enter") sys.exit(ret) diff --git a/testing/vcsaddons/test_EzTemplate_12_plots_mix_glb_local.py b/testing/vcsaddons/test_EzTemplate_12_plots_mix_glb_local.py index 043e03de49..6e9398fe80 100644 --- a/testing/vcsaddons/test_EzTemplate_12_plots_mix_glb_local.py +++ b/testing/vcsaddons/test_EzTemplate_12_plots_mix_glb_local.py @@ -1,12 +1,4 @@ - -import sys,os -src = sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -import EzTemplate,vcs -## 12 plot one legend per row - +import os, sys, EzTemplate, vcs, testing.regression as regression ## Initialize VCS x=vcs.init() x.drawlogooff() @@ -24,9 +16,7 @@ fnm = "test_EzTemplate_12_plots_mix_glb_local.png" M.preview(fnm,bg=bg) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) +ret = regression.check_result_image(fnm, sys.argv[1]) if not bg: raw_input("Press Enter") sys.exit(ret) diff --git a/testing/vcsaddons/test_EzTemplate_12_plots_spacing.py b/testing/vcsaddons/test_EzTemplate_12_plots_spacing.py index d17eb1a691..5d4cd293b9 100644 --- a/testing/vcsaddons/test_EzTemplate_12_plots_spacing.py +++ b/testing/vcsaddons/test_EzTemplate_12_plots_spacing.py @@ -1,14 +1,6 @@ - -import sys,os -src = sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage -import EzTemplate,vcs -## 12 plot one legend per row - +import os, sys, EzTemplate, vcs, testing.regression as regression ## Initialize VCS -x=vcs.init() +x = vcs.init() x.drawlogooff() bg = True @@ -18,9 +10,7 @@ fnm = "test_EzTemplate_12_plots_spacing.png" M.preview(fnm,bg=bg) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) +ret = regression.check_result_image(fnm, sys.argv[1]) if not bg: raw_input("Press Enter") sys.exit(ret) diff --git a/testing/vcsaddons/test_vcs_addons_EzTemplate_2x2.py b/testing/vcsaddons/test_vcs_addons_EzTemplate_2x2.py index 2619fe5efc..ee645d16c0 100644 --- a/testing/vcsaddons/test_vcs_addons_EzTemplate_2x2.py +++ b/testing/vcsaddons/test_vcs_addons_EzTemplate_2x2.py @@ -1,21 +1,11 @@ +import os, sys, cdms2, testing.regression as regression, vcs, vcsaddons -import sys,os -src = sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage - -import vcs -import vcsaddons -import cdms2 - -f=cdms2.open(os.path.join(vcs.sample_data,'clt.nc')) -s=f("clt",time=slice(0,1),squeeze=1) +f = cdms2.open(os.path.join(vcs.sample_data,'clt.nc')) +s = f("clt",time=slice(0,1),squeeze=1) bg = True - -M=vcsaddons.EzTemplate.Multi(rows=2,columns=2) -x=vcs.init() +M = vcsaddons.EzTemplate.Multi(rows=2,columns=2) +x = vcs.init() x.setantialiasing(0) x.drawlogooff() if bg: @@ -25,9 +15,7 @@ fnm = "test_vcs_addons_EzTemplate_2x2.png" x.png(fnm) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) +ret = regression.check_result_image(fnm, sys.argv[1]) if not bg: raw_input("Press Enter") sys.exit(ret) diff --git a/testing/vcsaddons/test_vcsaddons_preview_2x2.py b/testing/vcsaddons/test_vcsaddons_preview_2x2.py index 754aa5ceae..a0318f25a9 100644 --- a/testing/vcsaddons/test_vcsaddons_preview_2x2.py +++ b/testing/vcsaddons/test_vcsaddons_preview_2x2.py @@ -1,22 +1,12 @@ - -import sys,os -src = sys.argv[1] -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage - -import vcsaddons +import os, sys, testing.regression as regression, vcsaddons bg = True - -M=vcsaddons.EzTemplate.Multi(rows=2,columns=2) +M = vcsaddons.EzTemplate.Multi(rows=2,columns=2) if bg: M.x.setbgoutputdimensions(1200,1091,units="pixels") fnm = "test_vcsaddons_preview_2x2.png" M.preview(out=fnm,bg=bg) -print "fnm:",fnm -print "src:",src -ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold) +ret = regression.check_result_image(fnm, sys.argv[1]) if not bg: raw_input("Press Enter") sys.exit(ret) From 569843aec62da106d9a7452983f49c999adcf4aa Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Fri, 13 May 2016 07:34:01 -0400 Subject: [PATCH 02/14] Updated to current master --- testing/vcs/test_fewer_colors_than_levels.py | 20 +++-------------- testing/vcs/test_vcs_no_continents.py | 23 +++----------------- 2 files changed, 6 insertions(+), 37 deletions(-) diff --git a/testing/vcs/test_fewer_colors_than_levels.py b/testing/vcs/test_fewer_colors_than_levels.py index 2779d4b6d3..c500cf19e3 100644 --- a/testing/vcs/test_fewer_colors_than_levels.py +++ b/testing/vcs/test_fewer_colors_than_levels.py @@ -1,18 +1,9 @@ -import vcs,cdms2,sys,os - -baselineImage = sys.argv[1] - -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import os, sys, cdms2, vcs, testing.regression as regression dataset = cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) data = dataset("clt") -canvas = vcs.init() -canvas.setantialiasing(0) -canvas.setbgoutputdimensions(1200, 1091, units="pixels") -canvas.drawlogooff() +canvas = regression.init() boxfill = canvas.createboxfill() @@ -21,9 +12,4 @@ canvas.plot(data, boxfill, bg=1) -testImage = os.path.abspath("test_fewer_colors_than_levels.png") -canvas.png(testImage) - -ret = checkimage.check_result_image(testImage, baselineImage, checkimage.defaultThreshold) - -sys.exit(ret) +regression.run(canvas, "test_fewer_colors_than_levels.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_no_continents.py b/testing/vcs/test_vcs_no_continents.py index 03630d4577..a5c3e8d04e 100644 --- a/testing/vcs/test_vcs_no_continents.py +++ b/testing/vcs/test_vcs_no_continents.py @@ -1,7 +1,4 @@ -import cdms2 -import os -import sys -import vcs +import os, sys, cdms2, vcs, testing.regression as regression # Load the clt data: dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) @@ -10,10 +7,7 @@ time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0')) # Initialize canvas: -canvas = vcs.init() -canvas.setantialiasing(0) -canvas.setbgoutputdimensions(1200,1091,units="pixels") -canvas.drawlogooff() +canvas = regression.init() t1 = vcs.createtemplate() t1.scale(.5, "y") @@ -24,15 +18,4 @@ canvas.plot(clt, t1, continents=0, bg=True) canvas.plot(clt, t2, continents=1, bg=True) -# Load the image testing module: -testingDir = os.path.join(os.path.dirname(__file__), "..") -sys.path.append(testingDir) -import checkimage - -# Create the test image and compare: -baseline = sys.argv[1] -testFile = "test_vcs_no_continents.png" -canvas.png(testFile) -ret = checkimage.check_result_image(testFile, baseline, - checkimage.defaultThreshold) -sys.exit(ret) +regression.run(canvas, "test_vcs_no_continents.png") \ No newline at end of file From 9990b92bbd4c29b95800d8a9feb3f14060158074 Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Fri, 13 May 2016 07:36:49 -0400 Subject: [PATCH 03/14] Ported common code to testing common --- Packages/testing/common.py | 22 +++++++++++++++++++ Packages/testing/regression.py | 1 + .../vcs/test_vcs_fillarea_basics_no_plot.py | 8 ++----- testing/vcs/test_vcs_verify_boxfill_basics.py | 7 ++---- testing/vcs/test_vcs_verify_proj_basics.py | 8 ++----- 5 files changed, 29 insertions(+), 17 deletions(-) create mode 100644 Packages/testing/common.py diff --git a/Packages/testing/common.py b/Packages/testing/common.py new file mode 100644 index 0000000000..7a32bcec51 --- /dev/null +++ b/Packages/testing/common.py @@ -0,0 +1,22 @@ +def test_values_setting(gm,attributes,good_values=[],bad_values=[]): + if isinstance(attributes,str): + attributes=[attributes,] + for att in attributes: + for val in good_values: + setattr(gm,att,val) + for val in bad_values: + try: + setattr(gm,att,val) + success = True + except: + success = False + else: + if success: + if hasattr(gm,"g_name"): + nm = gm.g_name + elif hasattr(gm,"s_name"): + nm = gm.s_name + else: + nm=gm.p_name + raise Exception,"Should not be able to set %s attribute '%s' to %s" % (nm,att,repr(val)) + sys.exit(1) diff --git a/Packages/testing/regression.py b/Packages/testing/regression.py index 68f381ce4d..bcc0882021 100644 --- a/Packages/testing/regression.py +++ b/Packages/testing/regression.py @@ -138,6 +138,7 @@ def printDart(name, type, value, suff=""): printDart("ValidImage", "image/png", os.path.abspath(bestFilename), "File") return -1 + def main(): if len(sys.argv) != 4: print "Error:" diff --git a/testing/vcs/test_vcs_fillarea_basics_no_plot.py b/testing/vcs/test_vcs_fillarea_basics_no_plot.py index 870aae9be8..9a8e38ce7f 100644 --- a/testing/vcs/test_vcs_fillarea_basics_no_plot.py +++ b/testing/vcs/test_vcs_fillarea_basics_no_plot.py @@ -1,9 +1,5 @@ - -import vcs -import numpy -import cdtime - -from vcs_test_common import * +import numpy, cdtime, vcs +from testing.common import test_values_setting x=vcs.init() x.drawlogooff() diff --git a/testing/vcs/test_vcs_verify_boxfill_basics.py b/testing/vcs/test_vcs_verify_boxfill_basics.py index 0d7c4c2d0c..0768ff9f91 100644 --- a/testing/vcs/test_vcs_verify_boxfill_basics.py +++ b/testing/vcs/test_vcs_verify_boxfill_basics.py @@ -1,8 +1,5 @@ -import vcs -import numpy -import cdtime - -from vcs_test_common import * +import numpy, cdtime, vcs +from testing.common import test_values_setting x=vcs.init() x.drawlogooff() diff --git a/testing/vcs/test_vcs_verify_proj_basics.py b/testing/vcs/test_vcs_verify_proj_basics.py index f1e1fa0a90..822a6fc0ba 100644 --- a/testing/vcs/test_vcs_verify_proj_basics.py +++ b/testing/vcs/test_vcs_verify_proj_basics.py @@ -1,9 +1,5 @@ - -import vcs -import numpy -import cdtime - -from vcs_test_common import * +import numpy, cdtime, vcs +from testing.common import test_values_setting x=vcs.init() x.drawlogooff() From a2ce6ac2f478aae2a184d4f618bbd3542325a1e1 Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Fri, 13 May 2016 08:01:52 -0400 Subject: [PATCH 04/14] Added testing to the modules to be built --- Packages/testing/regression.py | 2 ++ Packages/testing/setup.py | 3 +-- installation/control.py | 11 ++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Packages/testing/regression.py b/Packages/testing/regression.py index bcc0882021..b272d592fb 100644 --- a/Packages/testing/regression.py +++ b/Packages/testing/regression.py @@ -27,10 +27,12 @@ def init(): return vcsinst def run(vcsinst, fname, baseline=sys.argv[1], threshold=defaultThreshold): + """Export plot to a png and exit after comparsion.""" vcsinst.png(fname) sys.exit(check_result_image(fname, baseline, threshold)) def run_wo_terminate(vcsinst, fname, baseline=sys.argv[1], threshold=defaultThreshold): + """Export plot to a png and return comparison with baseline.""" vcsinst.png(fname) return check_result_image(fname, baseline, threshold) diff --git a/Packages/testing/setup.py b/Packages/testing/setup.py index 70f790d7bf..85c270ed86 100755 --- a/Packages/testing/setup.py +++ b/Packages/testing/setup.py @@ -9,6 +9,5 @@ description="Testing infrastructure for cdat", url="http://uvcdat.llnl.gov", packages=['testing'], - package_dir={'testing': 'testing',}, - install_requires=['numpy','vcs', 'vtk'], + package_dir = {'testing': '', } ) diff --git a/installation/control.py b/installation/control.py index 7a3a520919..49ed5d9af6 100644 --- a/installation/control.py +++ b/installation/control.py @@ -1,7 +1,7 @@ # This file is used to control the behavior of install.py. # The search path is used if the X11 directories aren't configured. -x11search = ['/usr/X11R6', '/usr/X11R6.5.1', +x11search = ['/usr/X11R6', '/usr/X11R6.5.1', '/usr/X11R6.4','/usr','/usr/openwin','/opt'] # Here is where they are on OSF1 and perhaps similar systems x11OSF1lib = ['/usr/lib/X11', '/usr/lib'] @@ -48,14 +48,14 @@ make_code = 'make' # List of packages to be built -packages = [ +packages = [ "Packages/pydebug", "Packages/cdtime", "Packages/demo", "Packages/help", "Packages/regrid2", - "Packages/cdms2", - "Packages/esg", + "Packages/cdms2", + "Packages/esg", "Packages/ncml", "Packages/DV3D", "Packages/vcs", @@ -63,9 +63,10 @@ "Packages/cdutil", "Packages/unidata", "Packages/xmgrace", - "Packages/genutil", + "Packages/genutil", "Packages/Thermo", "Packages/WK", "Packages/gui_support", "Packages/distarray", + "Packages/testing", ] From 2dbbdec142265dc8199f3d990201ad660c551392 Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Tue, 17 May 2016 16:34:12 -0400 Subject: [PATCH 05/14] Fixed vtk ui tests --- testing/vcs/vtk_ui/vtk_ui_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/vcs/vtk_ui/vtk_ui_test.py b/testing/vcs/vtk_ui/vtk_ui_test.py index 40bbeaef1e..d5cbe18bfc 100644 --- a/testing/vcs/vtk_ui/vtk_ui_test.py +++ b/testing/vcs/vtk_ui/vtk_ui_test.py @@ -1,4 +1,4 @@ -import, os, sys, time, vcs.vtk_ui, vtk +import os, sys, time, vtk, vcs.vtk_ui def init(): @@ -102,7 +102,7 @@ def check_image(self, compare_against): generate_png(self.win, self.test_file) pth = os.path.join(os.path.dirname(__file__), "../..") sys.path.append(pth) - import regression + import testing.regression as regression return regression.check_result_image(self.test_file, compare_against) def test(self): From 29d182bd5442ea6b71f95f9856d6ec9a9983a6ac Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Wed, 18 May 2016 07:31:37 -0400 Subject: [PATCH 06/14] Updated test name to match the naming convention --- testing/vcs/test_vcs_boxfill_lev1_lev2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/vcs/test_vcs_boxfill_lev1_lev2.py b/testing/vcs/test_vcs_boxfill_lev1_lev2.py index c5b5cbcbee..6c1d985d7d 100644 --- a/testing/vcs/test_vcs_boxfill_lev1_lev2.py +++ b/testing/vcs/test_vcs_boxfill_lev1_lev2.py @@ -7,4 +7,4 @@ b.level_1 = .5 b.level_2 = 14.5 x.plot(s, b, bg=1) -regression.run(x, "test_boxfill_lev1_lev2.png") +regression.run(x, "test_vcs_boxfill_lev1_lev2.png") From 88df13b95b1a5000db8d5e58c9c3152865dc5baa Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Wed, 18 May 2016 09:57:38 -0400 Subject: [PATCH 07/14] Updated dv3d package to use regression module --- testing/dv3d/TestManager.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testing/dv3d/TestManager.py b/testing/dv3d/TestManager.py index 51ed57183a..94e7e365ed 100644 --- a/testing/dv3d/TestManager.py +++ b/testing/dv3d/TestManager.py @@ -10,7 +10,7 @@ TestingDir=os.path.dirname(__file__) pth = os.path.join(TestingDir,"..") sys.path.append(pth) -import checkimage +import testing.regression as regression DefaultSampleFile = "geos5-sample.nc" DefaultSampleVar = "uwnd" @@ -128,8 +128,8 @@ def test( self, interactive=False ): test_image = '.'.join( [ self.name, 'test', 'png' ] ) self.canvas.png( test_image, width = 900, height = 600 ) - ret = checkimage.check_result_image( test_image, self.image_name,\ - checkimage.defaultThreshold+3. ) + ret = regression.check_result_image( test_image, self.image_name,\ + regression.defaultThreshold+3. ) if interactive: print "Type to continue and update ref image ( type 'n' to skip update )." From 9e86fb3b9be60ea6e08558034a56c2a22bc2c9db Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Wed, 18 May 2016 09:59:10 -0400 Subject: [PATCH 08/14] Fixed flake8 test --- Packages/vcs/vcs/Canvas.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Packages/vcs/vcs/Canvas.py b/Packages/vcs/vcs/Canvas.py index 49fdbf978e..0e9d234265 100644 --- a/Packages/vcs/vcs/Canvas.py +++ b/Packages/vcs/vcs/Canvas.py @@ -76,6 +76,7 @@ # Python < 3 DeprecationWarning ignored by default warnings.simplefilter('default') + class SIGNAL(object): def __init__(self, name=None): From dc508774b3b0d886a7908213c73f8ac21b64a55d Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Wed, 18 May 2016 10:01:36 -0400 Subject: [PATCH 09/14] Updated esmf test to use regression module --- .../regrid/testEsmfRegridPeriodictyRegional.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/testing/regrid/testEsmfRegridPeriodictyRegional.py b/testing/regrid/testEsmfRegridPeriodictyRegional.py index 2b92795255..53a1a706b1 100644 --- a/testing/regrid/testEsmfRegridPeriodictyRegional.py +++ b/testing/regrid/testEsmfRegridPeriodictyRegional.py @@ -1,9 +1,4 @@ -import vcs,cdms2 -import os,sys -import EzTemplate -pth = os.path.join(os.path.dirname(__file__),"..") -sys.path.append(pth) -import checkimage +import os, sys, vcs, cdms2, EzTemplate, testing.regression as regression data = sys.argv[1] png = sys.argv[2] @@ -38,11 +33,7 @@ s_esmf_con = s.regrid(grid_dest,regridTool="esmf",regridMethod="conservative") s_esmf_lin.id = "ESMF Conservative" -x=vcs.init() -x.setantialiasing(0) -x.drawlogooff() -x.setbgoutputdimensions(1200,1091,units="pixels") - +x=regression.init() t=x.createtemplate() t.blank() t.data.priority=1 @@ -60,7 +51,5 @@ x.plot(s_regrid2,M.get(),gm,bg=1) x.plot(s_esmf_lin,M.get(),gm,bg=1) x.plot(s_esmf_con,M.get(),gm,bg=1) -x.png("esmf_issue_1125") -ret = checkimage.check_result_image("esmf_issue_1125.png",png,checkimage.defaultThreshold) -sys.exit(ret) +ret = regression.run(x, "esmf_issue_1125.png", png) From 395c7459b2a3915c0c7a6eb4f37561ad9af972b8 Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Wed, 18 May 2016 10:10:53 -0400 Subject: [PATCH 10/14] Updated diagnostics tests to use regression module --- testing/metrics/diags_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testing/metrics/diags_test.py b/testing/metrics/diags_test.py index ff71c8d66a..2d4131cb80 100755 --- a/testing/metrics/diags_test.py +++ b/testing/metrics/diags_test.py @@ -12,7 +12,7 @@ import cdms2, numpy pth = os.path.join(os.path.dirname(__file__),"..") sys.path.append(pth) -import checkimage +import testing.regression as regression import argparse, pdb class DiagTest(object): @@ -95,7 +95,7 @@ def closeness( self, varname, filename, rtol, atol ): def execute(self, test_str, imagefilename, imagethreshold, ncfiles, rtol, atol): print test_str if imagethreshold is None: # user didn't specify a value - imagethreshold = checkimage.defaultThreshold + imagethreshold = regression.defaultThreshold # Silence annoying messages about how to set the NetCDF file type. Anything will do. cdms2.setNetcdfShuffleFlag(0) cdms2.setNetcdfDeflateFlag(0) @@ -118,7 +118,7 @@ def execute(self, test_str, imagefilename, imagethreshold, ncfiles, rtol, atol): imagebaselinefname = os.path.join( self.baselinepath, imagefilename ) #pdb.set_trace() print "OK THRESHOLD IS:",imagethreshold - graphics_result = checkimage.check_result_image( imagefname, imagebaselinefname, imagethreshold ) + graphics_result = regression.check_result_image( imagefname, imagebaselinefname, imagethreshold ) print "Graphics file", imagefname, "match difference:", graphics_result #initialize to successful graphics check From 314fc2bf70fb9c410ba7c1200a1fcaec9dfbfdd5 Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Wed, 18 May 2016 11:53:42 -0400 Subject: [PATCH 11/14] Fixed numpy test --- testing/vcs/test_vcs_boxfill_10x10_numpy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/vcs/test_vcs_boxfill_10x10_numpy.py b/testing/vcs/test_vcs_boxfill_10x10_numpy.py index a45aa5889d..765917942d 100644 --- a/testing/vcs/test_vcs_boxfill_10x10_numpy.py +++ b/testing/vcs/test_vcs_boxfill_10x10_numpy.py @@ -3,5 +3,5 @@ s = numpy.sin(numpy.arange(100)) s = numpy.reshape(s,(10,10)) x = regression.init() -x.plot(s) +x.plot(s, bg=1) regression.run(x, "test_vcs_boxfill_10x10_numpy.png") \ No newline at end of file From f19b372e0ccc187eef150f1ce7af83a56021616b Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Wed, 18 May 2016 11:59:38 -0400 Subject: [PATCH 12/14] Fixed canvas update test --- testing/vcs/test_vcs_boxfill_decreasing_latitude.py | 2 +- testing/vcs/test_vcs_canvas_background_update.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/vcs/test_vcs_boxfill_decreasing_latitude.py b/testing/vcs/test_vcs_boxfill_decreasing_latitude.py index 1f727e3b56..6cbc0f0163 100755 --- a/testing/vcs/test_vcs_boxfill_decreasing_latitude.py +++ b/testing/vcs/test_vcs_boxfill_decreasing_latitude.py @@ -51,5 +51,5 @@ gm.datawc_y2 = 30 gm.datawc_y1 = 90 -x.plot(ice, gm, tmpl, bg = 1) +x.plot(ice, gm, tmpl, bg=1) regression.run(x, "test_boxfill_decreasing_latitude.png") \ No newline at end of file diff --git a/testing/vcs/test_vcs_canvas_background_update.py b/testing/vcs/test_vcs_canvas_background_update.py index a28c087137..80f79d2aa9 100644 --- a/testing/vcs/test_vcs_canvas_background_update.py +++ b/testing/vcs/test_vcs_canvas_background_update.py @@ -5,4 +5,4 @@ x.open() x.backgroundcolor = (255, 255, 0) x.update() -regression.run(x, "test_backgroundcolor_yellow.png") \ No newline at end of file +regression.check_result_image(x, "test_backgroundcolor_yellow.png") \ No newline at end of file From a14200869100199487b89ea08dd37ad2b7d97731 Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Wed, 18 May 2016 16:06:31 -0400 Subject: [PATCH 13/14] Using a fixed size for click test --- Packages/testing/regression.py | 8 +++++--- testing/vcs/test_vcs_click_info.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Packages/testing/regression.py b/Packages/testing/regression.py index b272d592fb..68ded76d9f 100644 --- a/Packages/testing/regression.py +++ b/Packages/testing/regression.py @@ -16,14 +16,16 @@ defaultThreshold=10.0 -def init(): +def init(*args, **kwargs): testingDir = os.path.join(os.path.dirname(__file__), "..") sys.path.append(testingDir) - vcsinst = vcs.init() + vcsinst = vcs.init(*args, **kwargs) vcsinst.setantialiasing(0) vcsinst.drawlogooff() - vcsinst.setbgoutputdimensions(1200,1091,units="pixels") + + if ('bg' in kwargs and kwargs['bg']) or ('bg' not in kwargs): + vcsinst.setbgoutputdimensions(1200, 1091, units="pixels") return vcsinst def run(vcsinst, fname, baseline=sys.argv[1], threshold=defaultThreshold): diff --git a/testing/vcs/test_vcs_click_info.py b/testing/vcs/test_vcs_click_info.py index c16a6c0d4c..f37ee651a7 100644 --- a/testing/vcs/test_vcs_click_info.py +++ b/testing/vcs/test_vcs_click_info.py @@ -8,7 +8,7 @@ # Tests if the info produced when clicking on a map is correct. src = sys.argv[1] plot = sys.argv[2] -x = regression.init() +x = regression.init(bg=False, geometry=(800, 600)) # data f = cdms2.open(vcs.sample_data + "/" + testConfig[plot][0]) From 9c121a20f2121a0fcca665123d50b27553f176a0 Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Wed, 18 May 2016 21:19:46 -0400 Subject: [PATCH 14/14] Fixed failing test because of incorrect capture window size --- testing/vcs/test_vcs_configurator_resize.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/testing/vcs/test_vcs_configurator_resize.py b/testing/vcs/test_vcs_configurator_resize.py index 7692e6218c..bd3490afbd 100644 --- a/testing/vcs/test_vcs_configurator_resize.py +++ b/testing/vcs/test_vcs_configurator_resize.py @@ -4,15 +4,16 @@ x.open() x.configure() -x.backend.renWin.SetSize(814, 303) - fnm = "test_vcs_configurator_resize.png" win = x.backend.renWin -win.Render() +win.SetSize(814, 303) + out_filter = vtk.vtkWindowToImageFilter() out_filter.SetInput(win) +win.Render() + png_writer = vtk.vtkPNGWriter() png_writer.SetFileName(fnm) png_writer.SetInputConnection(out_filter.GetOutputPort())