comparison testing/utp_1.1/utps/pzmodel/utp_pzmodel_resp.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_PZMODEL_RESP a set of UTPs for the pzmodel/resp method
2 %
3 % M Hewitson 06-08-08
4 %
5 % $Id: utp_pzmodel_resp.m,v 1.7 2010/03/15 15:57:06 ingo Exp $
6 %
7
8 % <MethodDescription>
9 %
10 % The resp method of the pzmodel class returns the complex response of a pzmodel
11 % as an Analysis Object. For a command with no output variables plots the method
12 % the result into a diagram.
13 %
14 % </MethodDescription>
15
16 function results = utp_pzmodel_resp(varargin)
17
18 % Check the inputs
19 if nargin == 0
20
21 % Some keywords
22 class = 'pzmodel';
23 mthd = 'resp';
24
25 results = [];
26 disp('******************************************************');
27 disp(['**** Running UTPs for ' class '/' mthd]);
28 disp('******************************************************');
29
30 % Test PZMODEL objects
31 [pz1, pz2, pz3, pz4, pz5, pzv, pzm] = get_test_objects_pzmodel;
32
33 % Exception list for the UTPs:
34 [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples();
35
36 warning('This UTP needs a complete update');
37
38 % Run the tests
39 results = [results utp_01]; % getInfo call
40 results = [results utp_02]; % Vector input
41 results = [results utp_03]; % Matrix input
42 results = [results utp_04]; % List input
43 results = [results utp_05]; % Test with mixed input
44 results = [results utp_06]; % Test history is working
45 results = [results utp_07]; % Test the modify call works
46 results = [results utp_08]; % Test input data shape == output data shape
47 results = [results utp_09]; % Test output of the data
48 results = [results utp_10]; % Test with f = ao.y
49 results = [results utp_11]; % Test with f
50 results = [results utp_12]; % Test with f1, f2 and nf
51 results = [results utp_13]; % Test with f1, f2 and nf AND 'scale'
52
53 % Make surethat all figures are closed
54 close all;
55
56 disp('Done.');
57 disp('******************************************************');
58
59 elseif nargin == 1 % Check for UTP functions
60 if strcmp(varargin{1}, 'isutp')
61 results = 1;
62 else
63 results = 0;
64 end
65 else
66 error('### Incorrect inputs')
67 end
68
69 %% UTP_01
70
71 % <TestDescription>
72 %
73 % Tests that the getInfo call works for this method.
74 %
75 % </TestDescription>
76 function result = utp_01
77
78
79 % <SyntaxDescription>
80 %
81 % Test that the getInfo call works for no sets, all sets, and each set
82 % individually.
83 %
84 % </SyntaxDescription>
85
86 try
87 % <SyntaxCode>
88 % Call for no sets
89 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']);
90 % Call for all sets
91 io(2) = eval([class '.getInfo(''' mthd ''')']);
92 % Call for each set
93 for kk=1:numel(io(2).sets)
94 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']);
95 end
96 % </SyntaxCode>
97 stest = true;
98 catch err
99 disp(err.message)
100 stest = false;
101 end
102
103 % <AlgoDescription>
104 %
105 % 1) Check that getInfo call returned an minfo object in all cases.
106 % 2) Check that all plists have the correct parameters.
107 %
108 % </AlgoDescription>
109
110 atest = true;
111 if stest
112 % <AlgoCode>
113 % check we have minfo objects
114 if isa(io, 'minfo')
115 %%% SET 'None'
116 if ~isempty(io(1).sets), atest = false; end
117 if ~isempty(io(1).plists), atest = false; end
118 %%% Check all Sets
119 if ~any(strcmpi(io(2).sets, 'List')), atest = false; end
120 if ~any(strcmpi(io(2).sets, 'Range')), atest = false; end
121 if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end
122 %%%%%%%%%% SET 'List'
123 if io(3).plists.nparams ~= 2, atest = false; end
124 % Check key
125 if ~io(3).plists.isparam('f'), atest = false; end
126 if ~io(3).plists.isparam('bank'), atest = false; end
127 % Check default value
128 if ~isEmptyDouble(io(3).plists.find('f')), atest = false; end
129 if ~isequal(io(3).plists.find('bank'), 'none'), atest = false; end
130 % Check options
131 if ~isequal(io(3).plists.getOptionsForParam('f'), {[]}), atest = false; end
132 if ~isequal(io(3).plists.getOptionsForParam('bank'), {'none', 'serial', 'parallel'}), atest = false; end
133 %%%%%%%%%% SET 'Range'
134 if io(4).plists.nparams ~= 5, atest = false; end
135 % Check key
136 if ~io(4).plists.isparam('f1'), atest = false; end
137 if ~io(4).plists.isparam('f2'), atest = false; end
138 if ~io(4).plists.isparam('nf'), atest = false; end
139 if ~io(4).plists.isparam('scale'), atest = false; end
140 if ~io(4).plists.isparam('bank'), atest = false; end
141 % Check default value
142 if ~isEmptyDouble(io(4).plists.find('f1')), atest = false; end
143 if ~isEmptyDouble(io(4).plists.find('f2')), atest = false; end
144 if ~isequal(io(4).plists.find('nf'), 1000), atest = false; end
145 if ~isequal(io(4).plists.find('scale'), 'log'), atest = false; end
146 if ~isequal(io(4).plists.find('bank'), 'none'), atest = false; end
147 % Check options
148 if ~isequal(io(4).plists.getOptionsForParam('f1'), {[]}), atest = false; end
149 if ~isequal(io(4).plists.getOptionsForParam('f2'), {[]}), atest = false; end
150 if ~isequal(io(4).plists.getOptionsForParam('nf'), {1000}), atest = false; end
151 if ~isequal(io(4).plists.getOptionsForParam('scale'), {'lin', 'log'}), atest = false; end
152 if ~isequal(io(4).plists.getOptionsForParam('bank'), {'none', 'serial', 'parallel'}), atest = false; end
153 end
154 % </AlgoCode>
155 else
156 atest = false;
157 end
158
159 % Return a result structure
160 result = utp_prepare_result(atest, stest, dbstack, mfilename);
161 end % END UTP_01
162
163 %% UTP_02
164
165 % <TestDescription>
166 %
167 % Tests that the resp method works with a vector of PZMODEL objects as input.
168 %
169 % </TestDescription>
170 function result = utp_02
171
172 % <SyntaxDescription>
173 %
174 % Test that the resp method works for a vector of PZMODEL objects as input.
175 % Test the method with an output and with no output (a diagram must appear)
176 %
177 % </SyntaxDescription>
178
179 try
180 % <SyntaxCode>
181 % Make sure that all figures are closed.
182 close all;
183 resp(pzv);
184 out = resp(pzv);
185 % </SyntaxCode>
186 stest = true;
187 catch err
188 disp(err.message)
189 stest = false;
190 end
191
192 % <AlgoDescription>
193 %
194 % 1) Test the right number of lines in the diagram.
195 % 2) Check that the number of elements in 'out' is the same as in 'pzv'
196 % 3) Check that each output PZMODEL contains the correct data.
197 %
198 % </AlgoDescription>
199
200 atest = true;
201 if stest
202 % <AlgoCode>
203 % Get the current figure.
204 fi = gcf;
205 % Get ALL axes including the legends.
206 ax = get(fi, 'Children');
207 % Select only the 'axes' with the lines
208 ax = ax(ismember(get(ax(:), 'Tag'), ''));
209 % Get the lines of both axes
210 lines = get(ax(:), 'Children');
211 % Check that the diagram have the same number of lines as the output
212 % object
213 if max(cellfun('size', lines, 1)) ~= numel(pzv), atest = false; end
214 % Check the number of output objects.
215 if ~isequal(size(out), size(pzv)), atest = false; end
216 % Check each output against the default values for f1, f2 and nf
217 for ii = 1:numel(out)
218 f1 = getlowerFreq(pzv(ii))/10;
219 f2 = getupperFreq(pzv(ii))*10;
220 nf = find(pzmodel.getInfo('resp', 'Range').plists, 'nf');
221 if ~isa(out(ii), 'ao'), atest = false; end
222 if ~strcmp(out(ii).hist.methodInfo.mname, 'resp'), atest = false; end
223 if out(ii).x(1) ~= f1, atest = false; end
224 if out(ii).x(end) ~= f2, atest = false; end
225 if numel(out(ii).x) ~= nf, atest = false; end
226 end
227 % </AlgoCode>
228 else
229 atest = false;
230 end
231
232 % Return a result structure
233 result = utp_prepare_result(atest, stest, dbstack, mfilename);
234 end % END UTP_02
235
236 %% UTP_03
237
238 % <TestDescription>
239 %
240 % Tests that the resp method works with a matrix of PZMODEL objects as input.
241 %
242 % </TestDescription>
243 function result = utp_03
244
245 % <SyntaxDescription>
246 %
247 % Test that the resp method works for a matrix of PZMODEL objects as input.
248 % Test the method with an output and with no output (a diagram must appear)
249 %
250 % </SyntaxDescription>
251
252 try
253 % <SyntaxCode>
254 % Make sure that all figures are closed.
255 close all;
256 pzmat = [pz5, pz3, pz2; pz1, pz5, pz3];
257 resp(pzmat);
258 out = resp(pzmat);
259 % </SyntaxCode>
260 stest = true;
261 catch err
262 disp(err.message)
263 stest = false;
264 end
265
266 % <AlgoDescription>
267 %
268 % 1) Test the right number of lines in the diagram.
269 % 2) Check that the number of elements in 'out' is the same as in 'pzmat'
270 % 3) Check that each output PZMODEL contains the correct data.
271 %
272 % </AlgoDescription>
273
274 atest = true;
275 if stest
276 % <AlgoCode>
277 % Get the current figure.
278 fi = gcf;
279 % Get ALL axes including the legends.
280 ax = get(fi, 'Children');
281 % Select only the 'axes' with the lines
282 ax = ax(ismember(get(ax(:), 'Tag'), ''));
283 % Get the lines of both axes
284 lines = get(ax(:), 'Children');
285 % Check that the diagram have the same number of lines as the output
286 % object
287 if max(cellfun('size', lines, 1)) ~= numel(pzmat), atest = false; end
288 % Check the number of output objects.
289 if ~isequal(size(out), size(pzmat)), atest = false; end
290 % Check each output against the default values for f1, f2 and nf
291 for ii = 1:numel(out)
292 f1 = getlowerFreq(pzmat(ii))/10;
293 f2 = getupperFreq(pzmat(ii))*10;
294 nf = find(pzmodel.getInfo('resp', 'Range').plists, 'nf');
295 if ~isa(out(ii), 'ao'), atest = false; end
296 if ~strcmp(out(ii).hist.methodInfo.mname, 'resp'), atest = false; end
297 if out(ii).x(1) ~= f1, atest = false; end
298 if out(ii).x(end) ~= f2, atest = false; end
299 if numel(out(ii).x) ~= nf, atest = false; end
300 end
301 % </AlgoCode>
302 else
303 atest = false;
304 end
305
306 % Return a result structure
307 result = utp_prepare_result(atest, stest, dbstack, mfilename);
308 end % END UTP_03
309
310 %% UTP_04
311
312 % <TestDescription>
313 %
314 % Tests that the pzmat method works with a list of PZMODEL objects as input.
315 %
316 % </TestDescription>
317 function result = utp_04
318
319 % <SyntaxDescription>
320 %
321 % Test that the resp method works for a list of PZMODEL objects as input.
322 % Test the method with an output and with no output (a diagram must appear)
323 %
324 % </SyntaxDescription>
325
326 try
327 % <SyntaxCode>
328 close all;
329 resp(pz1,pz2,pz3);
330 out = resp(pz1,pz2,pz3);
331 % </SyntaxCode>
332 stest = true;
333 catch err
334 disp(err.message)
335 stest = false;
336 end
337
338 % <AlgoDescription>
339 %
340 % 1) Test the right number of lines in the diagram.
341 % 2) Check that the number of elements in 'out' is the same as in 'pzmat'
342 % 3) Check that each output PZMODEL contains the correct data.
343 %
344 % </AlgoDescription>
345
346 atest = true;
347 pzin = [pz1,pz2,pz3];
348 if stest
349 % <AlgoCode>
350 % Get the current figure.
351 fi = gcf;
352 % Get ALL axes including the legends.
353 ax = get(fi, 'Children');
354 % Select only the 'axes' with the lines
355 ax = ax(ismember(get(ax(:), 'Tag'), ''));
356 % Get the lines of both axes
357 lines = get(ax(:), 'Children');
358 % Check that the diagram have the same number of lines as the output
359 % object
360 if max(cellfun('size', lines, 1)) ~= numel(pzin), atest = false; end
361 % Check the number of output objects.
362 if ~isequal(size(out), size(pzin)), atest = false; end
363 % Check each output against the default values for f1, f2 and nf
364 for ii = 1:numel(out)
365 f1 = getlowerFreq(pzin(ii))/10;
366 f2 = getupperFreq(pzin(ii))*10;
367 nf = find(pzmodel.getInfo('resp', 'Range').plists, 'nf');
368 if ~isa(out(ii), 'ao'), atest = false; end
369 if ~strcmp(out(ii).hist.methodInfo.mname, 'resp'), atest = false; end
370 if out(ii).x(1) ~= f1, atest = false; end
371 if out(ii).x(end) ~= f2, atest = false; end
372 if numel(out(ii).x) ~= nf, atest = false; end
373 end
374 % </AlgoCode>
375 else
376 atest = false;
377 end
378
379 % Return a result structure
380 result = utp_prepare_result(atest, stest, dbstack, mfilename);
381 end % END UTP_04
382
383 %% UTP_05
384
385 % <TestDescription>
386 %
387 % Tests that the resp method works with a mix of different shaped PZMODEL
388 % objects as input.
389 %
390 % </TestDescription>
391 function result = utp_05
392
393 % <SyntaxDescription>
394 %
395 % Test that the resp method works with an input of matrices and vectors
396 % and single PZMODEL objects. Test the method with an output and with no
397 % output (a diagram must appear)
398 %
399 % </SyntaxDescription>
400
401 try
402 % <SyntaxCode>
403 close all;
404 pzmat = [pz5, pz3, pz2; pz1, pz5, pz3];
405 resp(pz1,pzv,pz2,pzmat,pz3);
406 out = resp(pz1,pzv,pz2,pzmat,pz3);
407 % </SyntaxCode>
408 stest = true;
409 catch err
410 disp(err.message)
411 stest = false;
412 end
413
414 % <AlgoDescription>
415 %
416 % 1) Test the right number of lines in the diagram.
417 % 2) Check that the number of elements in 'out' is the same as in 'pzmat'
418 % 3) Check that each output PZMODEL contains the correct data.
419 %
420 % </AlgoDescription>
421
422 atest = true;
423 pzin = [pz1,reshape(pzv,1,[]),pz2,reshape(pzmat,1,[]),pz3];
424 if stest
425 % <AlgoCode>
426 % Get the current figure.
427 fi = gcf;
428 % Get ALL axes including the legends.
429 ax = get(fi, 'Children');
430 % Select only the 'axes' with the lines
431 ax = ax(ismember(get(ax(:), 'Tag'), ''));
432 % Get the lines of both axes
433 lines = get(ax(:), 'Children');
434 % Check that the diagram have the same number of lines as the output
435 % object
436 if max(cellfun('size', lines, 1)) ~= numel(pzin), atest = false; end
437 % Check the number of output objects.
438 if ~isequal(size(out), size(pzin)), atest = false; end
439 % Check each output against the default values for f1, f2 and nf
440 for ii = 1:numel(out)
441 f1 = getlowerFreq(pzin(ii))/10;
442 f2 = getupperFreq(pzin(ii))*10;
443 nf = find(pzmodel.getInfo('resp', 'Range').plists, 'nf');
444 if ~isa(out(ii), 'ao'), atest = false; end
445 if ~strcmp(out(ii).hist.methodInfo.mname, 'resp'), atest = false; end
446 if out(ii).x(1) ~= f1, atest = false; end
447 if out(ii).x(end) ~= f2, atest = false; end
448 if numel(out(ii).x) ~= nf, atest = false; end
449 end
450 % </AlgoCode>
451 else
452 atest = false;
453 end
454
455 % Return a result structure
456 result = utp_prepare_result(atest, stest, dbstack, mfilename);
457 end % END UTP_05
458
459 %% UTP_06
460
461 % <TestDescription>
462 %
463 % Tests that the resp method properly applies history.
464 %
465 % </TestDescription>
466 function result = utp_06
467
468 % <SyntaxDescription>
469 %
470 % Test that the result of applying the resp method can be processed back.
471 %
472 % </SyntaxDescription>
473
474 try
475 % <SyntaxCode>
476 close all;
477 resp(pz5);
478 out = resp(pz5);
479 mout = rebuild(out);
480 % </SyntaxCode>
481 stest = true;
482 catch err
483 disp(err.message)
484 stest = false;
485 end
486
487 % <AlgoDescription>
488 %
489 % 1) Check that the last entry in the history of 'out' corresponds to
490 % 'resp'.
491 % 2) Check that re-built object is the same object as the input.
492 %
493 % </AlgoDescription>
494
495 atest = true;
496 if stest
497 % <AlgoCode>
498 % Get the current figure.
499 fi = gcf;
500 % Get ALL axes including the legends.
501 ax = get(fi, 'Children');
502 % Select only the 'axes' with the lines
503 ax = ax(ismember(get(ax(:), 'Tag'), ''));
504 % Get the lines of both axes
505 lines = get(ax(:), 'Children');
506 x = get(lines{1}, 'XData');
507 y1 = get(lines{1}, 'YData');
508 y2 = get(lines{2}, 'YData');
509 if ~isequal(x, out.x.'), atest = false; end
510 if ~isequal(y2, abs(out.y)'), atest = false; end
511 if ~isequal(y1, utils.math.phase(out.y)'), atest = false; end
512 % Check the last step in the history of 'out'
513 if ~strcmp(out.hist.methodInfo.mname, 'resp'), atest = false; end
514 % Run 'test.m' and check the result
515 if ~eq(mout, out, ple2), atest = false; end
516 % </AlgoCode>
517 else
518 atest = false;
519 end
520
521 % Return a result structure
522 result = utp_prepare_result(atest, stest, dbstack, mfilename);
523 end % END UTP_06
524
525 %% UTP_07
526
527 % <TestDescription>
528 %
529 % Tests that modify command plots the response into a diagram.
530 %
531 % </TestDescription>
532 function result = utp_07
533
534 % <SyntaxDescription>
535 %
536 % Tests that modify command plots the response into a diagram.
537 %
538 % </SyntaxDescription>
539
540 try
541 % <SyntaxCode>
542 close all;
543 pz5.resp();
544 % </SyntaxCode>
545 stest = true;
546 catch err
547 disp(err.message)
548 stest = false;
549 end
550
551 % <AlgoDescription>
552 %
553 % 1) Check the response diagram.
554 %
555 % </AlgoDescription>
556
557 atest = true;
558 if stest
559 % <AlgoCode>
560 % Get the current figure.
561 fi = gcf;
562 % Get ALL axes including the legends.
563 ax = get(fi, 'Children');
564 % Select only the 'axes' with the lines
565 ax = ax(ismember(get(ax(:), 'Tag'), ''));
566 % Get the lines of both axes
567 lines = get(ax(:), 'Children');
568 x = get(lines{1}, 'XData');
569 f1 = getlowerFreq(pz5)/10;
570 f2 = getupperFreq(pz5)*10;
571 nf = find(pzmodel.getInfo('resp', 'Range').plists, 'nf');
572 if x(1) ~= f1, atest = false; end
573 if x(end) ~= f2, atest = false; end
574 if numel(x) ~= nf, atest = false; end
575 % </AlgoCode>
576 else
577 atest = false;
578 end
579
580 % Return a result structure
581 result = utp_prepare_result(atest, stest, dbstack, mfilename);
582 end % END UTP_07
583
584 %% UTP_08
585
586 % <TestDescription>
587 %
588 % Test the shape of the output.
589 %
590 % </TestDescription>
591 function result = utp_08
592
593 % <SyntaxDescription>
594 %
595 % Test that the output AO of the resp method keeps the shape of the used
596 % input f vector.
597 %
598 % </SyntaxDescription>
599
600 try
601 % <SyntaxCode>
602 arow = ao(1:100, linspace(.1, 5, 100));
603 acol = arow.';
604 f = linspace(.1, 5, 100);
605 out1 = resp(pz5, arow);
606 out2 = resp(pz5, acol);
607 out3 = resp(pz5, f);
608 % </SyntaxCode>
609 stest = true;
610 catch err
611 disp(err.message)
612 stest = false;
613 end
614
615 % <AlgoDescription>
616 %
617 % 1) Check that the shape of the data doesn't change.
618 %
619 % </AlgoDescription>
620
621 atest = true;
622 if stest
623 % <AlgoCode>
624 % Check the shape of the output data
625 if size(out1.data.y,1) ~= 1, atest = false; end
626 if size(out1.data.y,2) == 1, atest = false; end
627 if size(out2.data.y,1) == 1, atest = false; end
628 if size(out2.data.y,2) ~= 1, atest = false; end
629 if size(out3.data.y,1) ~= 1, atest = false; end
630 if size(out3.data.y,2) == 1, atest = false; end
631 % </AlgoCode>
632 else
633 atest = false;
634 end
635
636 % Return a result structure
637 result = utp_prepare_result(atest, stest, dbstack, mfilename);
638 end % END UTP_08
639
640 %% UTP_09
641
642 % <TestDescription>
643 %
644 % Check that the resp method pass back the output objects to a list of
645 % output variables or to a single variable.
646 %
647 % </TestDescription>
648 function result = utp_09
649
650 % <SyntaxDescription>
651 %
652 % Call the method with a list of output variables and with a single output
653 % variable. Additionaly check that the rebuild method works on the output.
654 %
655 % </SyntaxDescription>
656
657 try
658 % <SyntaxCode>
659 [o1, o2] = resp(pz5, pz3);
660 o3 = resp(pz5, pz3);
661 mout1 = rebuild(o1);
662 mout2 = rebuild(o2);
663 mout3 = rebuild(o3);
664 % </SyntaxCode>
665 stest = true;
666 catch err
667 disp(err.message)
668 stest = false;
669 end
670
671 % <AlgoDescription>
672 %
673 % 1) Check that the output contains the right number of objects
674 % 2) Check that the 'rebuild' method produces the same object as 'out'.
675 %
676 % </AlgoDescription>
677
678 atest = true;
679 if stest
680 % <AlgoCode>
681 % Check the number of outputs
682 if numel(o1) ~=1, atest = false; end
683 if numel(o2) ~=1, atest = false; end
684 if numel(o3) ~=2, atest = false; end
685 % Check the rebuilding of the object
686 if ~eq(o1, mout1, ple2), atest = false; end
687 if ~eq(o2, mout2, ple2), atest = false; end
688 if ~eq(o3, mout3, ple2), atest = false; end
689 % </AlgoCode>
690 else
691 atest = false;
692 end
693
694 % Return a result structure
695 result = utp_prepare_result(atest, stest, dbstack, mfilename);
696 end % END UTP_09
697
698 %% UTP_10
699
700 % <TestDescription>
701 %
702 % Check that the resp method uses the x-data of an input AO for f-vector.
703 %
704 % </TestDescription>
705 function result = utp_10
706
707 % <SyntaxDescription>
708 %
709 % Call the method with different method to pass an AO in.
710 %
711 % </SyntaxDescription>
712
713 try
714 % <SyntaxCode>
715 f1 = .1;
716 f2 = 5;
717 nf = 100;
718 axy = ao(linspace(f1, f2, nf), randn(100,1));
719 afs = ao(linspace(f1, f2, nf), randn(100,1), plist('type', 'fsdata'));
720 out1 = resp(pz5, axy);
721 out2 = resp(pz5, afs);
722 out3 = resp(pz5, plist('f', axy));
723 out4 = resp(pz5, plist('f', afs));
724
725 mout1 = rebuild(out1);
726 mout2 = rebuild(out2);
727 mout3 = rebuild(out3);
728 mout4 = rebuild(out4);
729 % </SyntaxCode>
730 stest = true;
731 catch err
732 disp(err.message)
733 stest = false;
734 end
735
736 % <AlgoDescription>
737 %
738 % 1) Check the output
739 % 2) Check that the 'rebuild' method produces the same object as 'out'.
740 %
741 % </AlgoDescription>
742
743 atest = true;
744 if stest
745 % <AlgoCode>
746 % Check the output
747 if ~isa(out1, 'ao'), atest = false; end
748 if ~isa(out2, 'ao'), atest = false; end
749 if ~isa(out3, 'ao'), atest = false; end
750 if ~isa(out4, 'ao'), atest = false; end
751 if out1.x(1) ~= f1, atest = false; end
752 if out1.x(end) ~= f2, atest = false; end
753 if numel(out1.x) ~= nf, atest = false; end
754 if out2.x(1) ~= f1, atest = false; end
755 if out2.x(end) ~= f2, atest = false; end
756 if numel(out2.x) ~= nf, atest = false; end
757 if out3.x(1) ~= f1, atest = false; end
758 if out3.x(end) ~= f2, atest = false; end
759 if numel(out3.x) ~= nf, atest = false; end
760 if out4.x(1) ~= f1, atest = false; end
761 if out4.x(end) ~= f2, atest = false; end
762 if numel(out4.x) ~= nf, atest = false; end
763 % Check the rebuilding of the object
764 if ~eq(out1, mout1, ple2), atest = false; end
765 if ~eq(out2, mout2, ple2), atest = false; end
766 if ~eq(out3, mout3, ple2), atest = false; end
767 if ~eq(out4, mout4, ple2), atest = false; end
768 % </AlgoCode>
769 else
770 atest = false;
771 end
772
773 % Return a result structure
774 result = utp_prepare_result(atest, stest, dbstack, mfilename);
775 end % END UTP_10
776
777 %% UTP_11
778
779 % <TestDescription>
780 %
781 % Check that the resp method uses the specified f-vector to compute the response.
782 %
783 % </TestDescription>
784 function result = utp_11
785
786 % <SyntaxDescription>
787 %
788 % Call the method with different method to pass an f-vector in.
789 %
790 % </SyntaxDescription>
791
792 try
793 % <SyntaxCode>
794 f1 = .1;
795 f2 = 5;
796 nf = 100;
797 f = linspace(f1, f2, nf);
798 out1 = resp(pz5, f);
799 out2 = resp(pz5, plist('f', f));
800
801 mout1 = rebuild(out1);
802 mout2 = rebuild(out2);
803 % </SyntaxCode>
804 stest = true;
805 catch err
806 disp(err.message)
807 stest = false;
808 end
809
810 % <AlgoDescription>
811 %
812 % 1) Check the output
813 % 2) Check that the 'rebuild' method produces the same object as 'out'.
814 %
815 % </AlgoDescription>
816
817 atest = true;
818 if stest
819 % <AlgoCode>
820 % Check the output
821 if ~isa(out1, 'ao'), atest = false; end
822 if ~isa(out2, 'ao'), atest = false; end
823 if out1.x(1) ~= f1, atest = false; end
824 if out1.x(end) ~= f2, atest = false; end
825 if numel(out1.x) ~= nf, atest = false; end
826 if out2.x(1) ~= f1, atest = false; end
827 if out2.x(end) ~= f2, atest = false; end
828 if numel(out2.x) ~= nf, atest = false; end
829 % Check the rebuilding of the object
830 if ~eq(out1, mout1, ple2), atest = false; end
831 if ~eq(out2, mout2, ple2), atest = false; end
832 % </AlgoCode>
833 else
834 atest = false;
835 end
836
837 % Return a result structure
838 result = utp_prepare_result(atest, stest, dbstack, mfilename);
839 end % END UTP_11
840
841 %% UTP_12
842
843 % <TestDescription>
844 %
845 % Check that the resp method uses the specified f1, f2, and nf to compute the response.
846 %
847 % </TestDescription>
848 function result = utp_12
849
850 % <SyntaxDescription>
851 %
852 % Call the method with different method to pass f1, f2, and nf in.
853 %
854 % </SyntaxDescription>
855
856 try
857 % <SyntaxCode>
858 f1 = .1;
859 f2 = 5;
860 nf = 100;
861 nf2 = 123;
862 out1 = resp(pz5, f1, f2);
863 out2 = resp(pz5, f1, f2, nf);
864 out3 = resp(pz5, plist('f1', f1, 'f2', f2, 'nf', nf));
865 out4 = resp(pz5, plist('f1', f1, 'nf', nf2));
866 out5 = resp(pz5, plist('f2', f2));
867
868 mout1 = rebuild(out1);
869 mout2 = rebuild(out2);
870 mout3 = rebuild(out3);
871 mout4 = rebuild(out4);
872 mout5 = rebuild(out5);
873 % </SyntaxCode>
874 stest = true;
875 catch err
876 disp(err.message)
877 stest = false;
878 end
879
880 % <AlgoDescription>
881 %
882 % 1) Check the output
883 % 2) Check that the 'rebuild' method produces the same object as 'out'.
884 %
885 % </AlgoDescription>
886
887 atest = true;
888 T = 10e-12;
889 if stest
890 % <AlgoCode>
891 % Check the output
892 f1d = getlowerFreq(pz5)/10;
893 f2d = getupperFreq(pz5)*10;
894 nfd = find(pzmodel.getInfo('resp', 'Range').plists, 'nf');
895 if ~isa(out1, 'ao'), atest = false; end
896 if ~isa(out2, 'ao'), atest = false; end
897 if ~isa(out3, 'ao'), atest = false; end
898 if ~isa(out4, 'ao'), atest = false; end
899 if ~isa(out5, 'ao'), atest = false; end
900 if out1.x(1) ~= f1, atest = false; end
901 if any(find(abs(out1.x(end)-f2)>T)), atest = false; end
902 if numel(out1.x) ~= nfd, atest = false; end % Default values
903 if out2.x(1) ~= f1, atest = false; end
904 if any(find(abs(out2.x(end)-f2)>T)), atest = false; end
905 if numel(out2.x) ~= nf, atest = false; end
906 if out3.x(1) ~= f1, atest = false; end
907 if abs(out3.x(end)-f2)>T, atest = false; end
908 if numel(out3.x) ~= nf, atest = false; end
909 if out4.x(1) ~= f1, atest = false; end
910 if out4.x(end) ~= f2d, atest = false; end % Default values
911 if numel(out4.x) ~= nf2, atest = false; end
912 if out5.x(1) ~= f1d, atest = false; end % Default values
913 if any(find(abs(out5.x(end)-f2)>T)), atest = false; end
914 if numel(out5.x) ~= nfd, atest = false; end % Default values
915 % Check the rebuilding of the object
916 if ~eq(out1, mout1, ple2), atest = false; end
917 if ~eq(out2, mout2, ple2), atest = false; end
918 if ~eq(out3, mout3, ple2), atest = false; end
919 if ~eq(out4, mout4, ple2), atest = false; end
920 if ~eq(out5, mout5, ple2), atest = false; end
921 % </AlgoCode>
922 else
923 atest = false;
924 end
925
926 % Return a result structure
927 result = utp_prepare_result(atest, stest, dbstack, mfilename);
928 end % END UTP_12
929
930 %% UTP_13
931
932 % <TestDescription>
933 %
934 % Check that the resp method uses the specified f1, f2, and nf to compute the response.
935 %
936 % </TestDescription>
937 function result = utp_13
938
939 % <SyntaxDescription>
940 %
941 % Call the method with different method to pass f1, f2, and nf in.
942 %
943 % </SyntaxDescription>
944
945 try
946 % <SyntaxCode>
947 f1 = .1;
948 f2 = 5;
949 nf = 123;
950 out1 = resp(pz5, plist('f1', f1, 'f2', f2, 'nf', nf, 'scale', 'lin'));
951 out2 = resp(pz5, plist('f1', f1, 'f2', f2, 'nf', nf, 'scale', 'log'));
952 out3 = resp(pz5, plist('scale', 'lin'));
953 out4 = resp(pz5, plist('scale', 'log'));
954
955 mout1 = rebuild(out1);
956 mout2 = rebuild(out2);
957 mout3 = rebuild(out3);
958 mout4 = rebuild(out4);
959 % </SyntaxCode>
960 stest = true;
961 catch err
962 disp(err.message)
963 stest = false;
964 end
965
966 % <AlgoDescription>
967 %
968 % 1) Check the output
969 % 2) Check that the 'rebuild' method produces the same object as 'out'.
970 %
971 % </AlgoDescription>
972
973 atest = true;
974 T = 10e-12;
975 if stest
976 % <AlgoCode>
977 % Check the output
978 f1d = getlowerFreq(pz5)/10;
979 f2d = getupperFreq(pz5)*10;
980 nfd = find(pzmodel.getInfo('resp', 'Range').plists, 'nf');
981 if ~isa(out1, 'ao'), atest = false; end
982 if ~isa(out2, 'ao'), atest = false; end
983 if ~isa(out3, 'ao'), atest = false; end
984 if ~isa(out4, 'ao'), atest = false; end
985 xlin1 = linspace(f1, f2, nf);
986 xlin2 = linspace(f1d, f2d, nfd);
987 xlog1 = logspace(log10(f1), log10(f2), nf);
988 xlog2 = logspace(log10(f1d), log10(f2d), nfd);
989 if ~isequal(xlin1, out1.x'), atest = false; end
990 if ~isequal(xlin2, out3.x'), atest = false; end
991 if ~isequal(xlog1, out2.x'), atest = false; end
992 if ~isequal(xlog2, out4.x'), atest = false; end
993
994 % Check the rebuilding of the object
995 if ~eq(out1, mout1, ple2), atest = false; end
996 if ~eq(out2, mout2, ple2), atest = false; end
997 if ~eq(out3, mout3, ple2), atest = false; end
998 if ~eq(out4, mout4, ple2), atest = false; end
999 % </AlgoCode>
1000 else
1001 atest = false;
1002 end
1003
1004 % Return a result structure
1005 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1006 end % END UTP_13
1007
1008 end