Mercurial > hg > ltpda
comparison testing/utp_1.1/utps/parfrac/utp_parfrac_parfrac.m @ 44:409a22968d5e default
Add unit tests
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Tue, 06 Dec 2011 18:42:11 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
43:bc767aaa99a8 | 44:409a22968d5e |
---|---|
1 % UTP_PARFRAC_PARFRAC a set of UTPs for the parfrac/parfrac method | |
2 % | |
3 % M Hewitson 06-08-08 | |
4 % | |
5 % $Id: utp_parfrac_parfrac.m,v 1.21 2011/08/22 05:37:13 hewitson Exp $ | |
6 % | |
7 | |
8 % <MethodDescription> | |
9 % | |
10 % The parfrac method of the parfrac class constructs PARFRAC objects. | |
11 % | |
12 % </MethodDescription> | |
13 | |
14 function results = utp_parfrac_parfrac(varargin) | |
15 | |
16 % Check the inputs | |
17 if nargin == 0 | |
18 | |
19 % Some keywords | |
20 class = 'parfrac'; | |
21 mthd = 'parfrac'; | |
22 | |
23 results = []; | |
24 disp('******************************************************'); | |
25 disp(['**** Running UTPs for ' class '/' mthd]); | |
26 disp('******************************************************'); | |
27 | |
28 % Test objects | |
29 [pf1,pf2,pf3,pfv,pfm] = get_test_objects_parfrac; | |
30 | |
31 % Exception list for the UTPs: | |
32 [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples(); | |
33 | |
34 % Run the tests | |
35 results = [results utp_01]; % getInfo call | |
36 results = [results utp_02]; % Vector input | |
37 results = [results utp_03]; % Matrix input | |
38 results = [results utp_04]; % List input | |
39 results = [results utp_05]; % Test with mixed input | |
40 results = [results utp_06]; % Test history is working with empty constructor | |
41 results = [results utp_07]; % Test history is working with copy constructor | |
42 results = [results utp_08]; % Test history is working with MAT file constructor | |
43 results = [results utp_09]; % Test history is working with XML file constructor | |
44 results = [results utp_10]; % Test history is working with struct constructor | |
45 results = [results utp_11]; % Test history is working with rational-object constructor | |
46 results = [results utp_12]; % Test history is working with pzmodel-object constructor | |
47 results = [results utp_13]; % Test history is working with plist(filename) constructor | |
48 results = [results utp_14]; % Test history is working with plist(hostname) constructor | |
49 results = [results utp_15]; % Test history is working with plist(res || poles || dir) constructor | |
50 results = [results utp_16]; % Test history is working with plist(pzmodel) constructor | |
51 results = [results utp_17]; % Test history is working with plist(rational) constructor | |
52 results = [results utp_18]; % Test history is working with plist(plist) constructor | |
53 results = [results utp_19]; % Test history is working with conn+Id constructor | |
54 results = [results utp_20]; % Test history is working with res + poles + dir constructor | |
55 results = [results utp_21]; % Test history is working with res + poles + dir + name constructor | |
56 results = [results utp_22]; % Test history is working with res + poles + dir + name + iunits + ounits constructor | |
57 | |
58 disp('Done.'); | |
59 disp('******************************************************'); | |
60 | |
61 elseif nargin == 1 % Check for UTP functions | |
62 if strcmp(varargin{1}, 'isutp') | |
63 results = 1; | |
64 elseif strcmpi(varargin{1}, 'needs repository') | |
65 results = 2; | |
66 else | |
67 results = 0; | |
68 end | |
69 else | |
70 error('### Incorrect inputs') | |
71 end | |
72 | |
73 %% UTP_01 | |
74 | |
75 % <TestDescription> | |
76 % | |
77 % Tests that the getInfo call works for this method. | |
78 % | |
79 % </TestDescription> | |
80 function result = utp_01 | |
81 | |
82 | |
83 % <SyntaxDescription> | |
84 % | |
85 % Test that the getInfo call works for no sets, all sets, and each set | |
86 % individually. | |
87 % | |
88 % </SyntaxDescription> | |
89 | |
90 try | |
91 % <SyntaxCode> | |
92 % Call for no sets | |
93 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']); | |
94 % Call for all sets | |
95 io(2) = eval([class '.getInfo(''' mthd ''')']); | |
96 % Call for each set | |
97 for kk=1:numel(io(2).sets) | |
98 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']); | |
99 end | |
100 % </SyntaxCode> | |
101 stest = true; | |
102 catch err | |
103 disp(err.message) | |
104 stest = false; | |
105 end | |
106 | |
107 % <AlgoDescription> | |
108 % | |
109 % 1) Check that getInfo call returned an minfo object in all cases. | |
110 % 2) Check that all plists have the correct parameters. | |
111 % | |
112 % </AlgoDescription> | |
113 | |
114 atest = true; | |
115 if stest | |
116 % <AlgoCode> | |
117 % check we have minfo objects | |
118 if isa(io, 'minfo') | |
119 %%% SET 'None' | |
120 if ~isempty(io(1).sets), atest = false; end | |
121 if ~isempty(io(1).plists), atest = false; end | |
122 %%% Check all Sets | |
123 if ~any(strcmpi(io(2).sets, 'Default')), atest = false; end | |
124 if ~any(strcmpi(io(2).sets, 'From Rational')), atest = false; end | |
125 if ~any(strcmpi(io(2).sets, 'From Pzmodel')), atest = false; end | |
126 if ~any(strcmpi(io(2).sets, 'From Residuals/Poles/Direct')), atest = false; end | |
127 if ~any(strcmpi(io(2).sets, 'From Repository')), atest = false; end | |
128 if ~any(strcmpi(io(2).sets, 'From XML File')), atest = false; end | |
129 if ~any(strcmpi(io(2).sets, 'From MAT File')), atest = false; end | |
130 if ~any(strcmpi(io(2).sets, 'From Built-in Model')), atest = false; end | |
131 if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end | |
132 %%%%%%%%%% SET 'Default' | |
133 if io(3).plists.nparams ~= 3, atest = false; end | |
134 % Check key | |
135 % Check default value | |
136 % Check options | |
137 %%%%%%%%%% SET 'From MAT File' | |
138 pn = 4; | |
139 if io(pn).plists.nparams ~= 4, atest = false; end | |
140 % Check key | |
141 if ~io(pn).plists.isparam('filename'), atest = false; end | |
142 % Check default value | |
143 if ~isEmptyChar(io(pn).plists.find('filename')), atest = false; end | |
144 % Check options | |
145 if ~isequal(io(pn).plists.getOptionsForParam('filename'), {''}), atest = false; end | |
146 %%%%%%%%%% SET 'From XML File' | |
147 pn = 5; | |
148 if io(pn).plists.nparams ~= 4, atest = false; end | |
149 % Check key | |
150 if ~io(pn).plists.isparam('filename'), atest = false; end | |
151 % Check default value | |
152 if ~isEmptyChar(io(pn).plists.find('filename')), atest = false; end | |
153 % Check options | |
154 if ~isequal(io(pn).plists.getOptionsForParam('filename'), {''}), atest = false; end | |
155 %%%%%%%%%% SET 'From Repository' | |
156 pn = 6; | |
157 if io(pn).plists.nparams ~= 10, atest = false; end | |
158 % Check key | |
159 if ~io(pn).plists.isparam('hostname'), atest = false; end | |
160 if ~io(pn).plists.isparam('id'), atest = false; end | |
161 if ~io(pn).plists.isparam('cid'), atest = false; end | |
162 if ~io(pn).plists.isparam('database'), atest = false; end | |
163 if ~io(pn).plists.isparam('binary'), atest = false; end | |
164 if ~io(pn).plists.isparam('username'), atest = false; end | |
165 if ~io(pn).plists.isparam('password'), atest = false; end | |
166 % Check default value | |
167 if ~isEmptyDouble(io(pn).plists.find('id')), atest = false; end | |
168 if ~isEmptyDouble(io(pn).plists.find('cid')), atest = false; end | |
169 if ~isequal(io(pn).plists.find('binary'), 'yes'), atest = false; end | |
170 % Check options | |
171 if ~isequal(io(pn).plists.getOptionsForParam('id'), {[]}), atest = false; end | |
172 if ~isequal(io(pn).plists.getOptionsForParam('cid'), {[]}), atest = false; end | |
173 if ~isequal(io(pn).plists.getOptionsForParam('binary'), {'yes', 'no'}), atest = false; end | |
174 %%%%%%%%%% SET 'From Built-in Model' | |
175 pn = 7; | |
176 if io(pn).plists.nparams ~= 4, atest = false; end | |
177 % Check key | |
178 if ~io(pn).plists.isparam('built-in'), atest = false; end | |
179 % Check default value | |
180 if ~isEmptyChar(io(pn).plists.find('built-in')), atest = false; end | |
181 % Check options | |
182 if ~isequal(io(pn).plists.getOptionsForParam('built-in'), {''}), atest = false; end | |
183 %%%%%%%%%% SET 'From Rational' | |
184 pn = 8; | |
185 if io(pn).plists.nparams ~= 6, atest = false; end | |
186 % Check key | |
187 if ~io(pn).plists.isparam('rational'), atest = false; end | |
188 % Check default value | |
189 if ~eq(io(pn).plists.find('rational'), rational(), ple1), atest = false; end | |
190 % Check options | |
191 %%%%%%%%%% SET 'From Pzmodel' | |
192 pn = 9; | |
193 if io(pn).plists.nparams ~= 6, atest = false; end | |
194 % Check key | |
195 if ~io(pn).plists.isparam('pzmodel'), atest = false; end | |
196 % Check default value | |
197 if ~eq(io(pn).plists.find('pzmodel'), pzmodel(), ple1), atest = false; end | |
198 % Check options | |
199 %%%%%%%%%% SET 'From Residuals/Poles/Direct' | |
200 pn = 10; | |
201 if io(pn).plists.nparams ~= 8, atest = false; end | |
202 % Check key | |
203 if ~io(pn).plists.isparam('res'), atest = false; end | |
204 if ~io(pn).plists.isparam('poles'), atest = false; end | |
205 if ~io(pn).plists.isparam('dir'), atest = false; end | |
206 if ~io(pn).plists.isparam('name'), atest = false; end | |
207 % Check default value | |
208 if ~isEmptyDouble(io(pn).plists.find('res')), atest = false; end | |
209 if ~isEmptyDouble(io(pn).plists.find('poles')), atest = false; end | |
210 if ~isequal(io(pn).plists.find('dir'), 0), atest = false; end | |
211 if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end | |
212 % Check options | |
213 if ~isequal(io(pn).plists.getOptionsForParam('res'), {[]}), atest = false; end | |
214 if ~isequal(io(pn).plists.getOptionsForParam('poles'), {[]}), atest = false; end | |
215 if ~isequal(io(pn).plists.getOptionsForParam('dir'), {0}), atest = false; end | |
216 if ~isequal(io(pn).plists.getOptionsForParam('name'), {''}), atest = false; end | |
217 end | |
218 % </AlgoCode> | |
219 else | |
220 atest = false; | |
221 end | |
222 | |
223 % Return a result structure | |
224 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
225 end % END UTP_01 | |
226 | |
227 %% UTP_02 | |
228 | |
229 % <TestDescription> | |
230 % | |
231 % Tests that the parfrac method works with a vector of PARFRAC objects as | |
232 % input. | |
233 % | |
234 % </TestDescription> | |
235 function result = utp_02 | |
236 | |
237 % <SyntaxDescription> | |
238 % | |
239 % Test that the parfrac method works with a vector of PARFRAC objects | |
240 % as input. | |
241 % | |
242 % </SyntaxDescription> | |
243 | |
244 try | |
245 % <SyntaxCode> | |
246 out = parfrac(pfv); | |
247 % </SyntaxCode> | |
248 stest = true; | |
249 catch err | |
250 disp(err.message) | |
251 stest = false; | |
252 end | |
253 | |
254 % <AlgoDescription> | |
255 % | |
256 % 1) Check that the shape of the output PARFRACs is the same as the | |
257 % input shape. | |
258 % 2) Check that each output PARFRAC is a copy of the input PARFRAC. | |
259 % 3) Check that the copy have an additional history step. | |
260 % | |
261 % </AlgoDescription> | |
262 | |
263 atest = true; | |
264 if stest | |
265 % <AlgoCode> | |
266 % Check we have the correct shape | |
267 if size(out) ~= size(pfv), atest = false; end | |
268 % Check that the output is a copy. | |
269 for ii = 1:numel(out) | |
270 % Check that the output is the same except the history | |
271 if ~eq(pfv(ii), out(ii), ple3), atest = false; end | |
272 % Check the history | |
273 if ~eq(pfv(ii).hist, out(ii).hist.inhists), atest = false; end | |
274 % Change the output to make sure that it is a 'real' copy | |
275 out(ii).setDescription('my desc'); | |
276 if eq(pfv(ii), out(ii), ple3), atest = false; end | |
277 end | |
278 % </AlgoCode> | |
279 else | |
280 atest = false; | |
281 end | |
282 | |
283 % Return a result structure | |
284 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
285 end % END UTP_02 | |
286 | |
287 %% UTP_03 | |
288 | |
289 % <TestDescription> | |
290 % | |
291 % Tests that the parfrac method works with a matrix of PARFRAC objects as | |
292 % input. | |
293 % | |
294 % </TestDescription> | |
295 function result = utp_03 | |
296 | |
297 % <SyntaxDescription> | |
298 % | |
299 % Test that the parfrac method works with a matrix of PARFRAC objects | |
300 % as input. | |
301 % | |
302 % </SyntaxDescription> | |
303 | |
304 try | |
305 % <SyntaxCode> | |
306 out = parfrac(pfm); | |
307 % </SyntaxCode> | |
308 stest = true; | |
309 catch err | |
310 disp(err.message) | |
311 stest = false; | |
312 end | |
313 | |
314 % <AlgoDescription> | |
315 % | |
316 % 1) Check that the shape of the output PARFRACs is the same as the | |
317 % input shape. | |
318 % 2) Check that each output PARFRAC is a copy of the input PARFRAC. | |
319 % 3) Check that the copy have an additional history step. | |
320 % | |
321 % </AlgoDescription> | |
322 | |
323 atest = true; | |
324 if stest | |
325 % <AlgoCode> | |
326 % Check we have the correct number of outputs | |
327 if size(out) ~= size(pfm), atest = false; end | |
328 % Check that the output is a copy. | |
329 for ii = 1:numel(out) | |
330 % Check that the output is the same except the history | |
331 if ~eq(pfm(ii), out(ii), ple3), atest = false; end | |
332 % Check the history | |
333 if ~eq(pfm(ii).hist, out(ii).hist.inhists), atest = false; end | |
334 % Change the output to make sure that it is a 'real' copy | |
335 out(ii).setDescription('my desc'); | |
336 if eq(pfm(ii), out(ii), ple3), atest = false; end | |
337 end | |
338 % </AlgoCode> | |
339 else | |
340 atest = false; | |
341 end | |
342 | |
343 % Return a result structure | |
344 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
345 end % END UTP_03 | |
346 | |
347 %% UTP_04 | |
348 | |
349 % <TestDescription> | |
350 % | |
351 % Tests that the parfrac method works with a list of PARFRAC objects as | |
352 % input. | |
353 % | |
354 % </TestDescription> | |
355 function result = utp_04 | |
356 | |
357 % <SyntaxDescription> | |
358 % | |
359 % Test that the parfrac method works with a list of PARFRAC objects as | |
360 % input. | |
361 % | |
362 % </SyntaxDescription> | |
363 | |
364 try | |
365 % <SyntaxCode> | |
366 out = parfrac(pf1,pf2,pf3); | |
367 % </SyntaxCode> | |
368 stest = true; | |
369 catch err | |
370 disp(err.message) | |
371 stest = false; | |
372 end | |
373 | |
374 % <AlgoDescription> | |
375 % | |
376 % 1) Check that the number of elements in 'out' is the same of the | |
377 % number in the input. | |
378 % 2) Check that each output PARFRAC is a copy of the input PARFRAC. | |
379 % 3) Check that the copy have an additional history step. | |
380 % | |
381 % </AlgoDescription> | |
382 | |
383 atest = true; | |
384 pfin = [pf1,pf2,pf3]; | |
385 if stest | |
386 % <AlgoCode> | |
387 % Check we have the correct number of outputs | |
388 if numel(out) ~= 3, atest = false; end | |
389 | |
390 % Check that the output is a copy. | |
391 for ii = 1:numel(out) | |
392 % Check that the output is the same except the history | |
393 if ~eq(pfin(ii), out(ii), ple3), atest = false; end | |
394 % Check the history | |
395 if ~eq(pfin(ii).hist, out(ii).hist.inhists), atest = false; end | |
396 % Change the output to make sure that it is a 'real' copy | |
397 out(ii).setDescription('my desc'); | |
398 if eq(pfin(ii), out(ii), ple3), atest = false; end | |
399 end | |
400 % </AlgoCode> | |
401 else | |
402 atest = false; | |
403 end | |
404 | |
405 % Return a result structure | |
406 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
407 end % END UTP_04 | |
408 | |
409 %% UTP_05 | |
410 | |
411 % <TestDescription> | |
412 % | |
413 % Tests that the parfrac method works with a mix of different shaped | |
414 % PARFRACs as input. | |
415 % | |
416 % </TestDescription> | |
417 function result = utp_05 | |
418 | |
419 % <SyntaxDescription> | |
420 % | |
421 % Test that the parfrac method works with a mix of different shaped | |
422 % PARFRACs as input. | |
423 % | |
424 % </SyntaxDescription> | |
425 | |
426 try | |
427 % <SyntaxCode> | |
428 out = parfrac(pf1,pfv,pf2,pfm,pf3); | |
429 % </SyntaxCode> | |
430 stest = true; | |
431 catch err | |
432 disp(err.message) | |
433 stest = false; | |
434 end | |
435 | |
436 % <AlgoDescription> | |
437 % | |
438 % 1) Check that the number of elements in 'out' is the same of the | |
439 % number in the input. | |
440 % 2) Check that each output PARFRAC is a copy of the input PARFRAC. | |
441 % 3) Check that the copy have an additional history step. | |
442 % | |
443 % </AlgoDescription> | |
444 | |
445 atest = true; | |
446 pfin = [pf1, reshape(pfv, 1, []), pf2, reshape(pfm, 1, []), pf3]; | |
447 if stest | |
448 % <AlgoCode> | |
449 % Check we have the correct number of outputs | |
450 if numel(out) ~= 3+numel(pfv)+numel(pfm), atest = false; end | |
451 | |
452 % Check that the output is a copy. | |
453 for ii = 1:numel(out) | |
454 % Check that the output is the same except the history | |
455 if ~eq(pfin(ii), out(ii), ple3), atest = false; end | |
456 % Check the history | |
457 if ~eq(pfin(ii).hist, out(ii).hist.inhists), atest = false; end | |
458 % Change the output to make sure that it is a 'real' copy | |
459 out(ii).setDescription('my desc'); | |
460 if eq(pfin(ii), out(ii), ple3), atest = false; end | |
461 end | |
462 % </AlgoCode> | |
463 else | |
464 atest = false; | |
465 end | |
466 | |
467 % Return a result structure | |
468 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
469 end % END UTP_05 | |
470 | |
471 %% UTP_06 | |
472 | |
473 % <TestDescription> | |
474 % | |
475 % Tests that the parfrac method properly applies history. | |
476 % | |
477 % </TestDescription> | |
478 function result = utp_06 | |
479 | |
480 % <SyntaxDescription> | |
481 % | |
482 % Test that the result of applying the parfrac method can be processed | |
483 % back. | |
484 % | |
485 % </SyntaxDescription> | |
486 | |
487 try | |
488 % <SyntaxCode> | |
489 out = parfrac(pf1); | |
490 mout = rebuild(out); | |
491 % </SyntaxCode> | |
492 stest = true; | |
493 catch err | |
494 disp(err.message) | |
495 stest = false; | |
496 end | |
497 | |
498 % <AlgoDescription> | |
499 % | |
500 % 1) Check that the last entry in the history of 'out' corresponds to | |
501 % 'parfrac'. | |
502 % 2) Check that the method rebuild produces the same object as 'out'. | |
503 % | |
504 % </AlgoDescription> | |
505 | |
506 atest = true; | |
507 if stest | |
508 % <AlgoCode> | |
509 % Check the last step in the history of 'out' | |
510 if ~strcmp(out.hist.methodInfo.mname, 'parfrac'), atest = false; end | |
511 % Check the rebuilt object | |
512 if ~eq(mout, out, ple2), atest = false; end | |
513 % </AlgoCode> | |
514 else | |
515 atest = false; | |
516 end | |
517 | |
518 % Return a result structure | |
519 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
520 end % END UTP_06 | |
521 | |
522 %% UTP_07 | |
523 | |
524 % <TestDescription> | |
525 % | |
526 % Tests that the parfrac method properly applies history to the copy | |
527 % constructor. | |
528 % | |
529 % </TestDescription> | |
530 function result = utp_07 | |
531 | |
532 % <SyntaxDescription> | |
533 % | |
534 % Test that the output can be processed back with the 'rebuild' method. | |
535 % Test the constructor with a different number of inputs. | |
536 % | |
537 % </SyntaxDescription> | |
538 | |
539 try | |
540 % <SyntaxCode> | |
541 out1 = parfrac(pf1); | |
542 out2 = parfrac(pf1, pf2); | |
543 out3 = parfrac(pf1, pf2, pf3); | |
544 out1.setName('my name'); | |
545 out2(1).setName('my name'); | |
546 out2(2).setName('my name'); | |
547 out3(1).setName('my name'); | |
548 out3(2).setName('my name'); | |
549 out3(3).setName('my name'); | |
550 mout = rebuild(out1); | |
551 % </SyntaxCode> | |
552 stest = true; | |
553 catch err | |
554 disp(err.message) | |
555 stest = false; | |
556 end | |
557 | |
558 % <AlgoDescription> | |
559 % | |
560 % 1) Check that the last entry in the history of 'out' corresponds to | |
561 % 'parfrac'. | |
562 % 2) Check that the original objects are not changed by the setter | |
563 % function | |
564 % 3) Check that the method rebuild produces the same object as 'out'. | |
565 % | |
566 % </AlgoDescription> | |
567 | |
568 atest = true; | |
569 if stest | |
570 % <AlgoCode> | |
571 % Check the last step in the history of 'out' | |
572 % It is the method 'setName' because we set it in above | |
573 if ~strcmp(out1.hist.methodInfo.mname, 'setName'), atest = false; end | |
574 % Check next to the last step in the history of 'out' | |
575 if ~strcmp(out1.hist.inhists.methodInfo.mname, 'parfrac'), atest = false; end | |
576 % Check the originals | |
577 if strcmp(pf1, 'my name'), atest = false; end | |
578 if strcmp(pf2, 'my name'), atest = false; end | |
579 if strcmp(pf3, 'my name'), atest = false; end | |
580 % Check the rebuilt object | |
581 if ~eq(mout, out1, ple2), atest = false; end | |
582 % </AlgoCode> | |
583 else | |
584 atest = false; | |
585 end | |
586 | |
587 % Return a result structure | |
588 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
589 end % END UTP_07 | |
590 | |
591 %% UTP_08 | |
592 | |
593 % <TestDescription> | |
594 % | |
595 % Tests that the parfrac method properly applies history to the read | |
596 % MAT-file constructor. | |
597 % | |
598 % </TestDescription> | |
599 function result = utp_08 | |
600 | |
601 % <SyntaxDescription> | |
602 % | |
603 % Test that the output can be processed back with the 'rebuild' method. | |
604 % | |
605 % </SyntaxDescription> | |
606 | |
607 try | |
608 % <SyntaxCode> | |
609 filename = 'pf.mat'; | |
610 pf = parfrac(pf3); | |
611 save(pf, filename); | |
612 | |
613 out = parfrac(filename); | |
614 mout = rebuild(out); | |
615 % </SyntaxCode> | |
616 stest = true; | |
617 catch err | |
618 disp(err.message) | |
619 stest = false; | |
620 end | |
621 | |
622 % <AlgoDescription> | |
623 % | |
624 % 1) Check that the loaded object is the same as the saved object. | |
625 % 2) Check that the 'rebuild' method produces the same object as 'out'. | |
626 % | |
627 % </AlgoDescription> | |
628 | |
629 atest = true; | |
630 if stest | |
631 % <AlgoCode> | |
632 % Check the loaded object. | |
633 if ~eq(out, pf), atest = false; end | |
634 % Check the rebuilt object | |
635 if ~eq(mout, out, ple1), atest = false; end | |
636 % </AlgoCode> | |
637 delete(filename); | |
638 else | |
639 atest = false; | |
640 end | |
641 | |
642 % Return a result structure | |
643 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
644 end % END UTP_08 | |
645 | |
646 | |
647 %% UTP_09 | |
648 | |
649 % <TestDescription> | |
650 % | |
651 % Tests that the parfrac method properly applies history to the read | |
652 % XML-file constructor. | |
653 % | |
654 % </TestDescription> | |
655 function result = utp_09 | |
656 | |
657 % <SyntaxDescription> | |
658 % | |
659 % Test that the output can be processed back with the 'rebuild' method. | |
660 % | |
661 % </SyntaxDescription> | |
662 | |
663 try | |
664 % <SyntaxCode> | |
665 filename = 'pfm.xml'; | |
666 amat = parfrac(pfm); | |
667 save(amat, filename); | |
668 | |
669 out = parfrac(filename); | |
670 mout = rebuild(out); | |
671 % </SyntaxCode> | |
672 stest = true; | |
673 catch err | |
674 disp(err.message) | |
675 stest = false; | |
676 end | |
677 | |
678 % <AlgoDescription> | |
679 % | |
680 % 1) Check that the loaded object is the same as the saved object. | |
681 % 2) Check that the 'rebuild' method produces the same object as 'out'. | |
682 % | |
683 % </AlgoDescription> | |
684 | |
685 atest = true; | |
686 if stest | |
687 % <AlgoCode> | |
688 % Check the algorithm | |
689 for kk = 1:numel(out) | |
690 % Check the loaded object. | |
691 if ~eq(out(kk), amat(kk)), atest = false; end | |
692 end | |
693 | |
694 % Check the rebuilt object | |
695 for kk = 1:numel(out) | |
696 if ~eq(mout(kk), out(kk), ple2), atest = false; end | |
697 end | |
698 % </AlgoCode> | |
699 delete(filename); | |
700 else | |
701 atest = false; | |
702 end | |
703 | |
704 % Return a result structure | |
705 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
706 end % END UTP_09 | |
707 | |
708 %% UTP_10 | |
709 | |
710 % <TestDescription> | |
711 % | |
712 % Tests that the parfrac method properly doesn't apply history to the | |
713 % struct constructor. | |
714 % | |
715 % </TestDescription> | |
716 function result = utp_10 | |
717 | |
718 % <SyntaxDescription> | |
719 % | |
720 % Test that the output can be processed back with the 'rebuild' method. | |
721 % | |
722 % </SyntaxDescription> | |
723 | |
724 try | |
725 % <SyntaxCode> | |
726 spf3 = struct(pf3); | |
727 spf3.iunits = struct(pf3.iunits); | |
728 spf3.ounits = struct(pf3.ounits); | |
729 spf3.hist = struct(pf3.hist); | |
730 | |
731 out1 = parfrac(struct(pf2)); | |
732 out2 = parfrac(spf3); | |
733 mout1 = rebuild(out1); | |
734 mout2 = rebuild(out2); | |
735 % </SyntaxCode> | |
736 stest = true; | |
737 catch err | |
738 disp(err.message) | |
739 stest = false; | |
740 end | |
741 | |
742 % <AlgoDescription> | |
743 % | |
744 % 1) Check that the last entry in the history of 'out' | |
745 % corresponds to 'parfrac'. | |
746 % 2) Check that the 'rebuild' method produces the same object as 'out'. | |
747 % | |
748 % </AlgoDescription> | |
749 | |
750 atest = true; | |
751 if stest | |
752 % <AlgoCode> | |
753 % Check that the output is a PARFRAC object | |
754 if ~isa(out1,'parfrac'), atest = false; end | |
755 if ~isa(out2,'parfrac'), atest = false; end | |
756 % Check the last step in the history of 'out' | |
757 if ~strcmp(out1.hist.methodInfo.mname, 'setName'), atest = false; end | |
758 if ~strcmp(out2.hist.methodInfo.mname, 'setName'), atest = false; end | |
759 % Check the rebuilt object | |
760 if ~eq(mout1, out1, ple2), atest = false; end | |
761 if ~eq(mout2, out2, ple2), atest = false; end | |
762 % </AlgoCode> | |
763 else | |
764 atest = false; | |
765 end | |
766 | |
767 % Return a result structure | |
768 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
769 end % END UTP_10 | |
770 | |
771 %% UTP_11 | |
772 | |
773 % <TestDescription> | |
774 % | |
775 % Tests that the parfrac method properly applies history to the rational | |
776 % constructor. | |
777 % | |
778 % </TestDescription> | |
779 function result = utp_11 | |
780 | |
781 % <SyntaxDescription> | |
782 % | |
783 % Test that the output can be processed back with the 'rebuild' method. | |
784 % | |
785 % </SyntaxDescription> | |
786 | |
787 try | |
788 % <SyntaxCode> | |
789 ra = rational([1 2 3], [4 5 6 7], 'my rational', unit('V'), unit('Hz')); | |
790 out = parfrac(ra); | |
791 mout = rebuild(out); | |
792 % </SyntaxCode> | |
793 stest = true; | |
794 catch err | |
795 disp(err.message) | |
796 stest = false; | |
797 end | |
798 | |
799 % <AlgoDescription> | |
800 % | |
801 % 1) Check that the last entry in the history of 'out' corresponds to | |
802 % 'parfrac'. | |
803 % 2) Check that the 'rebuild' method produces the same object as 'out'. | |
804 % | |
805 % </AlgoDescription> | |
806 | |
807 atest = true; | |
808 if stest | |
809 % <AlgoCode> | |
810 % Check that the output is a PARFRAC object | |
811 if ~isa(out,'parfrac'), atest = false; end | |
812 % Check the values of the parfract object | |
813 [res, poles, dterms, pmul] = utils.math.cpf('INOPT', 'RAT', 'NUM', ra.num, 'DEN', ra.den, 'MODE', 'SYM'); | |
814 if ~isequal(out.res, res), atest = false; end | |
815 if ~isequal(out.poles, poles), atest = false; end | |
816 if ~isequal(out.dir, dterms), atest = false; end | |
817 if ~isequal(out.pmul, pmul), atest = false; end | |
818 if ~eq(out.iunits, unit('V')), atest = false; end | |
819 if ~eq(out.ounits, unit('Hz')), atest = false; end | |
820 % Check the last step in the history of 'out' | |
821 if ~strcmp(out.hist.methodInfo.mname, 'parfrac'), atest = false; end | |
822 if ~strcmp(out.hist.inhists.methodInfo.mname, 'rational'), atest = false; end | |
823 % Check the rebuilt object | |
824 if ~eq(mout, out, ple2), atest = false; end | |
825 % </AlgoCode> | |
826 else | |
827 atest = false; | |
828 end | |
829 | |
830 % Return a result structure | |
831 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
832 end % END UTP_11 | |
833 | |
834 %% UTP_12 | |
835 | |
836 % <TestDescription> | |
837 % | |
838 % Tests that the parfrac method properly applies history to the pzmodel | |
839 % constructor. | |
840 % | |
841 % </TestDescription> | |
842 function result = utp_12 | |
843 | |
844 % <SyntaxDescription> | |
845 % | |
846 % Test that the output can be processed back with the 'rebuild' method. | |
847 % | |
848 % </SyntaxDescription> | |
849 | |
850 try | |
851 % <SyntaxCode> | |
852 ps = [pz(1) pz(200)]; | |
853 zs = pz(50); | |
854 pzm = pzmodel(1, ps, zs, unit('Hz^2'), unit('V^2')); | |
855 out = parfrac(pzm); | |
856 mout = rebuild(out); | |
857 % </SyntaxCode> | |
858 stest = true; | |
859 catch err | |
860 disp(err.message) | |
861 stest = false; | |
862 end | |
863 | |
864 % <AlgoDescription> | |
865 % | |
866 % 1) Check that the last entry in the history of 'out' corresponds to | |
867 % 'parfrac'. | |
868 % 2) Check that the 'rebuild' method produces the same object as 'out'. | |
869 % | |
870 % </AlgoDescription> | |
871 | |
872 atest = true; | |
873 if stest | |
874 % <AlgoCode> | |
875 % Check that the output is a PARFRAC object | |
876 if ~isa(out,'parfrac'), atest = false; end | |
877 % Check the values of the different proerpties | |
878 gs = utils.math.getk(vertcat(zs(:).ri),vertcat(ps(:).ri),pzm.gain); | |
879 [res, poles, dterms, pmul] = utils.math.cpf('INOPT', 'PZ', 'POLES', vertcat(ps(:).ri), 'ZEROS', vertcat(zs(:).ri), 'GAIN', gs, 'MODE', 'SYM'); | |
880 if ~isequal(out.res, res), atest = false; end | |
881 if ~isequal(out.poles, poles), atest = false; end | |
882 if ~isequal(out.dir, dterms), atest = false; end | |
883 if ~isequal(out.pmul, pmul), atest = false; end | |
884 % Check the last step in the history of 'out' | |
885 if ~strcmp(out.hist.methodInfo.mname, 'parfrac'), atest = false; end | |
886 if ~strcmp(out.hist.inhists.methodInfo.mname, 'pzmodel'), atest = false; end | |
887 % Check the rebuilt object | |
888 if ~eq(mout, out, ple2), atest = false; end | |
889 % </AlgoCode> | |
890 else | |
891 atest = false; | |
892 end | |
893 | |
894 % Return a result structure | |
895 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
896 end % END UTP_12 | |
897 | |
898 %% UTP_13 | |
899 | |
900 % <TestDescription> | |
901 % | |
902 % Tests that the parfrac method properly applies history to the | |
903 % plist(filename) constructor. | |
904 % | |
905 % </TestDescription> | |
906 function result = utp_13 | |
907 | |
908 % <SyntaxDescription> | |
909 % | |
910 % Test that the output can be processed back to an m-file. | |
911 % | |
912 % </SyntaxDescription> | |
913 | |
914 try | |
915 % <SyntaxCode> | |
916 filename1 = 'pf.xml'; | |
917 filename2 = 'pf.mat'; | |
918 | |
919 f1 = parfrac(pf3); | |
920 f2 = parfrac(pf2); | |
921 | |
922 save(f1, filename1); | |
923 save(f2, filename2); | |
924 | |
925 out1 = parfrac(plist('filename', filename1)); | |
926 out2 = parfrac(plist('filename', filename2)); | |
927 | |
928 rout1 = out1.rebuild; | |
929 rout2 = out2.rebuild; | |
930 % </SyntaxCode> | |
931 stest = true; | |
932 catch err | |
933 disp(err.message) | |
934 stest = false; | |
935 end | |
936 | |
937 % <AlgoDescription> | |
938 % | |
939 % 1) Check that the save method doesn't change the input object | |
940 % 2) Check that the 'rebuild' method produces the same object as 'out'. | |
941 % | |
942 % </AlgoDescription> | |
943 | |
944 atest = true; | |
945 if stest | |
946 % <AlgoCode> | |
947 % Check the input object of the save method | |
948 if ~eq(f1, pf3, ple3), atest = false; end | |
949 if ~eq(f1.hist.inhists, pf3.hist) , atest = false; end | |
950 if ~eq(f2, pf2, ple3) , atest = false; end | |
951 if ~eq(f2.hist.inhists, pf2.hist) , atest = false; end | |
952 % The load doesn't have two additionally history steps (save + load) | |
953 if ~eq(out1, f1), atest = false; end | |
954 if ~eq(out2, f2), atest = false; end | |
955 % Rebuild object and check the result | |
956 if ~eq(rout1, out1, ple2), atest = false; end | |
957 if ~eq(rout2, out2, ple2), atest = false; end | |
958 % </AlgoCode> | |
959 % delete test file | |
960 delete(filename1) | |
961 delete(filename2) | |
962 else | |
963 atest = false; | |
964 end | |
965 | |
966 % Return a result structure | |
967 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
968 end % END UTP_13 | |
969 | |
970 %% UTP_14 | |
971 | |
972 % <TestDescription> | |
973 % | |
974 % Tests that the PARFRAC method properly applies history to the | |
975 % plist(conn) constructor. | |
976 % | |
977 % </TestDescription> | |
978 function result = utp_14 | |
979 | |
980 % <SyntaxDescription> | |
981 % | |
982 % Test that the output can be processed back with the rebuild method. | |
983 % | |
984 % </SyntaxDescription> | |
985 | |
986 try | |
987 % <SyntaxCode> | |
988 conn = utpGetConnection(); | |
989 | |
990 sinfo.conn = conn; | |
991 sinfo.experiment_title = 'utp_parfrac_parfrac_14: submit parfrac vector'; | |
992 sinfo.experiment_description = 'utp_parfrac_parfrac_14: &description'; | |
993 sinfo.analysis_description = '<utp_parfrac_parfrac_14>'; | |
994 sinfo.quantity = 'none'; | |
995 sinfo.keywords = 'none'; | |
996 sinfo.reference_ids = ''; | |
997 sinfo.additional_comments = 'none'; | |
998 sinfo.additional_authors = 'no one'; | |
999 | |
1000 plForAutoTest = plist('no dialog', true, 'use selector', false); | |
1001 ids = submit(pfv, sinfo, plForAutoTest); | |
1002 | |
1003 out = parfrac(plist('hostname', utpGetHostname, 'database', utpGetDatabase, 'conn', conn, 'id', ids)); | |
1004 % </SyntaxCode> | |
1005 utpCloseConnection(conn); | |
1006 stest = true; | |
1007 catch err | |
1008 disp(err.message) | |
1009 % Close connection | |
1010 utpCloseConnection(conn); | |
1011 stest = false; | |
1012 end | |
1013 | |
1014 % <AlgoDescription> | |
1015 % | |
1016 % 1) Check that the last entry in the history of 'out' corresponds to | |
1017 % 'parfrac'. | |
1018 % 2) Check that the 'rebuild' method produces the same object as 'out'. | |
1019 % | |
1020 % </AlgoDescription> | |
1021 | |
1022 atest = true; | |
1023 if stest | |
1024 % <AlgoCode> | |
1025 % Check the last step in the history of 'out' | |
1026 for kk = 1:numel(out) | |
1027 if ~strcmp(out(kk).hist.methodInfo.mname, 'parfrac'), atest = false; end | |
1028 end | |
1029 % Check data values | |
1030 if ~eq(out, pfv, ple3), atest = false; end | |
1031 % Rebuild object and check the result | |
1032 mout = rebuild(out); | |
1033 if ~eq(mout, out, ple3), atest = false; end | |
1034 % </AlgoCode> | |
1035 else | |
1036 atest = false; | |
1037 end | |
1038 | |
1039 % Return a result structure | |
1040 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
1041 end % END UTP_14 | |
1042 | |
1043 %% UTP_15 | |
1044 | |
1045 % <TestDescription> | |
1046 % | |
1047 % Tests that the PARFRAC method properly applies history to the | |
1048 % plist(res || poles || dir) constructor. | |
1049 % | |
1050 % </TestDescription> | |
1051 function result = utp_15 | |
1052 | |
1053 % <SyntaxDescription> | |
1054 % | |
1055 % Test that the output can be processed back with the rebuild method. | |
1056 % | |
1057 % </SyntaxDescription> | |
1058 | |
1059 try | |
1060 % <SyntaxCode> | |
1061 res = [1; 2+1i; 2-1i]; | |
1062 ps = [6; 1+3i; 1-3i]; | |
1063 d = [1; 2]; | |
1064 pl = plist('res', res, 'poles', ps, 'dir', d); | |
1065 out = parfrac(pl); | |
1066 mout = rebuild(out); | |
1067 % </SyntaxCode> | |
1068 stest = true; | |
1069 catch err | |
1070 disp(err.message) | |
1071 stest = false; | |
1072 end | |
1073 | |
1074 % <AlgoDescription> | |
1075 % | |
1076 % 1) Check that the last entry in the history of 'out' corresponds to | |
1077 % 'parfrac'. | |
1078 % 2) Check that the 'rebuild' method produces the same object as 'out'. | |
1079 % | |
1080 % </AlgoDescription> | |
1081 | |
1082 atest = true; | |
1083 if stest | |
1084 % <AlgoCode> | |
1085 % Check the last step in the history of 'out' | |
1086 if ~strcmp(out.hist.methodInfo.mname, 'parfrac'), atest = false; end | |
1087 % Check the properties | |
1088 if ~isequal(out.res, res), atest = false; end | |
1089 if ~isequal(out.poles, ps), atest = false; end | |
1090 if ~isequal(out.dir, d), atest = false; end | |
1091 % Rebuild object and check the result | |
1092 if ~eq(mout, out, ple2), atest = false; end | |
1093 % </AlgoCode> | |
1094 else | |
1095 atest = false; | |
1096 end | |
1097 | |
1098 % Return a result structure | |
1099 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
1100 end % END UTP_15 | |
1101 | |
1102 %% UTP_16 | |
1103 | |
1104 % <TestDescription> | |
1105 % | |
1106 % Tests that the PARFRAC method properly applies history to the | |
1107 % plist(pzmodel) constructor. | |
1108 % | |
1109 % </TestDescription> | |
1110 function result = utp_16 | |
1111 | |
1112 % <SyntaxDescription> | |
1113 % | |
1114 % Test that the output can be processed back with the rebuild method. | |
1115 % | |
1116 % </SyntaxDescription> | |
1117 | |
1118 try | |
1119 % <SyntaxCode> | |
1120 ps = [pz(1) pz(200)]; | |
1121 zs = pz(50); | |
1122 pzm = pzmodel(1, ps, zs, unit('Hz'), unit('V')); | |
1123 pl = plist('pzmodel', pzm); | |
1124 out = parfrac(pl); | |
1125 | |
1126 rout = rebuild(out); | |
1127 % </SyntaxCode> | |
1128 stest = true; | |
1129 catch err | |
1130 disp(err.message) | |
1131 stest = false; | |
1132 end | |
1133 | |
1134 % <AlgoDescription> | |
1135 % | |
1136 % 1) Check that the last entry in the history of 'out' corresponds to | |
1137 % 'parfrac'. | |
1138 % 2) Check that the 'rebuild' method produces the same object as 'out'. | |
1139 % | |
1140 % </AlgoDescription> | |
1141 | |
1142 atest = true; | |
1143 if stest | |
1144 % <AlgoCode> | |
1145 % Check the last step in the history of 'out' | |
1146 if ~strcmp(out.hist.methodInfo.mname, 'parfrac'), atest = false; end | |
1147 % Check the next to the last step in the history. | |
1148 % It must be the history of the pole/zero model (here 'pzmodel') | |
1149 if ~strcmp(out.hist.inhists.methodInfo.mname, 'pzmodel'), atest = false; end | |
1150 % Check values | |
1151 gs = utils.math.getk(vertcat(zs(:).ri),vertcat(ps(:).ri),pzm.gain); | |
1152 [res, poles, dterms, pmul] = utils.math.cpf('INOPT', 'PZ', 'POLES', vertcat(ps(:).ri), 'ZEROS', vertcat(zs(:).ri), 'GAIN', gs, 'MODE', 'SYM'); | |
1153 if ~isequal(out.res, res), atest = false; end | |
1154 if ~isequal(out.poles, poles), atest = false; end | |
1155 if ~isequal(out.dir, dterms), atest = false; end | |
1156 if ~isequal(out.pmul, pmul), atest = false; end | |
1157 if ~eq(out.iunits, unit('Hz')), atest = false; end | |
1158 if ~eq(out.ounits, unit('V')), atest = false; end | |
1159 % Rebuild object and check the result | |
1160 if ~eq(rout, out, ple1), atest = false; end | |
1161 % </AlgoCode> | |
1162 else | |
1163 atest = false; | |
1164 end | |
1165 | |
1166 % Return a result structure | |
1167 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
1168 end % END UTP_16 | |
1169 | |
1170 %% UTP_17 | |
1171 | |
1172 % <TestDescription> | |
1173 % | |
1174 % Tests that the PARFRAC method properly applies history to the | |
1175 % plist(parfrac) constructor. | |
1176 % | |
1177 % </TestDescription> | |
1178 function result = utp_17 | |
1179 | |
1180 % <SyntaxDescription> | |
1181 % | |
1182 % Test that the output can be processed back with the rebuild method. | |
1183 % | |
1184 % </SyntaxDescription> | |
1185 | |
1186 try | |
1187 % <SyntaxCode> | |
1188 ra = rational([1 2 3], [4 5 6 7], 'my rational', unit('V'), unit('Hz')); | |
1189 pl = plist('rational', ra); | |
1190 out = parfrac(pl); | |
1191 | |
1192 mout = rebuild(out); | |
1193 % </SyntaxCode> | |
1194 stest = true; | |
1195 catch err | |
1196 disp(err.message) | |
1197 stest = false; | |
1198 end | |
1199 | |
1200 % <AlgoDescription> | |
1201 % | |
1202 % 1) Check that the last entry in the history of 'out' corresponds to | |
1203 % 'parfrac'. | |
1204 % 2) Check that the 'rebuild' method produces the same object as 'out'. | |
1205 % | |
1206 % </AlgoDescription> | |
1207 | |
1208 atest = true; | |
1209 if stest | |
1210 % <AlgoCode> | |
1211 % Check the last step in the history of 'out' | |
1212 if ~strcmp(out.hist.methodInfo.mname, 'parfrac'), atest = false; end | |
1213 % Check the next to the last step in the history. | |
1214 % It must be the history of the partial fraction model (here 'parfrac') | |
1215 if ~strcmp(out.hist.inhists.methodInfo.mname, 'rational'), atest = false; end | |
1216 % Check values | |
1217 [res, poles, dterms, pmul] = utils.math.cpf('INOPT', 'RAT', 'NUM', ra.num, 'DEN', ra.den, 'MODE', 'SYM'); | |
1218 if ~isequal(out.res, res), atest = false; end | |
1219 if ~isequal(out.poles, poles), atest = false; end | |
1220 if ~isequal(out.dir, dterms), atest = false; end | |
1221 if ~isequal(out.pmul, pmul), atest = false; end | |
1222 if ~eq(out.iunits, unit('V')), atest = false; end | |
1223 if ~eq(out.ounits, unit('Hz')), atest = false; end | |
1224 % Rebuild object and check the result | |
1225 if ~eq(mout, out, ple1), atest = false; end | |
1226 % </AlgoCode> | |
1227 else | |
1228 atest = false; | |
1229 end | |
1230 | |
1231 % Return a result structure | |
1232 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
1233 end % END UTP_17 | |
1234 | |
1235 %% UTP_18 | |
1236 | |
1237 % <TestDescription> | |
1238 % | |
1239 % Tests that the PARFRAC method properly applies history to the | |
1240 % plist(<plist-object>) constructor. | |
1241 % | |
1242 % </TestDescription> | |
1243 function result = utp_18 | |
1244 | |
1245 % <SyntaxDescription> | |
1246 % | |
1247 % Test that the output can be processed back with the rebuild method. | |
1248 % | |
1249 % </SyntaxDescription> | |
1250 | |
1251 try | |
1252 % <SyntaxCode> | |
1253 ra = rational([1 2 3], [4 5 6 7], 'my rational', unit('V'), unit('Hz')); | |
1254 pl = plist('rational', ra); | |
1255 out1 = parfrac(plist('plist', pl)); | |
1256 out2 = parfrac(plist('plist', plist())); % empty plist | |
1257 | |
1258 rout1 = rebuild(out1); | |
1259 rout2 = rebuild(out2); | |
1260 % </SyntaxCode> | |
1261 stest = true; | |
1262 catch err | |
1263 disp(err.message) | |
1264 stest = false; | |
1265 end | |
1266 | |
1267 % <AlgoDescription> | |
1268 % | |
1269 % 1) Check that the last entry in the history of 'out' corresponds to | |
1270 % 'parfrac'. | |
1271 % 2) Check that the 'rebuild' method produces the same object as 'out'. | |
1272 % | |
1273 % </AlgoDescription> | |
1274 | |
1275 atest = true; | |
1276 if stest | |
1277 % <AlgoCode> | |
1278 % Check the last step in the history of 'out1' | |
1279 if ~strcmp(out1.hist.methodInfo.mname, 'parfrac'), atest = false; end | |
1280 % Check the next to the last step in the history. | |
1281 % It must be the history of the partial fraction model (here 'parfrac') | |
1282 if ~strcmp(out1.hist.inhists.methodInfo.mname, 'rational'), atest = false; end | |
1283 % Check values | |
1284 if ~eq(out1.iunits, unit('V')), atest = false; end | |
1285 if ~eq(out1.ounits, unit('Hz')), atest = false; end | |
1286 % Check the last step in the history of 'out2' | |
1287 if ~strcmp(out2.hist.methodInfo.mname, 'parfrac'), atest = false; end | |
1288 % Check the next to the last step in the history. | |
1289 if ~isempty(out2.hist.inhists), atest = false; end | |
1290 % Rebuild object and check the result | |
1291 if ~eq(rout1, out1, ple1), atest = false; end | |
1292 if ~eq(rout2, out2, ple1), atest = false; end | |
1293 % </AlgoCode> | |
1294 else | |
1295 atest = false; | |
1296 end | |
1297 | |
1298 % Return a result structure | |
1299 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
1300 end % END UTP_18 | |
1301 | |
1302 %% UTP_19 | |
1303 | |
1304 % <TestDescription> | |
1305 % | |
1306 % Tests that the PARFRAC method properly applies history to the conn+Id | |
1307 % constructor. | |
1308 % | |
1309 % </TestDescription> | |
1310 function result = utp_19 | |
1311 | |
1312 % <SyntaxDescription> | |
1313 % | |
1314 % Test that the output can be processed back with the rebuild method. | |
1315 % | |
1316 % </SyntaxDescription> | |
1317 | |
1318 conn = utpGetConnection | |
1319 try | |
1320 % <SyntaxCode> | |
1321 | |
1322 sinfo.conn = conn; | |
1323 sinfo.experiment_title = 'utp_parfrac_parfrac_19: submit parfrac'; | |
1324 sinfo.experiment_description = 'utp_parfrac_parfrac_19: description'; | |
1325 sinfo.analysis_description = 'utp_parfrac_parfrac_19'; | |
1326 sinfo.quantity = 'none'; | |
1327 sinfo.keywords = 'none'; | |
1328 sinfo.reference_ids = ''; | |
1329 sinfo.additional_comments = 'none'; | |
1330 sinfo.additional_authors = 'no one'; | |
1331 | |
1332 plForAutoTest = plist('no dialog', true, 'use selector', false); | |
1333 [ids] = submit(pf3, sinfo, plForAutoTest); | |
1334 | |
1335 out = parfrac(conn, ids); | |
1336 % </SyntaxCode> | |
1337 utpCloseConnection(conn); | |
1338 stest = true; | |
1339 catch err | |
1340 disp(err.message) | |
1341 % Close connection | |
1342 utpCloseConnection(conn); | |
1343 stest = false; | |
1344 end | |
1345 | |
1346 % <AlgoDescription> | |
1347 % | |
1348 % 1) Check that the last entry in the history of 'out' corresponds to | |
1349 % 'parfrac'. | |
1350 % 2) Check that the 'rebuild' method produces the same object as 'out'. | |
1351 % | |
1352 % </AlgoDescription> | |
1353 | |
1354 atest = true; | |
1355 if stest | |
1356 % <AlgoCode> | |
1357 % Check the last step in the history of 'out' | |
1358 if ~strcmp(out.hist.methodInfo.mname, 'parfrac'), atest = false; end | |
1359 % Check data values | |
1360 if ~eq(out,pf3, ple3), atest = false; end | |
1361 % Check the history except the additional 'submit' + 'retrieve' steps | |
1362 if ~eq(out.hist.inhists, pf3.hist), atest = false; end | |
1363 % Check the rebuilt object | |
1364 mout = rebuild(out); | |
1365 if ~eq(mout, out, ple3), atest = false; end | |
1366 % </AlgoCode> | |
1367 else | |
1368 atest = false; | |
1369 end | |
1370 | |
1371 % Return a result structure | |
1372 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
1373 end % END UTP_19 | |
1374 | |
1375 %% UTP_20 | |
1376 | |
1377 % <TestDescription> | |
1378 % | |
1379 % Tests that the PARFRAC method properly applies history to the | |
1380 % res + poles + direct terms object constructor. | |
1381 % | |
1382 % </TestDescription> | |
1383 function result = utp_20 | |
1384 | |
1385 % <SyntaxDescription> | |
1386 % | |
1387 % Test that the output can be processed back with the rebuild method. | |
1388 % | |
1389 % </SyntaxDescription> | |
1390 | |
1391 try | |
1392 % <SyntaxCode> | |
1393 res = [1; 2+1i; 2-1i]; | |
1394 ps = [6; 1+3i; 1-3i]; | |
1395 d = [1; 2]; | |
1396 out = parfrac(res, ps, d); | |
1397 | |
1398 rout = rebuild(out); | |
1399 % </SyntaxCode> | |
1400 stest = true; | |
1401 catch err | |
1402 disp(err.message) | |
1403 stest = false; | |
1404 end | |
1405 | |
1406 % <AlgoDescription> | |
1407 % | |
1408 % 1) Check that the last entry in the history of 'out' corresponds to | |
1409 % 'parfrac'. | |
1410 % 2) Check that the 'rebuild' method produces the same object as 'out'. | |
1411 % | |
1412 % </AlgoDescription> | |
1413 | |
1414 atest = true; | |
1415 if stest | |
1416 % <AlgoCode> | |
1417 % Check the last step in the history of 'out' | |
1418 if ~strcmp(out.hist.methodInfo.mname, 'parfrac'), atest = false; end | |
1419 % Check properties | |
1420 if ~isequal(out.res, res), atest = false; end | |
1421 if ~isequal(out.poles, ps), atest = false; end | |
1422 if ~isequal(out.dir, d), atest = false; end | |
1423 % Rebuild object and check the result | |
1424 if ~eq(rout, out, ple1), atest = false; end | |
1425 % </AlgoCode> | |
1426 else | |
1427 atest = false; | |
1428 end | |
1429 | |
1430 % Return a result structure | |
1431 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
1432 end % END UTP_20 | |
1433 | |
1434 %% UTP_21 | |
1435 | |
1436 % <TestDescription> | |
1437 % | |
1438 % Tests that the PARFRAC method properly applies history to the | |
1439 % res + poles + direct terms + name object constructor. | |
1440 % | |
1441 % </TestDescription> | |
1442 function result = utp_21 | |
1443 | |
1444 % <SyntaxDescription> | |
1445 % | |
1446 % Test that the output can be processed back with the rebuild method. | |
1447 % | |
1448 % </SyntaxDescription> | |
1449 | |
1450 try | |
1451 % <SyntaxCode> | |
1452 res = [1; 2+1i; 2-1i]; | |
1453 ps = [6; 1+3i; 1-3i]; | |
1454 d = [1; 2]; | |
1455 name = 'my new crazy name'; | |
1456 out = parfrac(res, ps, d, name); | |
1457 | |
1458 rout = rebuild(out); | |
1459 % </SyntaxCode> | |
1460 stest = true; | |
1461 catch err | |
1462 disp(err.message) | |
1463 stest = false; | |
1464 end | |
1465 | |
1466 % <AlgoDescription> | |
1467 % | |
1468 % 1) Check that the last entry in the history of 'out' corresponds to | |
1469 % 'parfrac'. | |
1470 % 2) Check that the 'rebuild' method produces the same object as 'out'. | |
1471 % | |
1472 % </AlgoDescription> | |
1473 | |
1474 atest = true; | |
1475 if stest | |
1476 % <AlgoCode> | |
1477 % Check the last step in the history of 'out' | |
1478 if ~strcmp(out.hist.methodInfo.mname, 'parfrac'), atest = false; end | |
1479 % Check properties | |
1480 if ~isequal(out.res, res), atest = false; end | |
1481 if ~isequal(out.poles, ps), atest = false; end | |
1482 if ~isequal(out.dir, d), atest = false; end | |
1483 if ~isequal(out.name, name), atest = false; end | |
1484 % Rebuild object and check the result | |
1485 if ~eq(rout, out, ple1), atest = false; end | |
1486 % </AlgoCode> | |
1487 else | |
1488 atest = false; | |
1489 end | |
1490 | |
1491 % Return a result structure | |
1492 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
1493 end % END UTP_21 | |
1494 | |
1495 %% UTP_22 | |
1496 | |
1497 % <TestDescription> | |
1498 % | |
1499 % Tests that the PARFRAC method properly applies history to the | |
1500 % res + poles + direct terms + name + iunits + ounits object constructor. | |
1501 % | |
1502 % </TestDescription> | |
1503 function result = utp_22 | |
1504 | |
1505 % <SyntaxDescription> | |
1506 % | |
1507 % Test that the output can be processed back with the rebuild method. | |
1508 % | |
1509 % </SyntaxDescription> | |
1510 | |
1511 try | |
1512 % <SyntaxCode> | |
1513 res = [1; 2+1i; 2-1i]; | |
1514 ps = [6; 1+3i; 1-3i]; | |
1515 d = [1; 2]; | |
1516 name = 'I''m crazy'; | |
1517 iu = unit('V^2'); | |
1518 ou = 's^2/3'; | |
1519 out = parfrac(res, ps, d, name, iu, ou); | |
1520 | |
1521 rout = rebuild(out); | |
1522 % </SyntaxCode> | |
1523 stest = true; | |
1524 catch err | |
1525 disp(err.message) | |
1526 stest = false; | |
1527 end | |
1528 | |
1529 % <AlgoDescription> | |
1530 % | |
1531 % 1) Check that the last entry in the history of 'out' corresponds to | |
1532 % 'parfrac'. | |
1533 % 2) Check that the 'rebuild' method produces the same object as 'out'. | |
1534 % | |
1535 % </AlgoDescription> | |
1536 | |
1537 atest = true; | |
1538 if stest | |
1539 % <AlgoCode> | |
1540 % Check the last step in the history of 'out' | |
1541 if ~strcmp(out.hist.methodInfo.mname, 'parfrac'), atest = false; end | |
1542 % Check properties | |
1543 if ~isequal(out.res, res), atest = false; end | |
1544 if ~isequal(out.poles, ps), atest = false; end | |
1545 if ~isequal(out.dir, d), atest = false; end | |
1546 if ~isequal(out.name, name), atest = false; end | |
1547 if ~eq(out.iunits, iu), atest = false; end | |
1548 if ~eq(out.ounits, unit(ou), ple1), atest = false; end | |
1549 % Rebuild object and check the result | |
1550 if ~eq(rout, out, ple1), atest = false; end | |
1551 % </AlgoCode> | |
1552 else | |
1553 atest = false; | |
1554 end | |
1555 | |
1556 % Return a result structure | |
1557 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
1558 end % END UTP_22 | |
1559 | |
1560 end |