/[escript]/trunk/escript/test/python/test_objects.py
ViewVC logotype

Contents of /trunk/escript/test/python/test_objects.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1044 - (show annotations)
Mon Mar 19 07:29:31 2007 UTC (12 years, 1 month ago) by gross
File MIME type: text/x-python
File size: 43120 byte(s)
clear name tagging is supported now.
1 # $Id:$
2 """
3 Test suite for data objects. at the moment for dump and load only.
4
5 The tests must be linked with some function space class object in the setUp method:
6 to run the use:
7
8 from esys.finley import Brick
9 class Test_DumpOnFinley(Test_Dump):
10 def setUp(self):
11 self.domain =Rectangle(NE,NE+1,2)
12 self.domain_with_different_number_of_samples =Rectangle(2*NE,NE+1,2)
13 self.domain_with_different_number_of_data_points_per_sample =Rectangle(2*NE,NE+1,2,integrationOrder=2)
14 self.domain_with_different_sample_ordering =Rectangle(1,(NE+1)*NE,2)
15 self.filebase="."
16
17 suite = unittest.TestSuite()
18 suite.addTest(unittest.makeSuite(Test_DumpOnFinley))
19 unittest.TextTestRunner(verbosity=2).run(suite)
20
21 @var __author__: name of author
22 @var __copyright__: copyrights
23 @var __license__: licence agreement
24 @var __url__: url entry point on documentation
25 @var __version__: version
26 @var __date__: date of the version
27 """
28
29 __author__="Lutz Gross, l.gross@uq.edu.au"
30 __copyright__=""" Copyright (c) 2006, 2007 by ACcESS MNRF
31 http://www.access.edu.au
32 Primary Business: Queensland, Australia"""
33 __license__="""Licensed under the Open Software License version 3.0
34 http://www.opensource.org/licenses/osl-3.0.php"""
35 __url__="http://www.iservo.edu.au/esys/escript"
36 __version__="$Revision:$"
37 __date__="$Date:$"
38
39 import unittest
40 import os
41 import numarray
42 from esys.escript import *
43
44 class Test_Domain(unittest.TestCase):
45 def test_addTags(self):
46 tag1="A"
47 tag2="B"
48 tag3="C"
49 self.domain.setTagMap(tag1,1)
50 self.failUnless(self.domain.isValidTagName(tag1))
51 self.failUnless(not self.domain.isValidTagName(tag2))
52 self.domain.setTagMap(tag2,2)
53 self.failUnless(self.domain.isValidTagName(tag1))
54 self.failUnless(self.domain.isValidTagName(tag2))
55 self.failUnless(not self.domain.isValidTagName(tag3))
56 self.failUnless(self.domain.getTag(tag1)==1)
57 self.failUnless(self.domain.getTag(tag2)==2)
58 self.failUnlessRaises(RuntimeError,self.domain.getTag,tag3)
59
60 # set tag:
61 s=Scalar(0,Function(self.domain))
62 r=Scalar(0,Function(self.domain))
63 s.setTaggedValue(tag1,1.)
64 r.setTaggedValue(1,1.)
65 s.setTaggedValue(tag2,2.)
66 r.setTaggedValue(2,2.)
67 s.setTaggedValue(tag3,3.)
68 self.failUnless(Lsup(s-r)<=0.)
69 # get tag:
70 names=getTagNames(self.domain)
71 self.failUnless(len(names) == 2)
72 self.failUnless( tag1 in names )
73 self.failUnless( tag2 in names )
74 self.failUnless(self.domain.isValidTagName(tag1))
75 self.failUnless(self.domain.isValidTagName(tag2))
76 # insert tag shortcut:
77 s2=insertTaggedValues(Scalar(0,Function(self.domain)),**{ tag1 : 1., tag2 : 2.})
78 self.failUnless(Lsup(s2-r)<=0.)
79
80
81
82 class Test_Dump(unittest.TestCase):
83 arg0=9.81
84 arg1=numarray.array([3.098, -3.111])
85 arg2=numarray.array([[3.82, -3.81, -0.957, 0.892, -1.367], [-4.589, -1.835, -2.679, -1.517, -4.2515], [-4.909, 1.634, -2.883, -2.135, 1.187], [0.6431, 4.638, -4.616, -0.196, -4.370]])
86 arg3=numarray.array([[[-2.3667, -0.040], [-4.7398, -3.2412]], [[-2.125, -2.240], [2.237, -4.279]], [[0.68720, 2.4059], [-2.4964, 3.17453]], [[-4.907, -4.9431], [-0.3604, 0.4269]], [[1.4179, 3.326], [1.356, -0.4610]], [[3.378, 2.0902], [-2.6857, 1.3585]]])
87 arg4=numarray.array([[[[-3.810, -1.3597, -1.5307, 1.099], [-1.828, 0.2526, -1.4429, 2.326], [4.9732, -2.063, 1.3153, -3.809]], [[-4.8902, -4.714, 1.520, -1.931], [-3.8847, 4.3867, 1.894030, 2.432], [-1.2082, -0.8304, 2.2612, 4.6399]]], [[[-4.5922, -3.309, -0.8171, -0.7210], [2.8051, -4.93047, 0.08450, 4.3824], [0.43204, 2.1908, 4.512633, -1.8218]], [[2.2493, -4.190, -2.3893, -4.147], [-2.104, -4.635, -4.2767, -3.53151], [-2.351, -1.6614, 2.9385, 4.099]]], [[[1.710, 0.2235, -3.4917, 0.8713], [-0.2881, 4.6278, 3.603, -2.1211], [-0.565, 4.294, -2.210827, -0.37651]], [[0.6578, -2.869, -2.490, -4.789], [3.232, 2.483, 0.9531, 2.260], [-1.785, 0.42156, -1.8379, 4.212]]]])
88
89 def _diffDataObjects(self,d_ref,file):
90 d_ref.dump(file)
91 d=load(file, self.domain)
92 self.failUnless(not d.isEmpty(),"data in %s are empty."%file)
93 self.failUnless(d_ref.getFunctionSpace() == d.getFunctionSpace(), "wrong function space in %s."%file)
94 self.failUnless(d_ref.getRank() == d.getRank(), "different rank in %s. "%file)
95 self.failUnless(d_ref.getShape() == d.getShape(), "different shape %s. "%file)
96 self.failUnless(Lsup(d_ref-d)<=0., "different entries %s."%file)
97
98 #===========================================================================
99 def test_DumpAndLoad_Constant_Solution_Rank0(self):
100 if loadIsConfigured():
101 file=os.path.join(self.filebase,"constant_solution_rank0.nc")
102 d=Data(self.arg0,Solution(self.domain))
103 self._diffDataObjects(d,file)
104
105 def test_DumpAndLoad_Constant_Solution_Rank1(self):
106 if loadIsConfigured():
107 file=os.path.join(self.filebase,"constant_solution_rank1.nc")
108 d=Data(self.arg1,Solution(self.domain))
109 self._diffDataObjects(d,file)
110
111 def test_DumpAndLoad_Constant_Solution_Rank2(self):
112 if loadIsConfigured():
113 file=os.path.join(self.filebase,"constant_solution_rank2.nc")
114 d=Data(self.arg2,Solution(self.domain))
115 self._diffDataObjects(d,file)
116
117 def test_DumpAndLoad_Constant_Solution_Rank3(self):
118 if loadIsConfigured():
119 file=os.path.join(self.filebase,"constant_solution_rank3.nc")
120 d=Data(self.arg3,Solution(self.domain))
121 self._diffDataObjects(d,file)
122
123 def test_DumpAndLoad_Constant_Solution_Rank4(self):
124 if loadIsConfigured():
125 file=os.path.join(self.filebase,"constant_solution_rank4.nc")
126 d=Data(self.arg4,Solution(self.domain))
127 self._diffDataObjects(d,file)
128 #===========================================================================
129 def test_DumpAndLoad_Constant_ReducedSolution_Rank0(self):
130 if loadIsConfigured():
131 file=os.path.join(self.filebase,"constant_reduced_solution_rank0.nc")
132 d=Data(self.arg0,ReducedSolution(self.domain))
133 self._diffDataObjects(d,file)
134
135 def test_DumpAndLoad_Constant_ReducedSolution_Rank1(self):
136 if loadIsConfigured():
137 file=os.path.join(self.filebase,"constant_reduced_solution_rank1.nc")
138 d=Data(self.arg1,ReducedSolution(self.domain))
139 self._diffDataObjects(d,file)
140
141 def test_DumpAndLoad_Constant_ReducedSolution_Rank2(self):
142 if loadIsConfigured():
143 file=os.path.join(self.filebase,"constant_reduced_solution_rank2.nc")
144 d=Data(self.arg2,ReducedSolution(self.domain))
145 self._diffDataObjects(d,file)
146
147 def test_DumpAndLoad_Constant_ReducedSolution_Rank3(self):
148 if loadIsConfigured():
149 file=os.path.join(self.filebase,"constant_reduced_solution_rank3.nc")
150 d=Data(self.arg3,ReducedSolution(self.domain))
151 self._diffDataObjects(d,file)
152
153 def test_DumpAndLoad_Constant_ReducedSolution_Rank4(self):
154 if loadIsConfigured():
155 file=os.path.join(self.filebase,"constant_reduced_solution_rank4.nc")
156 d=Data(self.arg4,ReducedSolution(self.domain))
157 self._diffDataObjects(d,file)
158 #===========================================================================
159 def test_DumpAndLoad_Constant_ContinuousFunction_Rank0(self):
160 if loadIsConfigured():
161 file=os.path.join(self.filebase,"constant_continuous_function_rank0.nc")
162 d=Data(self.arg0,ContinuousFunction(self.domain))
163 self._diffDataObjects(d,file)
164
165 def test_DumpAndLoad_Constant_ContinuousFunction_Rank1(self):
166 if loadIsConfigured():
167 file=os.path.join(self.filebase,"constant_continuous_function_rank1.nc")
168 d=Data(self.arg1,ContinuousFunction(self.domain))
169 self._diffDataObjects(d,file)
170
171 def test_DumpAndLoad_Constant_ContinuousFunction_Rank2(self):
172 if loadIsConfigured():
173 file=os.path.join(self.filebase,"constant_continuous_function_rank2.nc")
174 d=Data(self.arg2,ContinuousFunction(self.domain))
175 self._diffDataObjects(d,file)
176
177 def test_DumpAndLoad_Constant_ContinuousFunction_Rank3(self):
178 if loadIsConfigured():
179 file=os.path.join(self.filebase,"constant_continuous_function_rank3.nc")
180 d=Data(self.arg3,ContinuousFunction(self.domain))
181 self._diffDataObjects(d,file)
182
183 def test_DumpAndLoad_Constant_ContinuousFunction_Rank4(self):
184 if loadIsConfigured():
185 file=os.path.join(self.filebase,"constant_continuous_function_rank4.nc")
186 d=Data(self.arg4,ContinuousFunction(self.domain))
187 self._diffDataObjects(d,file)
188
189 #===========================================================================
190 def test_DumpAndLoad_Constant_Function_Rank0(self):
191 if loadIsConfigured():
192 file=os.path.join(self.filebase,"constant_function_rank0.nc")
193 d=Data(self.arg0,Function(self.domain))
194 self._diffDataObjects(d,file)
195
196 def test_DumpAndLoad_Constant_Function_Rank1(self):
197 if loadIsConfigured():
198 file=os.path.join(self.filebase,"constant_function_rank1.nc")
199 d=Data(self.arg1,Function(self.domain))
200 self._diffDataObjects(d,file)
201
202 def test_DumpAndLoad_Constant_Function_Rank2(self):
203 if loadIsConfigured():
204 file=os.path.join(self.filebase,"constant_function_rank2.nc")
205 d=Data(self.arg2,Function(self.domain))
206 self._diffDataObjects(d,file)
207
208 def test_DumpAndLoad_Constant_Function_Rank3(self):
209 if loadIsConfigured():
210 file=os.path.join(self.filebase,"constant_function_rank3.nc")
211 d=Data(self.arg3,Function(self.domain))
212 self._diffDataObjects(d,file)
213
214 def test_DumpAndLoad_Constant_Function_Rank4(self):
215 if loadIsConfigured():
216 file=os.path.join(self.filebase,"constant_function_rank4.nc")
217 d=Data(self.arg4,Function(self.domain))
218 self._diffDataObjects(d,file)
219
220 #===========================================================================
221 def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank0(self):
222 if loadIsConfigured():
223 file=os.path.join(self.filebase,"constant_function_on_boundary_rank0.nc")
224 d=Data(self.arg0,FunctionOnBoundary(self.domain))
225 self._diffDataObjects(d,file)
226
227 def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank1(self):
228 if loadIsConfigured():
229 file=os.path.join(self.filebase,"constant_function_on_boundary_rank1.nc")
230 d=Data(self.arg1,FunctionOnBoundary(self.domain))
231 self._diffDataObjects(d,file)
232
233 def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank2(self):
234 if loadIsConfigured():
235 file=os.path.join(self.filebase,"constant_function_on_boundary_rank2.nc")
236 d=Data(self.arg2,FunctionOnBoundary(self.domain))
237 self._diffDataObjects(d,file)
238
239 def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank3(self):
240 if loadIsConfigured():
241 file=os.path.join(self.filebase,"constant_function_on_boundary_rank3.nc")
242 d=Data(self.arg3,FunctionOnBoundary(self.domain))
243 self._diffDataObjects(d,file)
244
245 def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank4(self):
246 if loadIsConfigured():
247 file=os.path.join(self.filebase,"constant_function_on_boundary_rank4.nc")
248 d=Data(self.arg4,FunctionOnBoundary(self.domain))
249 self._diffDataObjects(d,file)
250
251 #===========================================================================
252 def test_DumpAndLoad_Expanded_Solution_Rank0(self):
253 if loadIsConfigured():
254 file=os.path.join(self.filebase,"expanded_solution_rank0.nc")
255 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
256 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
257 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
258 d=Data(length(Solution(self.domain).getX())*self.arg0,Solution(self.domain))
259 self._diffDataObjects(d,file)
260
261 def test_DumpAndLoad_Expanded_Solution_Rank1(self):
262 if loadIsConfigured():
263 file=os.path.join(self.filebase,"expanded_solution_rank1.nc")
264 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
265 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
266 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
267 d=Data(length(Solution(self.domain).getX())*self.arg1,Solution(self.domain))
268 self._diffDataObjects(d,file)
269
270 def test_DumpAndLoad_Expanded_Solution_Rank2(self):
271 if loadIsConfigured():
272 file=os.path.join(self.filebase,"expanded_solution_rank2.nc")
273 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
274 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
275 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
276 d=Data(length(Solution(self.domain).getX())*self.arg2,Solution(self.domain))
277 self._diffDataObjects(d,file)
278
279 def test_DumpAndLoad_Expanded_Solution_Rank3(self):
280 if loadIsConfigured():
281 file=os.path.join(self.filebase,"expanded_solution_rank3.nc")
282 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
283 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
284 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
285 d=Data(length(Solution(self.domain).getX())*self.arg3,Solution(self.domain))
286 self._diffDataObjects(d,file)
287
288 def test_DumpAndLoad_Expanded_Solution_Rank4(self):
289 if loadIsConfigured():
290 file=os.path.join(self.filebase,"expanded_solution_rank4.nc")
291 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
292 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
293 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
294 d=Data(length(Solution(self.domain).getX())*self.arg4,Solution(self.domain))
295 self._diffDataObjects(d,file)
296 #===========================================================================
297 def test_DumpAndLoad_Expanded_ReducedSolution_Rank0(self):
298 if loadIsConfigured():
299 file=os.path.join(self.filebase,"expanded_reduced_solution_rank0.nc")
300 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
301 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
302 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
303 d=Data(length(ReducedSolution(self.domain).getX())*self.arg0,ReducedSolution(self.domain))
304 self._diffDataObjects(d,file)
305
306 def test_DumpAndLoad_Expanded_ReducedSolution_Rank1(self):
307 if loadIsConfigured():
308 file=os.path.join(self.filebase,"expanded_reduced_solution_rank1.nc")
309 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
310 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
311 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
312 d=Data(length(ReducedSolution(self.domain).getX())*self.arg1,ReducedSolution(self.domain))
313 self._diffDataObjects(d,file)
314
315 def test_DumpAndLoad_Expanded_ReducedSolution_Rank2(self):
316 if loadIsConfigured():
317 file=os.path.join(self.filebase,"expanded_reduced_solution_rank2.nc")
318 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
319 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
320 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
321 d=Data(length(ReducedSolution(self.domain).getX())*self.arg2,ReducedSolution(self.domain))
322 self._diffDataObjects(d,file)
323
324 def test_DumpAndLoad_Expanded_ReducedSolution_Rank3(self):
325 if loadIsConfigured():
326 file=os.path.join(self.filebase,"expanded_reduced_solution_rank3.nc")
327 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
328 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
329 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
330 d=Data(length(ReducedSolution(self.domain).getX())*self.arg3,ReducedSolution(self.domain))
331 self._diffDataObjects(d,file)
332
333 def test_DumpAndLoad_Expanded_ReducedSolution_Rank4(self):
334 if loadIsConfigured():
335 file=os.path.join(self.filebase,"expanded_reduced_solution_rank4.nc")
336 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
337 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
338 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
339 d=Data(length(ReducedSolution(self.domain).getX())*self.arg4,ReducedSolution(self.domain))
340 self._diffDataObjects(d,file)
341 #===========================================================================
342 def test_DumpAndLoad_Expanded_ContinuousFunction_Rank0(self):
343 if loadIsConfigured():
344 file=os.path.join(self.filebase,"expanded_continuous_function_rank0.nc")
345 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
346 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
347 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
348 d=Data(length(ContinuousFunction(self.domain).getX())*self.arg0,ContinuousFunction(self.domain))
349 self._diffDataObjects(d,file)
350
351 def test_DumpAndLoad_Expanded_ContinuousFunction_Rank1(self):
352 if loadIsConfigured():
353 file=os.path.join(self.filebase,"expanded_continuous_function_rank1.nc")
354 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
355 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
356 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
357 d=Data(length(ContinuousFunction(self.domain).getX())*self.arg1,ContinuousFunction(self.domain))
358 self._diffDataObjects(d,file)
359
360 def test_DumpAndLoad_Expanded_ContinuousFunction_Rank2(self):
361 if loadIsConfigured():
362 file=os.path.join(self.filebase,"expanded_continuous_function_rank2.nc")
363 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
364 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
365 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
366 d=Data(length(ContinuousFunction(self.domain).getX())*self.arg2,ContinuousFunction(self.domain))
367 self._diffDataObjects(d,file)
368
369 def test_DumpAndLoad_Expanded_ContinuousFunction_Rank3(self):
370 if loadIsConfigured():
371 file=os.path.join(self.filebase,"expanded_continuous_function_rank3.nc")
372 d=Data(length(ContinuousFunction(self.domain).getX())*self.arg3,ContinuousFunction(self.domain))
373 self._diffDataObjects(d,file)
374
375 def test_DumpAndLoad_Expanded_ContinuousFunction_Rank4(self):
376 if loadIsConfigured():
377 file=os.path.join(self.filebase,"expanded_continuous_function_rank4.nc")
378 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
379 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
380 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
381 d=Data(length(ContinuousFunction(self.domain).getX())*self.arg4,ContinuousFunction(self.domain))
382 self._diffDataObjects(d,file)
383
384 #===========================================================================
385 def test_DumpAndLoad_Expanded_Function_Rank0(self):
386 if loadIsConfigured():
387 file=os.path.join(self.filebase,"expanded_function_rank0.nc")
388 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
389 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
390 # elements are not in different order: self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
391 d=Data(length(Function(self.domain).getX())*self.arg0,Function(self.domain))
392 self._diffDataObjects(d,file)
393
394 def test_DumpAndLoad_Expanded_Function_Rank1(self):
395 if loadIsConfigured():
396 file=os.path.join(self.filebase,"expanded_function_rank1.nc")
397 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
398 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
399 # elements are not in different order: self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
400 d=Data(length(Function(self.domain).getX())*self.arg1,Function(self.domain))
401 self._diffDataObjects(d,file)
402
403 def test_DumpAndLoad_Expanded_Function_Rank2(self):
404 if loadIsConfigured():
405 file=os.path.join(self.filebase,"expanded_function_rank2.nc")
406 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
407 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
408 # elements are not in different order: self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
409 d=Data(length(Function(self.domain).getX())*self.arg2,Function(self.domain))
410 self._diffDataObjects(d,file)
411
412 def test_DumpAndLoad_Expanded_Function_Rank3(self):
413 if loadIsConfigured():
414 file=os.path.join(self.filebase,"expanded_function_rank3.nc")
415 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
416 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
417 # elements are not in different order: self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
418 d=Data(length(Function(self.domain).getX())*self.arg3,Function(self.domain))
419 self._diffDataObjects(d,file)
420
421 def test_DumpAndLoad_Expanded_Function_Rank4(self):
422 if loadIsConfigured():
423 file=os.path.join(self.filebase,"expanded_function_rank4.nc")
424 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
425 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
426 # elements are not in different order: self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
427 d=Data(length(Function(self.domain).getX())*self.arg4,Function(self.domain))
428 self._diffDataObjects(d,file)
429
430 #===========================================================================
431 def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank0(self):
432 if loadIsConfigured():
433 file=os.path.join(self.filebase,"expanded_function_on_boundary_rank0.nc")
434 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
435 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
436 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
437 d=Data(length(FunctionOnBoundary(self.domain).getX())*self.arg0,FunctionOnBoundary(self.domain))
438 self._diffDataObjects(d,file)
439
440 def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank1(self):
441 if loadIsConfigured():
442 file=os.path.join(self.filebase,"expanded_function_on_boundary_rank1.nc")
443 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
444 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
445 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
446 d=Data(length(FunctionOnBoundary(self.domain).getX())*self.arg1,FunctionOnBoundary(self.domain))
447 self._diffDataObjects(d,file)
448
449 def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank2(self):
450 if loadIsConfigured():
451 file=os.path.join(self.filebase,"expanded_function_on_boundary_rank2.nc")
452 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
453 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
454 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
455 d=Data(length(FunctionOnBoundary(self.domain).getX())*self.arg2,FunctionOnBoundary(self.domain))
456 self._diffDataObjects(d,file)
457
458 def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank3(self):
459 if loadIsConfigured():
460 file=os.path.join(self.filebase,"expanded_function_on_boundary_rank3.nc")
461 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
462 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
463 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
464 d=Data(length(FunctionOnBoundary(self.domain).getX())*self.arg3,FunctionOnBoundary(self.domain))
465 self._diffDataObjects(d,file)
466
467 def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank4(self):
468 if loadIsConfigured():
469 file=os.path.join(self.filebase,"expanded_function_on_boundary_rank4.nc")
470 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples)
471 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample)
472 self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering)
473 d=Data(length(FunctionOnBoundary(self.domain).getX())*self.arg4,FunctionOnBoundary(self.domain))
474 self._diffDataObjects(d,file)
475
476 #===========================================================================
477 def test_DumpAndLoad_Tagged_Solution_Rank0(self):
478 if loadIsConfigured():
479 file=os.path.join(self.filebase,"tagged_solution_rank0.nc")
480 d=Data(self.arg0,Solution(self.domain))
481 d.setTaggedValue(1,self.arg0*2)
482 d.setTaggedValue(10,self.arg0*3)
483 d.setTaggedValue(100,self.arg0*4)
484 self._diffDataObjects(d,file)
485
486 def test_DumpAndLoad_Tagged_Solution_Rank1(self):
487 if loadIsConfigured():
488 file=os.path.join(self.filebase,"tagged_solution_rank1.nc")
489 d=Data(self.arg1,Solution(self.domain))
490 d.setTaggedValue(1,self.arg1*2)
491 d.setTaggedValue(10,self.arg1*3)
492 d.setTaggedValue(100,self.arg1*4)
493 self._diffDataObjects(d,file)
494
495 def test_DumpAndLoad_Tagged_Solution_Rank2(self):
496 if loadIsConfigured():
497 file=os.path.join(self.filebase,"tagged_solution_rank2.nc")
498 d=Data(self.arg2,Solution(self.domain))
499 d.setTaggedValue(1,self.arg2*2)
500 d.setTaggedValue(10,self.arg2*3)
501 d.setTaggedValue(100,self.arg2*4)
502 self._diffDataObjects(d,file)
503
504 def test_DumpAndLoad_Tagged_Solution_Rank3(self):
505 if loadIsConfigured():
506 file=os.path.join(self.filebase,"tagged_solution_rank3.nc")
507 d=Data(self.arg3,Solution(self.domain))
508 d.setTaggedValue(1,self.arg3*2)
509 d.setTaggedValue(10,self.arg3*3)
510 d.setTaggedValue(100,self.arg3*4)
511 self._diffDataObjects(d,file)
512
513 def test_DumpAndLoad_Tagged_Solution_Rank4(self):
514 if loadIsConfigured():
515 file=os.path.join(self.filebase,"tagged_solution_rank4.nc")
516 d=Data(self.arg4,Solution(self.domain))
517 d.setTaggedValue(1,self.arg4*2)
518 d.setTaggedValue(10,self.arg4*3)
519 d.setTaggedValue(100,self.arg4*4)
520 self._diffDataObjects(d,file)
521 #===========================================================================
522 def test_DumpAndLoad_Tagged_ReducedSolution_Rank0(self):
523 if loadIsConfigured():
524 file=os.path.join(self.filebase,"tagged_reduced_solution_rank0.nc")
525 d=Data(self.arg0,ReducedSolution(self.domain))
526 d.setTaggedValue(1,self.arg0*2)
527 d.setTaggedValue(10,self.arg0*3)
528 d.setTaggedValue(100,self.arg0*4)
529 self._diffDataObjects(d,file)
530
531 def test_DumpAndLoad_Tagged_ReducedSolution_Rank1(self):
532 if loadIsConfigured():
533 file=os.path.join(self.filebase,"tagged_reduced_solution_rank1.nc")
534 d=Data(self.arg1,ReducedSolution(self.domain))
535 d.setTaggedValue(1,self.arg1*2)
536 d.setTaggedValue(10,self.arg1*3)
537 d.setTaggedValue(100,self.arg1*4)
538 self._diffDataObjects(d,file)
539
540 def test_DumpAndLoad_Tagged_ReducedSolution_Rank2(self):
541 if loadIsConfigured():
542 file=os.path.join(self.filebase,"tagged_reduced_solution_rank2.nc")
543 d=Data(self.arg2,ReducedSolution(self.domain))
544 d.setTaggedValue(1,self.arg2*2)
545 d.setTaggedValue(10,self.arg2*3)
546 d.setTaggedValue(100,self.arg2*4)
547 self._diffDataObjects(d,file)
548
549 def test_DumpAndLoad_Tagged_ReducedSolution_Rank3(self):
550 if loadIsConfigured():
551 file=os.path.join(self.filebase,"tagged_reduced_solution_rank3.nc")
552 d=Data(self.arg3,ReducedSolution(self.domain))
553 d.setTaggedValue(1,self.arg3*2)
554 d.setTaggedValue(10,self.arg3*3)
555 d.setTaggedValue(100,self.arg3*4)
556 self._diffDataObjects(d,file)
557
558 def test_DumpAndLoad_Tagged_ReducedSolution_Rank4(self):
559 if loadIsConfigured():
560 file=os.path.join(self.filebase,"tagged_reduced_solution_rank4.nc")
561 d=Data(self.arg4,ReducedSolution(self.domain))
562 d.setTaggedValue(1,self.arg4*2)
563 d.setTaggedValue(10,self.arg4*3)
564 d.setTaggedValue(100,self.arg4*4)
565 self._diffDataObjects(d,file)
566 #===========================================================================
567 def test_DumpAndLoad_Tagged_ContinuousFunction_Rank0(self):
568 if loadIsConfigured():
569 file=os.path.join(self.filebase,"tagged_continuous_function_rank0.nc")
570 d=Data(self.arg0,ContinuousFunction(self.domain))
571 d.setTaggedValue(1,self.arg0*2)
572 d.setTaggedValue(10,self.arg0*3)
573 d.setTaggedValue(100,self.arg0*4)
574 self._diffDataObjects(d,file)
575
576 def test_DumpAndLoad_Tagged_ContinuousFunction_Rank1(self):
577 if loadIsConfigured():
578 file=os.path.join(self.filebase,"tagged_continuous_function_rank1.nc")
579 d=Data(self.arg1,ContinuousFunction(self.domain))
580 d.setTaggedValue(1,self.arg1*2)
581 d.setTaggedValue(10,self.arg1*3)
582 d.setTaggedValue(100,self.arg1*4)
583 self._diffDataObjects(d,file)
584
585 def test_DumpAndLoad_Tagged_ContinuousFunction_Rank2(self):
586 if loadIsConfigured():
587 file=os.path.join(self.filebase,"tagged_continuous_function_rank2.nc")
588 d=Data(self.arg2,ContinuousFunction(self.domain))
589 d.setTaggedValue(1,self.arg2*2)
590 d.setTaggedValue(10,self.arg2*3)
591 d.setTaggedValue(100,self.arg2*4)
592 self._diffDataObjects(d,file)
593
594 def test_DumpAndLoad_Tagged_ContinuousFunction_Rank3(self):
595 if loadIsConfigured():
596 file=os.path.join(self.filebase,"tagged_continuous_function_rank3.nc")
597 d=Data(self.arg3,ContinuousFunction(self.domain))
598 d.setTaggedValue(1,self.arg3*2)
599 d.setTaggedValue(10,self.arg3*3)
600 d.setTaggedValue(100,self.arg3*4)
601 self._diffDataObjects(d,file)
602
603 def test_DumpAndLoad_Tagged_ContinuousFunction_Rank4(self):
604 if loadIsConfigured():
605 file=os.path.join(self.filebase,"tagged_continuous_function_rank4.nc")
606 d=Data(self.arg4,ContinuousFunction(self.domain))
607 d.setTaggedValue(1,self.arg4*2)
608 d.setTaggedValue(10,self.arg4*3)
609 d.setTaggedValue(100,self.arg4*4)
610 self._diffDataObjects(d,file)
611
612 #===========================================================================
613 def test_DumpAndLoad_Tagged_Function_Rank0(self):
614 if loadIsConfigured():
615 file=os.path.join(self.filebase,"tagged_function_rank0.nc")
616 d=Data(self.arg0,Function(self.domain))
617 d.setTaggedValue(1,self.arg0*2)
618 d.setTaggedValue(10,self.arg0*3)
619 d.setTaggedValue(100,self.arg0*4)
620 self._diffDataObjects(d,file)
621
622 def test_DumpAndLoad_Tagged_Function_Rank1(self):
623 if loadIsConfigured():
624 file=os.path.join(self.filebase,"tagged_function_rank1.nc")
625 d=Data(self.arg1,Function(self.domain))
626 d.setTaggedValue(1,self.arg1*2)
627 d.setTaggedValue(10,self.arg1*3)
628 d.setTaggedValue(100,self.arg1*4)
629 self._diffDataObjects(d,file)
630
631 def test_DumpAndLoad_Tagged_Function_Rank2(self):
632 if loadIsConfigured():
633 file=os.path.join(self.filebase,"tagged_function_rank2.nc")
634 d=Data(self.arg2,Function(self.domain))
635 d.setTaggedValue(1,self.arg2*2)
636 d.setTaggedValue(10,self.arg2*3)
637 d.setTaggedValue(100,self.arg2*4)
638 self._diffDataObjects(d,file)
639
640 def test_DumpAndLoad_Tagged_Function_Rank3(self):
641 if loadIsConfigured():
642 file=os.path.join(self.filebase,"tagged_function_rank3.nc")
643 d=Data(self.arg3,Function(self.domain))
644 d.setTaggedValue(1,self.arg3*2)
645 d.setTaggedValue(10,self.arg3*3)
646 d.setTaggedValue(100,self.arg3*4)
647 self._diffDataObjects(d,file)
648
649 def test_DumpAndLoad_Tagged_Function_Rank4(self):
650 if loadIsConfigured():
651 file=os.path.join(self.filebase,"tagged_function_rank4.nc")
652 d=Data(self.arg4,Function(self.domain))
653 d.setTaggedValue(1,self.arg4*2)
654 d.setTaggedValue(10,self.arg4*3)
655 d.setTaggedValue(100,self.arg4*4)
656 self._diffDataObjects(d,file)
657
658 #===========================================================================
659 def test_DumpAndLoad_Tagged_FunctionOnBoundary_Rank0(self):
660 if loadIsConfigured():
661 file=os.path.join(self.filebase,"tagged_function_on_boundary_rank0.nc")
662 d=Data(self.arg0,FunctionOnBoundary(self.domain))
663 d.setTaggedValue(1,self.arg0*2)
664 d.setTaggedValue(10,self.arg0*3)
665 d.setTaggedValue(100,self.arg0*4)
666 self._diffDataObjects(d,file)
667
668 def test_DumpAndLoad_Tagged_FunctionOnBoundary_Rank1(self):
669 if loadIsConfigured():
670 file=os.path.join(self.filebase,"tagged_function_on_boundary_rank1.nc")
671 d=Data(self.arg1,FunctionOnBoundary(self.domain))
672 d.setTaggedValue(1,self.arg1*2)
673 d.setTaggedValue(10,self.arg1*3)
674 d.setTaggedValue(100,self.arg1*4)
675 self._diffDataObjects(d,file)
676
677 def test_DumpAndLoad_Tagged_FunctionOnBoundary_Rank2(self):
678 if loadIsConfigured():
679 file=os.path.join(self.filebase,"tagged_function_on_boundary_rank2.nc")
680 d=Data(self.arg2,FunctionOnBoundary(self.domain))
681 d.setTaggedValue(1,self.arg2*2)
682 d.setTaggedValue(10,self.arg2*3)
683 d.setTaggedValue(100,self.arg2*4)
684 self._diffDataObjects(d,file)
685
686 def test_DumpAndLoad_Tagged_FunctionOnBoundary_Rank3(self):
687 if loadIsConfigured():
688 file=os.path.join(self.filebase,"tagged_function_on_boundary_rank3.nc")
689 d=Data(self.arg3,FunctionOnBoundary(self.domain))
690 d.setTaggedValue(1,self.arg3*2)
691 d.setTaggedValue(10,self.arg3*3)
692 d.setTaggedValue(100,self.arg3*4)
693 self._diffDataObjects(d,file)
694
695 def test_DumpAndLoad_Tagged_FunctionOnBoundary_Rank4(self):
696 if loadIsConfigured():
697 file=os.path.join(self.filebase,"tagged_function_on_boundary_rank4.nc")
698 d=Data(self.arg4,FunctionOnBoundary(self.domain))
699 d.setTaggedValue(1,self.arg4*2)
700 d.setTaggedValue(10,self.arg4*3)
701 d.setTaggedValue(100,self.arg4*4)
702 self._diffDataObjects(d,file)
703 #===========================================================================
704 def test_SetDataPointValue_Function_Rank0(self):
705 d=Data(self.arg0,Function(self.domain))
706 d.setValueOfDataPoint(0,self.arg0*2)
707 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
708 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg0)
709 d_0=d.getValueOfDataPoint(0)
710 d_1=d.getValueOfDataPoint(1)
711 self.failUnless(Lsup(d_0-self.arg0*2)<=Lsup(self.arg0*2), "wrong setting")
712 self.failUnless(Lsup(d_1-self.arg0)<=Lsup(self.arg0), "wrong setting")
713 def test_SetDataPointValue_Function_Rank1(self):
714 d=Data(self.arg1,Function(self.domain))
715 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg2)
716 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg1)
717 d.setValueOfDataPoint(0,self.arg1*2)
718 d_0=d.getValueOfDataPoint(0)
719 d_1=d.getValueOfDataPoint(1)
720 self.failUnless(Lsup(d_0-self.arg1*2)<=Lsup(self.arg1*2), "wrong setting")
721 self.failUnless(Lsup(d_1-self.arg1)<=Lsup(self.arg1), "wrong setting")
722 def test_SetDataPointValue_Function_Rank1_list(self):
723 d=Data(self.arg1,Function(self.domain))
724 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg2)
725 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg1)
726 d.setValueOfDataPoint(0,numarray.array2list(self.arg1*2))
727 d_0=d.getValueOfDataPoint(0)
728 d_1=d.getValueOfDataPoint(1)
729 self.failUnless(Lsup(d_0-self.arg1*2)<=Lsup(self.arg1*2), "wrong setting")
730 self.failUnless(Lsup(d_1-self.arg1)<=Lsup(self.arg1), "wrong setting")
731 def test_SetDataPointValue_Function_Rank2(self):
732 d=Data(self.arg2,Function(self.domain))
733 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
734 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg2)
735 d.setValueOfDataPoint(0,self.arg2*2)
736 d_0=d.getValueOfDataPoint(0)
737 d_1=d.getValueOfDataPoint(1)
738 self.failUnless(Lsup(d_0-self.arg2*2)<=Lsup(self.arg2*2), "wrong setting")
739 self.failUnless(Lsup(d_1-self.arg2)<=Lsup(self.arg2), "wrong setting")
740 def test_SetDataPointValue_Function_Rank2_list(self):
741 d=Data(self.arg2,Function(self.domain))
742 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
743 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg2)
744 d.setValueOfDataPoint(0,numarray.array2list(self.arg2*2))
745 d_0=d.getValueOfDataPoint(0)
746 d_1=d.getValueOfDataPoint(1)
747 self.failUnless(Lsup(d_0-self.arg2*2)<=Lsup(self.arg2*2), "wrong setting")
748 self.failUnless(Lsup(d_1-self.arg2)<=Lsup(self.arg2), "wrong setting")
749 def test_SetDataPointValue_Function_Rank3(self):
750 d=Data(self.arg3,Function(self.domain))
751 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
752 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg3)
753 d.setValueOfDataPoint(0,self.arg3*2)
754 d_0=d.getValueOfDataPoint(0)
755 d_1=d.getValueOfDataPoint(1)
756 self.failUnless(Lsup(d_0-self.arg3*2)<=Lsup(self.arg3*2), "wrong setting")
757 self.failUnless(Lsup(d_1-self.arg3)<=Lsup(self.arg3), "wrong setting")
758 def test_SetDataPointValue_Function_Rank3_list(self):
759 d=Data(self.arg3,Function(self.domain))
760 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
761 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg3)
762 d.setValueOfDataPoint(0,numarray.array2list(self.arg3*2))
763 d_0=d.getValueOfDataPoint(0)
764 d_1=d.getValueOfDataPoint(1)
765 self.failUnless(Lsup(d_0-self.arg3*2)<=Lsup(self.arg3*2), "wrong setting")
766 self.failUnless(Lsup(d_1-self.arg3)<=Lsup(self.arg3), "wrong setting")
767 def test_SetDataPointValue_Function_Rank4(self):
768 d=Data(self.arg4,Function(self.domain))
769 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
770 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg4)
771 d.setValueOfDataPoint(0,self.arg4*2)
772 d_0=d.getValueOfDataPoint(0)
773 d_1=d.getValueOfDataPoint(1)
774 self.failUnless(Lsup(d_0-self.arg4*2)<=Lsup(self.arg4*2), "wrong setting")
775 self.failUnless(Lsup(d_1-self.arg4)<=Lsup(self.arg4), "wrong setting")
776 def test_SetDataPointValue_Function_Rank4_list(self):
777 d=Data(self.arg4,Function(self.domain))
778 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
779 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg4)
780 d.setValueOfDataPoint(0,numarray.array2list(self.arg4*2))
781 d_0=d.getValueOfDataPoint(0)
782 d_1=d.getValueOfDataPoint(1)
783 self.failUnless(Lsup(d_0-self.arg4*2)<=Lsup(self.arg4*2), "wrong setting")
784 self.failUnless(Lsup(d_1-self.arg4)<=Lsup(self.arg4), "wrong setting")

  ViewVC Help
Powered by ViewVC 1.1.26