/[escript]/trunk/dudley/test/python/run_escriptOnDudley.py
ViewVC logotype

Contents of /trunk/dudley/test/python/run_escriptOnDudley.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4984 - (show annotations)
Mon Jun 2 02:50:34 2014 UTC (5 years, 2 months ago) by sshaw
File MIME type: text/x-python
File size: 7294 byte(s)
revamping testrunners, now uses automated discovery and allows running specific tests without modifying files (see escriptcore/py_src/testing.py for more info/examples)

1
2 ##############################################################################
3 #
4 # Copyright (c) 2003-2014 by University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Open Software License version 3.0
9 # http://www.opensource.org/licenses/osl-3.0.php
10 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development 2012-2013 by School of Earth Sciences
13 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 #
15 ##############################################################################
16
17 __copyright__="""Copyright (c) 2003-2014 by University of Queensland
18 http://www.uq.edu.au
19 Primary Business: Queensland, Australia"""
20 __license__="""Licensed under the Open Software License version 3.0
21 http://www.opensource.org/licenses/osl-3.0.php"""
22 __url__="https://launchpad.net/escript-finley"
23
24 import os
25 import sys
26 import esys.escriptcore.utestselect as unittest
27 from esys.escriptcore.testing import *
28 from esys.escript import *
29 from esys.dudley import Rectangle, Brick
30 from test_objects import Test_Dump, Test_SetDataPointValue, Test_saveCSV, \
31 Test_TableInterpolation, Test_Domain, Test_GlobalMinMax, Test_Lazy
32 from test_shared import Test_Shared
33
34 try:
35 DUDLEY_WORKDIR=os.environ['DUDLEY_WORKDIR']
36 except KeyError:
37 DUDLEY_WORKDIR='.'
38
39 NE=4 # number elements, must be even
40
41 class Test_SharedOnDudley(Test_Shared):
42 def setUp(self):
43 self.domain=Rectangle(NE,NE)
44 self.tol=0.001
45 def tearDown(self):
46 del self.domain
47 del self.tol
48
49 @unittest.skip("Test not previously tested")
50 class Test_DomainOnDudley(Test_Domain):
51 def setUp(self):
52 self.boundary_tag_list = [1, 2, 10, 20]
53 self.domain =Rectangle(NE,NE+1,2)
54 self.rdomain=self.domain
55
56 def tearDown(self):
57 del self.domain
58 del self.rdomain
59 del self.boundary_tag_list
60
61 def test_setXError(self):
62 domain=Rectangle(NE,NE)
63 x=domain.getX()
64 z=interpolate(x, Function(domain))
65 self.assertRaises(RuntimeError, domain.setX, z)
66 del x
67 del z
68 del domain
69
70 def test_tagsContinuousFunction(self):
71 ref_tags=[0]
72 tags=ContinuousFunction(self.domain).getListOfTags()
73 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
74 for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
75
76 def test_tagsFunction(self):
77 ref_tags=[0]
78 tags=Function(self.domain).getListOfTags()
79 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
80 for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
81
82 def test_tagsReducedFunction(self):
83 ref_tags=[0]
84 tags=ReducedFunction(self.domain).getListOfTags()
85 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
86 for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
87
88 def test_tagsFunctionOnBoundary(self):
89 ref_tags=[1, 2, 10, 20]
90 tags=FunctionOnBoundary(self.domain).getListOfTags()
91 # For an MPI-distributed domain some tags may be missing
92 if getMPISizeWorld() == 1: self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
93 for i in tags: self.assertTrue(i in ref_tags,"tag %s is missing."%i)
94
95 def test_tagsReducedFunctionOnBoundary(self):
96 ref_tags=[1, 2, 10, 20]
97 tags=ReducedFunctionOnBoundary(self.domain).getListOfTags()
98 # For an MPI-distributed domain some tags may be missing
99 if getMPISizeWorld() == 1: self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
100 for i in tags: self.assertTrue(i in ref_tags,"tag %s is missing."%i)
101
102 @unittest.skip("Test not previously tested")
103 class Test_DataOpsOnDudley(Test_Dump, Test_SetDataPointValue, Test_GlobalMinMax, Test_Lazy):
104 def setUp(self):
105 self.domain =Rectangle(NE,NE+1,2)
106 self.domain_with_different_number_of_samples =Rectangle(2*NE,NE+1,2)
107 self.domain_with_different_number_of_data_points_per_sample =Rectangle(2*NE,NE+1,2,integrationOrder=2)
108 self.domain_with_different_sample_ordering =Rectangle(NE,NE+1,2, optimize=True)
109 self.filename_base=DUDLEY_WORKDIR
110 self.mainfs=Function(self.domain)
111 self.otherfs=Solution(self.domain)
112
113 def tearDown(self):
114 del self.domain
115 del self.domain_with_different_number_of_samples
116 del self.domain_with_different_number_of_data_points_per_sample
117 del self.domain_with_different_sample_ordering
118 del self.mainfs
119 del self.otherfs
120
121
122 class Test_TableInterpolationOnDudley(Test_TableInterpolation):
123 def setUp(self):
124 self.domain=Brick(4,4,4)
125 self.functionspaces=[ContinuousFunction(self.domain), Function(self.domain), ReducedFunction(self.domain),
126 FunctionOnBoundary(self.domain), ReducedFunctionOnBoundary(self.domain)]
127 #We aren't testing DiracDeltaFunctions
128 self.xn=5 # number of grids on x axis
129 self.yn=5 # number of grids on y axis
130 self.zn=5
131
132 def tearDown(self):
133 del self.domain
134 del self.functionspaces
135
136
137 class Test_CSVOnDudley(Test_saveCSV):
138 def setUp(self):
139 NE0=NE
140 NE1=NE+1
141 self.domain=Rectangle(NE0,NE1)
142 self.functionspaces=[ContinuousFunction, ReducedContinuousFunction]
143 # number of total data points for each function space
144 self.linecounts=[ (NE0+1)*(NE1+1)+1, (NE0+1)*(NE1+1)+1 ]
145 # number of masked points, i.e. where X[0] is non-zero
146 self.linecounts_masked=[ NE0*(NE1+1)+1, NE0*(NE1+1)+1 ]
147 # expected values in first line of masked data = [ X[:], X[0] ]
148 self.firstline=[ [1./NE0, 0., 1./NE0], [1./NE0, 0., 1./NE0] ]
149
150 if getMPISizeWorld() == 1:
151 self.functionspaces += [ Function, ReducedFunction,
152 FunctionOnBoundary, ReducedFunctionOnBoundary ]
153 self.linecounts += [ 121, 41, 37, 19 ]
154 self.linecounts_masked += [ 116, 41, 27, 14 ]
155 self.firstline += [
156 [.125, 0., .125],
157 [.16666666666666667, .0666666666666667, .166666666666667],
158 [.05283121635129676, 0., .05283121635129676],
159 [.125, 0., .125]
160 ]
161 else:
162 print("Skipping some CSV tests on dudley since MPI size > 1")
163
164 def tearDown(self):
165 del self.domain
166
167 #@unittest.skipIf(getMPISizeWorld() > 1, "Skipping since MPI size > 1")
168 def test_csv_multiFS(self):
169 fname=os.path.join(DUDLEY_WORKDIR, "test_multifs.csv")
170 sol=Data(8,Solution(self.domain))
171 ctsfn=Data(9,ContinuousFunction(self.domain))
172 #test line 0
173 dirac=Data(-1,DiracDeltaFunctions(self.domain))
174 saveDataCSV(fname, A=sol, B=ctsfn, C=dirac)
175 #test line 1
176 fun=Data(5,Function(self.domain))
177 rfun=Data(3,ReducedFunction(self.domain))
178 saveDataCSV(fname, A=sol,B=ctsfn,C=fun, D=rfun)
179 #test line 2
180 bound=Data(1,FunctionOnBoundary(self.domain))
181 rbound=Data(3,ReducedFunctionOnBoundary(self.domain))
182 saveDataCSV(fname,A=sol,B=ctsfn,C=bound, D=rbound)
183
184
185 if __name__ == '__main__':
186 run_tests(__name__, exit_on_failure=True)
187

Properties

Name Value
svn:mergeinfo /branches/lapack2681/finley/test/python/run_escriptOnFinley.py:2682-2741 /branches/pasowrap/dudley/test/python/run_escriptOnDudley.py:3661-3674 /branches/py3_attempt2/dudley/test/python/run_escriptOnDudley.py:3871-3891 /branches/restext/finley/test/python/run_escriptOnFinley.py:2610-2624 /branches/ripleygmg_from_3668/dudley/test/python/run_escriptOnDudley.py:3669-3791 /branches/stage3.0/finley/test/python/run_escriptOnFinley.py:2569-2590 /branches/symbolic_from_3470/dudley/test/python/run_escriptOnDudley.py:3471-3974 /branches/symbolic_from_3470/ripley/test/python/dudley/test/python/run_escriptOnDudley.py:3517-3974 /release/3.0/finley/test/python/run_escriptOnFinley.py:2591-2601 /trunk/ripley/test/python/dudley/test/python/run_escriptOnDudley.py:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26