1 |
gross |
950 |
# $Id:$ |
2 |
|
|
|
3 |
|
|
__copyright__=""" Copyright (c) 2006 by ACcESS MNRF |
4 |
|
|
http://www.access.edu.au |
5 |
|
|
Primary Business: Queensland, Australia""" |
6 |
|
|
__license__="""Licensed under the Open Software License version 3.0 |
7 |
|
|
http://www.opensource.org/licenses/osl-3.0.php""" |
8 |
|
|
import unittest |
9 |
|
|
import tempfile |
10 |
|
|
|
11 |
|
|
from esys.escript import * |
12 |
|
|
from esys.finley import Rectangle |
13 |
|
|
import sys |
14 |
|
|
import os |
15 |
|
|
|
16 |
|
|
try: |
17 |
|
|
FINLEY_TEST_DATA=os.environ['FINLEY_TEST_DATA'] |
18 |
|
|
except KeyError: |
19 |
|
|
FINLEY_TEST_DATA='.' |
20 |
|
|
|
21 |
|
|
FINLEY_TEST_MESH_PATH=FINLEY_TEST_DATA+"/data_meshes/" |
22 |
|
|
|
23 |
|
|
|
24 |
|
|
NE=4 # number elements, must be even |
25 |
|
|
class Test_Dump(unittest.TestCase): |
26 |
|
|
arg0=9.81 |
27 |
|
|
arg1=numarray.array([3.098, -3.111]) |
28 |
|
|
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]]) |
29 |
|
|
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]]]) |
30 |
|
|
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]]]]) |
31 |
|
|
|
32 |
|
|
def _diffDataObjects(self,d_ref,file): |
33 |
|
|
d_ref.dump(file) |
34 |
|
|
d=load(file, self.domain) |
35 |
|
|
self.failUnless(not d.isEmpty(),"data in %s are empty."%file) |
36 |
|
|
self.failUnless(d_ref.getFunctionSpace() == d.getFunctionSpace(), "wrong function space in %s."%file) |
37 |
|
|
self.failUnless(d_ref.getRank() == d.getRank(), "different rank in %s. "%file) |
38 |
|
|
self.failUnless(d_ref.getShape() == d.getShape(), "different shape %s. "%file) |
39 |
|
|
self.failUnless(Lsup(d_ref-d)<=0., "different entries %s."%file) |
40 |
|
|
|
41 |
|
|
#=========================================================================== |
42 |
|
|
def test_DumpAndLoad_Constant_Solution_Rank0(self): |
43 |
|
|
file="constant_solution_rank0.nc" |
44 |
|
|
d=Data(self.arg0,self.solution) |
45 |
|
|
self._diffDataObjects(d,file) |
46 |
|
|
|
47 |
|
|
def test_DumpAndLoad_Constant_Solution_Rank1(self): |
48 |
|
|
file="constant_solution_rank1.nc" |
49 |
|
|
d=Data(self.arg1,self.solution) |
50 |
|
|
self._diffDataObjects(d,file) |
51 |
|
|
|
52 |
|
|
def test_DumpAndLoad_Constant_Solution_Rank2(self): |
53 |
|
|
file="constant_solution_rank2.nc" |
54 |
|
|
d=Data(self.arg2,self.solution) |
55 |
|
|
self._diffDataObjects(d,file) |
56 |
|
|
|
57 |
|
|
def test_DumpAndLoad_Constant_Solution_Rank3(self): |
58 |
|
|
file="constant_solution_rank3.nc" |
59 |
|
|
d=Data(self.arg3,self.solution) |
60 |
|
|
self._diffDataObjects(d,file) |
61 |
|
|
|
62 |
|
|
def test_DumpAndLoad_Constant_Solution_Rank4(self): |
63 |
|
|
file="constant_solution_rank4.nc" |
64 |
|
|
d=Data(self.arg4,self.solution) |
65 |
|
|
self._diffDataObjects(d,file) |
66 |
|
|
#=========================================================================== |
67 |
|
|
def test_DumpAndLoad_Constant_ReducedSolution_Rank0(self): |
68 |
|
|
file="constant_reduced_solution_rank0.nc" |
69 |
|
|
d=Data(self.arg0,self.reduced_solution) |
70 |
|
|
self._diffDataObjects(d,file) |
71 |
|
|
|
72 |
|
|
def test_DumpAndLoad_Constant_ReducedSolution_Rank1(self): |
73 |
|
|
file="constant_reduced_solution_rank1.nc" |
74 |
|
|
d=Data(self.arg1,self.reduced_solution) |
75 |
|
|
self._diffDataObjects(d,file) |
76 |
|
|
|
77 |
|
|
def test_DumpAndLoad_Constant_ReducedSolution_Rank2(self): |
78 |
|
|
file="constant_reduced_solution_rank2.nc" |
79 |
|
|
d=Data(self.arg2,self.reduced_solution) |
80 |
|
|
self._diffDataObjects(d,file) |
81 |
|
|
|
82 |
|
|
def test_DumpAndLoad_Constant_ReducedSolution_Rank3(self): |
83 |
|
|
file="constant_reduced_solution_rank3.nc" |
84 |
|
|
d=Data(self.arg3,self.reduced_solution) |
85 |
|
|
self._diffDataObjects(d,file) |
86 |
|
|
|
87 |
|
|
def test_DumpAndLoad_Constant_ReducedSolution_Rank4(self): |
88 |
|
|
file="constant_reduced_solution_rank4.nc" |
89 |
|
|
d=Data(self.arg4,self.reduced_solution) |
90 |
|
|
self._diffDataObjects(d,file) |
91 |
|
|
#=========================================================================== |
92 |
|
|
def test_DumpAndLoad_Constant_ContinuousFunction_Rank0(self): |
93 |
|
|
file="constant_continuous_function_rank0.nc" |
94 |
|
|
d=Data(self.arg0,self.continuous_function) |
95 |
|
|
self._diffDataObjects(d,file) |
96 |
|
|
|
97 |
|
|
def test_DumpAndLoad_Constant_ContinuousFunction_Rank1(self): |
98 |
|
|
file="constant_continuous_function_rank1.nc" |
99 |
|
|
d=Data(self.arg1,self.continuous_function) |
100 |
|
|
self._diffDataObjects(d,file) |
101 |
|
|
|
102 |
|
|
def test_DumpAndLoad_Constant_ContinuousFunction_Rank2(self): |
103 |
|
|
file="constant_continuous_function_rank2.nc" |
104 |
|
|
d=Data(self.arg2,self.continuous_function) |
105 |
|
|
self._diffDataObjects(d,file) |
106 |
|
|
|
107 |
|
|
def test_DumpAndLoad_Constant_ContinuousFunction_Rank3(self): |
108 |
|
|
file="constant_continuous_function_rank3.nc" |
109 |
|
|
d=Data(self.arg3,self.continuous_function) |
110 |
|
|
self._diffDataObjects(d,file) |
111 |
|
|
|
112 |
|
|
def test_DumpAndLoad_Constant_ContinuousFunction_Rank4(self): |
113 |
|
|
file="constant_continuous_function_rank4.nc" |
114 |
|
|
d=Data(self.arg4,self.continuous_function) |
115 |
|
|
self._diffDataObjects(d,file) |
116 |
|
|
|
117 |
|
|
#=========================================================================== |
118 |
|
|
def test_DumpAndLoad_Constant_Function_Rank0(self): |
119 |
|
|
file="constant_function_rank0.nc" |
120 |
|
|
d=Data(self.arg0,self.function) |
121 |
|
|
self._diffDataObjects(d,file) |
122 |
|
|
|
123 |
|
|
def test_DumpAndLoad_Constant_Function_Rank1(self): |
124 |
|
|
file="constant_function_rank1.nc" |
125 |
|
|
d=Data(self.arg1,self.function) |
126 |
|
|
self._diffDataObjects(d,file) |
127 |
|
|
|
128 |
|
|
def test_DumpAndLoad_Constant_Function_Rank2(self): |
129 |
|
|
file="constant_function_rank2.nc" |
130 |
|
|
d=Data(self.arg2,self.function) |
131 |
|
|
self._diffDataObjects(d,file) |
132 |
|
|
|
133 |
|
|
def test_DumpAndLoad_Constant_Function_Rank3(self): |
134 |
|
|
file="constant_function_rank3.nc" |
135 |
|
|
d=Data(self.arg3,self.function) |
136 |
|
|
self._diffDataObjects(d,file) |
137 |
|
|
|
138 |
|
|
def test_DumpAndLoad_Constant_Function_Rank4(self): |
139 |
|
|
file="constant_function_rank4.nc" |
140 |
|
|
d=Data(self.arg4,self.function) |
141 |
|
|
self._diffDataObjects(d,file) |
142 |
|
|
|
143 |
|
|
#=========================================================================== |
144 |
|
|
def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank0(self): |
145 |
|
|
file="constant_function_on_boundary_rank0.nc" |
146 |
|
|
d=Data(self.arg0,self.function_on_boundary) |
147 |
|
|
self._diffDataObjects(d,file) |
148 |
|
|
|
149 |
|
|
def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank1(self): |
150 |
|
|
file="constant_function_on_boundary_rank1.nc" |
151 |
|
|
d=Data(self.arg1,self.function_on_boundary) |
152 |
|
|
self._diffDataObjects(d,file) |
153 |
|
|
|
154 |
|
|
def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank2(self): |
155 |
|
|
file="constant_function_on_boundary_rank2.nc" |
156 |
|
|
d=Data(self.arg2,self.function_on_boundary) |
157 |
|
|
self._diffDataObjects(d,file) |
158 |
|
|
|
159 |
|
|
def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank3(self): |
160 |
|
|
file="constant_function_on_boundary_rank3.nc" |
161 |
|
|
d=Data(self.arg3,self.function_on_boundary) |
162 |
|
|
self._diffDataObjects(d,file) |
163 |
|
|
|
164 |
|
|
def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank4(self): |
165 |
|
|
file="constant_function_on_boundary_rank4.nc" |
166 |
|
|
d=Data(self.arg4,self.function_on_boundary) |
167 |
|
|
self._diffDataObjects(d,file) |
168 |
|
|
|
169 |
gross |
965 |
#=========================================================================== |
170 |
|
|
def test_DumpAndLoad_Expanded_Solution_Rank0(self): |
171 |
|
|
file="expanded_solution_rank0.nc" |
172 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
173 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
174 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
175 |
gross |
965 |
d=Data(length(self.solution.getX())*self.arg0,self.solution) |
176 |
|
|
self._diffDataObjects(d,file) |
177 |
gross |
950 |
|
178 |
gross |
965 |
def test_DumpAndLoad_Expanded_Solution_Rank1(self): |
179 |
|
|
file="expanded_solution_rank1.nc" |
180 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
181 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
182 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
183 |
gross |
965 |
d=Data(length(self.solution.getX())*self.arg1,self.solution) |
184 |
|
|
self._diffDataObjects(d,file) |
185 |
|
|
|
186 |
|
|
def test_DumpAndLoad_Expanded_Solution_Rank2(self): |
187 |
|
|
file="expanded_solution_rank2.nc" |
188 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
189 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
190 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
191 |
gross |
965 |
d=Data(length(self.solution.getX())*self.arg2,self.solution) |
192 |
|
|
self._diffDataObjects(d,file) |
193 |
|
|
|
194 |
|
|
def test_DumpAndLoad_Expanded_Solution_Rank3(self): |
195 |
|
|
file="expanded_solution_rank3.nc" |
196 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
197 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
198 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
199 |
gross |
965 |
d=Data(length(self.solution.getX())*self.arg3,self.solution) |
200 |
|
|
self._diffDataObjects(d,file) |
201 |
|
|
|
202 |
|
|
def test_DumpAndLoad_Expanded_Solution_Rank4(self): |
203 |
|
|
file="expanded_solution_rank4.nc" |
204 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
205 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
206 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
207 |
gross |
965 |
d=Data(length(self.solution.getX())*self.arg4,self.solution) |
208 |
|
|
self._diffDataObjects(d,file) |
209 |
|
|
#=========================================================================== |
210 |
|
|
def test_DumpAndLoad_Expanded_ReducedSolution_Rank0(self): |
211 |
|
|
file="expanded_reduced_solution_rank0.nc" |
212 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
213 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
214 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
215 |
gross |
965 |
d=Data(length(self.reduced_solution.getX())*self.arg0,self.reduced_solution) |
216 |
|
|
self._diffDataObjects(d,file) |
217 |
|
|
|
218 |
|
|
def test_DumpAndLoad_Expanded_ReducedSolution_Rank1(self): |
219 |
|
|
file="expanded_reduced_solution_rank1.nc" |
220 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
221 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
222 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
223 |
gross |
965 |
d=Data(length(self.reduced_solution.getX())*self.arg1,self.reduced_solution) |
224 |
|
|
self._diffDataObjects(d,file) |
225 |
|
|
|
226 |
|
|
def test_DumpAndLoad_Expanded_ReducedSolution_Rank2(self): |
227 |
|
|
file="expanded_reduced_solution_rank2.nc" |
228 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
229 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
230 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
231 |
gross |
965 |
d=Data(length(self.reduced_solution.getX())*self.arg2,self.reduced_solution) |
232 |
|
|
self._diffDataObjects(d,file) |
233 |
|
|
|
234 |
|
|
def test_DumpAndLoad_Expanded_ReducedSolution_Rank3(self): |
235 |
|
|
file="expanded_reduced_solution_rank3.nc" |
236 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
237 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
238 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
239 |
gross |
965 |
d=Data(length(self.reduced_solution.getX())*self.arg3,self.reduced_solution) |
240 |
|
|
self._diffDataObjects(d,file) |
241 |
|
|
|
242 |
|
|
def test_DumpAndLoad_Expanded_ReducedSolution_Rank4(self): |
243 |
|
|
file="expanded_reduced_solution_rank4.nc" |
244 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
245 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
246 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
247 |
gross |
965 |
d=Data(length(self.reduced_solution.getX())*self.arg4,self.reduced_solution) |
248 |
|
|
self._diffDataObjects(d,file) |
249 |
|
|
#=========================================================================== |
250 |
|
|
def test_DumpAndLoad_Expanded_ContinuousFunction_Rank0(self): |
251 |
|
|
file="expanded_continuous_function_rank0.nc" |
252 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
253 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
254 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
255 |
gross |
965 |
d=Data(length(self.continuous_function.getX())*self.arg0,self.continuous_function) |
256 |
|
|
self._diffDataObjects(d,file) |
257 |
|
|
|
258 |
|
|
def test_DumpAndLoad_Expanded_ContinuousFunction_Rank1(self): |
259 |
|
|
file="expanded_continuous_function_rank1.nc" |
260 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
261 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
262 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
263 |
gross |
965 |
d=Data(length(self.continuous_function.getX())*self.arg1,self.continuous_function) |
264 |
|
|
self._diffDataObjects(d,file) |
265 |
|
|
|
266 |
|
|
def test_DumpAndLoad_Expanded_ContinuousFunction_Rank2(self): |
267 |
|
|
file="expanded_continuous_function_rank2.nc" |
268 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
269 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
270 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
271 |
gross |
965 |
d=Data(length(self.continuous_function.getX())*self.arg2,self.continuous_function) |
272 |
|
|
self._diffDataObjects(d,file) |
273 |
|
|
|
274 |
|
|
def test_DumpAndLoad_Expanded_ContinuousFunction_Rank3(self): |
275 |
|
|
file="expanded_continuous_function_rank3.nc" |
276 |
|
|
d=Data(length(self.continuous_function.getX())*self.arg3,self.continuous_function) |
277 |
|
|
self._diffDataObjects(d,file) |
278 |
|
|
|
279 |
|
|
def test_DumpAndLoad_Expanded_ContinuousFunction_Rank4(self): |
280 |
|
|
file="expanded_continuous_function_rank4.nc" |
281 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
282 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
283 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
284 |
gross |
965 |
d=Data(length(self.continuous_function.getX())*self.arg4,self.continuous_function) |
285 |
|
|
self._diffDataObjects(d,file) |
286 |
|
|
|
287 |
|
|
#=========================================================================== |
288 |
|
|
def test_DumpAndLoad_Expanded_Function_Rank0(self): |
289 |
|
|
file="expanded_function_rank0.nc" |
290 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
291 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
292 |
|
|
# elements are not in different order: self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
293 |
gross |
965 |
d=Data(length(self.function.getX())*self.arg0,self.function) |
294 |
|
|
self._diffDataObjects(d,file) |
295 |
|
|
|
296 |
|
|
def test_DumpAndLoad_Expanded_Function_Rank1(self): |
297 |
|
|
file="expanded_function_rank1.nc" |
298 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
299 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
300 |
|
|
# elements are not in different order: self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
301 |
gross |
965 |
d=Data(length(self.function.getX())*self.arg1,self.function) |
302 |
|
|
self._diffDataObjects(d,file) |
303 |
|
|
|
304 |
|
|
def test_DumpAndLoad_Expanded_Function_Rank2(self): |
305 |
|
|
file="expanded_function_rank2.nc" |
306 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
307 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
308 |
|
|
# elements are not in different order: self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
309 |
gross |
965 |
d=Data(length(self.function.getX())*self.arg2,self.function) |
310 |
|
|
self._diffDataObjects(d,file) |
311 |
|
|
|
312 |
|
|
def test_DumpAndLoad_Expanded_Function_Rank3(self): |
313 |
|
|
file="expanded_function_rank3.nc" |
314 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
315 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
316 |
|
|
# elements are not in different order: self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
317 |
gross |
965 |
d=Data(length(self.function.getX())*self.arg3,self.function) |
318 |
|
|
self._diffDataObjects(d,file) |
319 |
|
|
|
320 |
|
|
def test_DumpAndLoad_Expanded_Function_Rank4(self): |
321 |
|
|
file="expanded_function_rank4.nc" |
322 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
323 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
324 |
|
|
# elements are not in different order: self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
325 |
gross |
965 |
d=Data(length(self.function.getX())*self.arg4,self.function) |
326 |
|
|
self._diffDataObjects(d,file) |
327 |
|
|
|
328 |
|
|
#=========================================================================== |
329 |
|
|
def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank0(self): |
330 |
|
|
file="expanded_function_on_boundary_rank0.nc" |
331 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
332 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
333 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
334 |
gross |
965 |
d=Data(length(self.function_on_boundary.getX())*self.arg0,self.function_on_boundary) |
335 |
|
|
self._diffDataObjects(d,file) |
336 |
|
|
|
337 |
|
|
def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank1(self): |
338 |
|
|
file="expanded_function_on_boundary_rank1.nc" |
339 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
340 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
341 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
342 |
gross |
965 |
d=Data(length(self.function_on_boundary.getX())*self.arg1,self.function_on_boundary) |
343 |
|
|
self._diffDataObjects(d,file) |
344 |
|
|
|
345 |
|
|
def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank2(self): |
346 |
|
|
file="expanded_function_on_boundary_rank2.nc" |
347 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
348 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
349 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
350 |
gross |
965 |
d=Data(length(self.function_on_boundary.getX())*self.arg2,self.function_on_boundary) |
351 |
|
|
self._diffDataObjects(d,file) |
352 |
|
|
|
353 |
|
|
def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank3(self): |
354 |
|
|
file="expanded_function_on_boundary_rank3.nc" |
355 |
gross |
982 |
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_samples) |
356 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_number_of_data_points_per_sample) |
357 |
|
|
self.failUnlessRaises(RuntimeError, load, file, self.domain_with_different_sample_ordering) |
358 |
gross |
965 |
d=Data(length(self.function_on_boundary.getX())*self.arg3,self.function_on_boundary) |
359 |
|
|
self._diffDataObjects(d,file) |
360 |
|
|
|
361 |
|
|
def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank4(self): |
362 |
|
|
file="expanded_function_on_boundary_rank4.nc" |
363 |
gross |
982 |
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 |
gross |
965 |
d=Data(length(self.function_on_boundary.getX())*self.arg4,self.function_on_boundary) |
367 |
|
|
self._diffDataObjects(d,file) |
368 |
|
|
|
369 |
|
|
|
370 |
gross |
950 |
|
371 |
gross |
965 |
class Test_DumpOnFinley(Test_Dump): |
372 |
|
|
def setUp(self): |
373 |
|
|
self.domain =Rectangle(NE,NE+1,2) |
374 |
gross |
982 |
self.domain_with_different_number_of_samples =Rectangle(2*NE,NE+1,2) |
375 |
|
|
self.domain_with_different_number_of_data_points_per_sample =Rectangle(2*NE,NE+1,2,integrationOrder=2) |
376 |
|
|
self.domain_with_different_sample_ordering =Rectangle(1,(NE+1)*NE,2) |
377 |
gross |
965 |
self.solution = Solution(self.domain) |
378 |
|
|
self.reduced_solution = ReducedSolution(self.domain) |
379 |
|
|
self.continuous_function = ContinuousFunction(self.domain) |
380 |
|
|
self.function = Function(self.domain) |
381 |
|
|
self.function_on_boundary = FunctionOnBoundary(self.domain) |
382 |
|
|
|
383 |
gross |
950 |
def tearDown(self): |
384 |
|
|
del self.function |
385 |
|
|
del self.function_on_boundary |
386 |
|
|
del self.domain |
387 |
|
|
|
388 |
|
|
if __name__ == '__main__': |
389 |
|
|
suite = unittest.TestSuite() |
390 |
|
|
suite.addTest(unittest.makeSuite(Test_DumpOnFinley)) |
391 |
|
|
s=unittest.TextTestRunner(verbosity=2).run(suite) |
392 |
|
|
if s.wasSuccessful(): |
393 |
|
|
sys.exit(0) |
394 |
|
|
else: |
395 |
|
|
sys.exit(1) |
396 |
|
|
|