Skip to content

Commit 5dd0a94

Browse files
committed
Using common module for regression testing
1 parent 11fc132 commit 5dd0a94

File tree

124 files changed

+589
-2135
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+589
-2135
lines changed

Packages/testing/__init__.py

Whitespace-only changes.
Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,28 @@
1212
import re
1313
import sys
1414
import logging
15+
import vcs
1516

1617
defaultThreshold=10.0
1718

19+
def init():
20+
testingDir = os.path.join(os.path.dirname(__file__), "..")
21+
sys.path.append(testingDir)
22+
23+
vcsinst = vcs.init()
24+
vcsinst.setantialiasing(0)
25+
vcsinst.drawlogooff()
26+
vcsinst.setbgoutputdimensions(1200,1091,units="pixels")
27+
return vcsinst
28+
29+
def run(vcsinst, fname, baseline=sys.argv[1], threshold=defaultThreshold):
30+
vcsinst.png(fname)
31+
sys.exit(check_result_image(fname, baseline, threshold))
32+
33+
def run_wo_terminate(vcsinst, fname, baseline=sys.argv[1], threshold=defaultThreshold):
34+
vcsinst.png(fname)
35+
return check_result_image(fname, baseline, threshold)
36+
1837
def image_compare(testImage, baselineImage):
1938
imageDiff = vtk.vtkImageDifference()
2039
imageDiff.SetInputData(testImage)
@@ -53,8 +72,8 @@ def find_alternates(fname):
5372
results.append(os.path.join(dirname, i))
5473
return results
5574

56-
def check_result_image(fname, baselinefname, threshold = defaultThreshold,
57-
baseline = True, cleanup=True):
75+
def check_result_image(fname, baselinefname=sys.argv[1], threshold=defaultThreshold,
76+
baseline=True, cleanup=True):
5877
testImage = image_from_file(fname)
5978
if testImage is None:
6079
print "Testing image missing, test failed."

Packages/testing/setup.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import os, sys
2+
from distutils.core import setup
3+
import cdat_info
4+
5+
sys.path.append(os.environ.get('BUILD_DIR',"build"))
6+
7+
setup(name="testing",
8+
version=cdat_info.Version,
9+
description="Testing infrastructure for cdat",
10+
url="http://uvcdat.llnl.gov",
11+
packages=['testing'],
12+
package_dir={'testing': 'testing',},
13+
install_requires=['numpy','vcs', 'vtk'],
14+
)

testing/vcs/test_vcs_1D_datawc.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
src=sys.argv[1]
55
pth = os.path.join(os.path.dirname(__file__),"..")
66
sys.path.append(pth)
7-
import checkimage
8-
x=vcs.init()
9-
x.setantialiasing(0)
10-
x.drawlogooff()
117

12-
x.setbgoutputdimensions(1200,1091,units="pixels")
8+
import testing.regression as regression
9+
10+
x = regression.init()
1311
yx =x.createyxvsx()
1412

15-
data = """-11.14902417 -9.17390922 -7.29515002
13+
data = """-11.14902417 -9.17390922 -7.29515002
1614
-7.51774549 -8.63608171
1715
-10.4827395 -9.93859485 -7.3394366 -5.39241468 -5.74825567
1816
-6.74967902 -7.09622319 -5.93836983 -4.04592997 -2.65591499
@@ -30,14 +28,9 @@
3028
data = MV2.array(data)
3129
yx.datawc_x1 = 0
3230
yx.datawc_x2 = 80
33-
yx.datawc_y1 =-12
34-
yx.datawc_y2 = 12
31+
yx.datawc_y1 =-12
32+
yx.datawc_y2 = 12
3533

3634

3735
x.plot(data,yx,bg=1)
38-
fnm = "test_vcs_1D_datawc.png"
39-
x.png(fnm)
40-
print "fnm:",fnm
41-
print "src:",src
42-
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
43-
sys.exit(ret)
36+
regression.run(x, "test_vcs_1D_datawc.png", src)
Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11

2-
import vcs,numpy,cdms2,MV2,os,sys
3-
src=sys.argv[1]
4-
pth = os.path.join(os.path.dirname(__file__),"..")
5-
sys.path.append(pth)
6-
import checkimage
2+
import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression
73

8-
x=vcs.init()
9-
x.setantialiasing(0)
10-
x.drawlogooff()
11-
x.setbgoutputdimensions(1200,1091,units="pixels")
12-
13-
yx =x.createyxvsx()
4+
x = regression.init()
5+
yx = x.createyxvsx()
146

157
data = """
16-
-999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999.
8+
-999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999.
179
0.059503571833625334
1810
0.059503571833625334 0.05664014775641405 0.05193557222118004
1911
0.04777129850801233 0.0407139313814465 0.029382624830271705
@@ -42,16 +34,5 @@
4234
""".split()
4335
data = numpy.array(data,dtype=numpy.float)
4436
data = MV2.masked_less(data,-900)
45-
#yx.datawc_x1 = 0
46-
#yx.datawc_x2 = 80
47-
##yx.datawc_y1 =-12
48-
#yx.datawc_y2 = 12
49-
50-
5137
x.plot(data,yx,bg=1)
52-
fnm = "test_vcs_1D_datawc_missing.png"
53-
x.png(fnm)
54-
print "fnm:",fnm
55-
print "src:",src
56-
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
57-
sys.exit(ret)
38+
regression.run(x, "test_vcs_1D_datawc_missing.png")
Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,9 @@
11

2-
import vcs,numpy,os,sys
3-
src=sys.argv[1]
4-
pth = os.path.join(os.path.dirname(__file__),"..")
5-
sys.path.append(pth)
6-
import checkimage
7-
8-
x=vcs.init()
9-
x.setantialiasing(0)
10-
x.drawlogooff()
11-
x.setbgoutputdimensions(1200,1091,units="pixels")
2+
import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression
123

4+
x = regression.init()
135
d = numpy.sin(numpy.arange(100))
14-
d=numpy.reshape(d,(10,10))
15-
16-
6+
d = numpy.reshape(d,(10,10))
177
one = x.create1d()
18-
198
x.plot(d,one,bg=1)
20-
21-
22-
fnm = "test_1D_with_manyDs.png"
23-
x.png(fnm)
24-
25-
print "fnm:",fnm
26-
print "src:",src
27-
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
28-
sys.exit(ret)
29-
30-
31-
9+
regression.run(x, "test_1D_with_manyDs.png", sys.argv[1])
Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,8 @@
11

2-
import vcs,numpy,os,sys
3-
src=sys.argv[1]
4-
pth = os.path.join(os.path.dirname(__file__),"..")
5-
sys.path.append(pth)
6-
import checkimage
7-
8-
x=vcs.init()
9-
x.setantialiasing(0)
10-
x.drawlogooff()
11-
x.setbgoutputdimensions(1200,1091,units="pixels")
2+
import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression
123

4+
x = regression.init()
135
d = numpy.sin(numpy.arange(100))
14-
156
b = x.createboxfill()
16-
177
x.plot(d,b,bg=1)
18-
19-
20-
fnm = "test_1d_in_boxfill.png"
21-
x.png(fnm)
22-
23-
print "fnm:",fnm
24-
print "src:",src
25-
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
26-
sys.exit(ret)
27-
28-
29-
8+
regression.run(x, "test_1d_in_boxfill.png", sys.argv[1])
Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,15 @@
1-
import vcs
2-
import numpy
3-
import MV2
4-
import cdms2
5-
import sys
6-
import os
71

8-
src=sys.argv[1]
9-
pth = os.path.join(os.path.dirname(__file__),"..")
10-
sys.path.append(pth)
11-
import checkimage
12-
13-
x=vcs.init()
14-
x.setantialiasing(0)
15-
x.drawlogooff()
16-
x.setbgoutputdimensions(1200,1091,units="pixels")
2+
import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression
173

4+
x = regression.init()
185
data = MV2.array([4,5,6,7,1,3,7,9,])+230.
19-
206
p = cdms2.createAxis([2,5,100,200,500,800,850,1000])
21-
227
data.setAxis(0,p)
23-
248
data.id="jim"
25-
269
gm=x.create1d()
27-
2810
gm.linewidth=0
2911
gm.datawc_x1=1000
3012
gm.datawc_x2=0
31-
3213
gm.markersize=30
33-
3414
x.plot(data,gm,bg=1)
35-
36-
fnm = "test_1d_marker_not_shown_if_xaxis_flipped.png"
37-
x.png(fnm)
38-
39-
print "fnm:",fnm
40-
print "src:",src
41-
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
42-
sys.exit(ret)
15+
regression.run(x, "test_1d_marker_not_shown_if_xaxis_flipped.png", sys.argv[1])

testing/vcs/test_vcs_1d_missing.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@
33
src=sys.argv[1]
44
pth = os.path.join(os.path.dirname(__file__),"..")
55
sys.path.append(pth)
6-
import checkimage
6+
import testing.regression as regression
77

8-
x=vcs.init()
9-
x.setantialiasing(0)
10-
x.drawlogooff()
11-
x.setbgoutputdimensions(1200,1091,units="pixels")
8+
x = regression.init()
129
yx =x.createyxvsx()
13-
14-
data = """-11.14902417 -9.17390922 -7.29515002
10+
data = """-11.14902417 -9.17390922 -7.29515002
1511
-7.51774549 -8.63608171
1612
-10.4827395 -9.93859485 -7.3394366 -5.39241468 -5.74825567
1713
-6.74967902 -7.09622319 -5.93836983 -4.04592997 -2.65591499
@@ -30,17 +26,5 @@
3026

3127
data=MV2.masked_where(MV2.logical_and(data>-4,data<-2),data)
3228

33-
#yx.datawc_x1 = 0
34-
#yx.datawc_x2 = 80
35-
##yx.datawc_y1 =-12
36-
#yx.datawc_y2 = 12
37-
38-
39-
x.plot(data,yx,bg=1)
40-
fnm = "test_vcs_1d_missing.png"
41-
x.png(fnm)
42-
43-
print "fnm:",fnm
44-
print "src:",src
45-
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
46-
sys.exit(ret)
29+
x.plot(data, yx, bg=1)
30+
regression.run(x, "test_vcs_1d_missing.png", src)

testing/vcs/test_vcs_animate_boxfill.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1-
import vcs
2-
import cdms2
3-
import os
4-
import sys
5-
import time
1+
import vcs, numpy, cdms2, MV2, os, sys, time, testing.regression as regression
2+
63
pth = os.path.join(os.path.dirname(__file__),"..")
74
sys.path.append(pth)
8-
import checkimage
9-
105
f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
116
s=f("clt",slice(0,12)) # read only 12 times steps to speed up things
127

13-
x=vcs.init()
8+
x = regression.init()
149
x.setantialiasing(0)
1510
x.drawlogooff()
1611
x.setbgoutputdimensions(1200,1091,units="pixels")
17-
1812
gm=x.createboxfill()
1913
x.plot(s,gm,bg=1)
2014
x.animate.create()
@@ -26,8 +20,7 @@
2620
pth = os.path.join(src_pth,prefix)
2721
ret = 0
2822
for p in pngs:
29-
print "Checking:",p
30-
ret += checkimage.check_result_image(p,os.path.join(pth,os.path.split(p)[1]),checkimage.defaultThreshold)
23+
ret += regression.check_result_image(p,os.path.join(pth,os.path.split(p)[1]))
3124
if ret == 0:
3225
os.removedirs(os.path.split(p)[0])
3326
os.remove("%s.mp4" % prefix)

0 commit comments

Comments
 (0)