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