comparison testing/utp_1.1/utps/mfir/utp_mfir_mfir.m @ 45:a59cdb8aaf31 database-connection-manager

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