Mercurial > hg > ltpda
comparison testing/utp_1.1/utps/ao/utp_ao_whiten2D.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_AO_WHITEN2D a set of UTPs for the ao/whiten2D method | |
2 % | |
3 % L Ferraioli 02-02-09 | |
4 % | |
5 % $Id: utp_ao_whiten2D.m,v 1.10 2010/05/07 16:20:01 ingo Exp $ | |
6 % | |
7 | |
8 % <MethodDescription> | |
9 % | |
10 % The whiten1D method of the ao class computes the whiten1Dolute value of the y | |
11 % and/or x data. | |
12 % | |
13 % </MethodDescription> | |
14 | |
15 function results = utp_ao_whiten2D(varargin) | |
16 | |
17 % Check the inputs | |
18 if nargin == 0 | |
19 | |
20 % Some keywords | |
21 class = 'ao'; | |
22 mthd = 'whiten2D'; | |
23 | |
24 results = []; | |
25 disp('******************************************************'); | |
26 disp(['**** Running UTPs for ' class '/' mthd]); | |
27 disp('******************************************************'); | |
28 | |
29 % Test AOs | |
30 [CSD,a1,a2,a3,a4,a5,a6,av,am,plstd] = get_test_obj_ao_whiten2D(); | |
31 | |
32 % -------------------------------------------------------------------- | |
33 | |
34 % Exception list for the UTPs: | |
35 [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples(); | |
36 | |
37 % add useful params to standard exceptions | |
38 ple3 = plist('Exceptions', {'history', 'created', 'UUID', 'param/desc', 'name', 'procinfo'}); | |
39 | |
40 % Run the tests | |
41 results = [results utp_01]; % getInfo call | |
42 results = [results utp_02]; % Vector input | |
43 results = [results utp_03]; % Matrix input | |
44 results = [results utp_04]; % List input | |
45 results = [results utp_05]; % Test with mixed input | |
46 results = [results utp_06]; % Test history is working | |
47 results = [results utp_07]; % Test the modify call works | |
48 results = [results utp_08]; % Test input data shape == output data shape | |
49 results = [results utp_09]; % Test output of the data | |
50 | |
51 disp('Done.'); | |
52 disp('******************************************************'); | |
53 | |
54 elseif nargin == 1 % Check for UTP functions | |
55 if strcmp(varargin{1}, 'isutp') | |
56 results = 1; | |
57 else | |
58 results = 0; | |
59 end | |
60 else | |
61 error('### Incorrect inputs') | |
62 end | |
63 | |
64 %% UTP_01 | |
65 | |
66 % <TestDescription> | |
67 % | |
68 % Tests that the getInfo call works for this method. | |
69 % | |
70 % </TestDescription> | |
71 function result = utp_01 | |
72 | |
73 | |
74 % <SyntaxDescription> | |
75 % | |
76 % Test that the getInfo call works for no sets, all sets, and each set | |
77 % individually. | |
78 % | |
79 % </SyntaxDescription> | |
80 | |
81 try | |
82 % <SyntaxCode> | |
83 % Call for no sets | |
84 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']); | |
85 % Call for all sets | |
86 io(2) = eval([class '.getInfo(''' mthd ''')']); | |
87 % Call for each set | |
88 for kk=1:numel(io(2).sets) | |
89 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']); | |
90 end | |
91 % </SyntaxCode> | |
92 stest = true; | |
93 catch err | |
94 disp(err.message) | |
95 stest = false; | |
96 end | |
97 | |
98 % <AlgoDescription> | |
99 % | |
100 % 1) Check that getInfo call returned an minfo object in all cases. | |
101 % 2) Check that all plists have the correct parameters. | |
102 % | |
103 % </AlgoDescription> | |
104 | |
105 atest = true; | |
106 if stest | |
107 % <AlgoCode> | |
108 % check we have minfo objects | |
109 if isa(io, 'minfo') | |
110 %%% SET 'None' | |
111 if ~isempty(io(1).sets), atest = false; end | |
112 if ~isempty(io(1).plists), atest = false; end | |
113 %%% Check all Sets | |
114 if ~any(strcmpi(io(2).sets, 'Default')), atest = false; end | |
115 if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end | |
116 %%%%%%%%%% SET 'Default' | |
117 if io(3).plists.nparams ~= 15, atest = false; end | |
118 % Check key | |
119 if ~io(3).plists.isparam('csd11'), atest = false; end | |
120 if ~io(3).plists.isparam('csd12'), atest = false; end | |
121 if ~io(3).plists.isparam('csd21'), atest = false; end | |
122 if ~io(3).plists.isparam('csd22'), atest = false; end | |
123 if ~io(3).plists.isparam('maxiter'), atest = false; end | |
124 if ~io(3).plists.isparam('poletype'), atest = false; end | |
125 if ~io(3).plists.isparam('minorder'), atest = false; end | |
126 if ~io(3).plists.isparam('maxorder'), atest = false; end | |
127 if ~io(3).plists.isparam('weights'), atest = false; end | |
128 if ~io(3).plists.isparam('plot'), atest = false; end | |
129 if ~io(3).plists.isparam('disp'), atest = false; end | |
130 if ~io(3).plists.isparam('msevartol'), atest = false; end | |
131 if ~io(3).plists.isparam('fittol'), atest = false; end | |
132 if ~io(3).plists.isparam('usesym'), atest = false; end | |
133 if ~io(3).plists.isparam('keepvar'), atest = false; end | |
134 % Check default value | |
135 if ~isEmptyDouble(io(3).plists.find('csd11')), atest = false; end | |
136 if ~isEmptyDouble(io(3).plists.find('csd12')), atest = false; end | |
137 if ~isEmptyDouble(io(3).plists.find('csd21')), atest = false; end | |
138 if ~isEmptyDouble(io(3).plists.find('csd22')), atest = false; end | |
139 if ~isequal(io(3).plists.find('maxiter'), 30), atest = false; end | |
140 if ~isequal(io(3).plists.find('poletype'), 3), atest = false; end | |
141 if ~isequal(io(3).plists.find('minorder'), 2), atest = false; end | |
142 if ~isequal(io(3).plists.find('maxorder'), 25), atest = false; end | |
143 if ~isequal(io(3).plists.find('weights'), 3), atest = false; end | |
144 if ~isequal(io(3).plists.find('plot'), false), atest = false; end | |
145 if ~isequal(io(3).plists.find('disp'), false), atest = false; end | |
146 if ~isequal(io(3).plists.find('msevartol'), .01), atest = false; end | |
147 if ~isequal(io(3).plists.find('fittol'), .01), atest = false; end | |
148 if ~isequal(io(3).plists.find('usesym'), 0), atest = false; end | |
149 if ~isequal(io(3).plists.find('keepvar'), false), atest = false; end | |
150 % Check options | |
151 if ~isequal(io(3).plists.getOptionsForParam('csd11'), {[]}), atest = false; end | |
152 if ~isequal(io(3).plists.getOptionsForParam('csd12'), {[]}), atest = false; end | |
153 if ~isequal(io(3).plists.getOptionsForParam('csd21'), {[]}), atest = false; end | |
154 if ~isequal(io(3).plists.getOptionsForParam('csd22'), {[]}), atest = false; end | |
155 if ~isequal(io(3).plists.getOptionsForParam('maxiter'), {30}), atest = false; end | |
156 if ~isequal(io(3).plists.getOptionsForParam('poletype'), {1 2 3}), atest = false; end | |
157 if ~isequal(io(3).plists.getOptionsForParam('minorder'), {2}), atest = false; end | |
158 if ~isequal(io(3).plists.getOptionsForParam('maxorder'), {25}), atest = false; end | |
159 if ~isequal(io(3).plists.getOptionsForParam('weights'), {3}), atest = false; end | |
160 if ~isequal(io(3).plists.getOptionsForParam('plot'), {false, true}), atest = false; end | |
161 if ~isequal(io(3).plists.getOptionsForParam('disp'), {false, true}), atest = false; end | |
162 if ~isequal(io(3).plists.getOptionsForParam('msevartol'), {.01}), atest = false; end | |
163 if ~isequal(io(3).plists.getOptionsForParam('fittol'), {.01}), atest = false; end | |
164 if ~isequal(io(3).plists.getOptionsForParam('usesym'), {0, 1, 2}), atest = false; end | |
165 if ~isequal(io(3).plists.getOptionsForParam('keepvar'), {true, false}), atest = false; end | |
166 end | |
167 % </AlgoCode> | |
168 else | |
169 atest = false; | |
170 end | |
171 | |
172 % Return a result structure | |
173 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
174 end % END UTP_01 | |
175 | |
176 %% UTP_02 | |
177 | |
178 % <TestDescription> | |
179 % | |
180 % Tests that the whiten2D method works with a vector of AOs as input. | |
181 % | |
182 % </TestDescription> | |
183 function result = utp_02 | |
184 | |
185 % <SyntaxDescription> | |
186 % | |
187 % Test that the whiten2D method works for a vector of AOs as input. | |
188 % | |
189 % </SyntaxDescription> | |
190 | |
191 try | |
192 % <SyntaxCode> | |
193 % Building data vector | |
194 | |
195 out = whiten2D(av, plstd); | |
196 % </SyntaxCode> | |
197 stest = true; | |
198 catch err | |
199 disp(err.message) | |
200 stest = false; | |
201 end | |
202 | |
203 % <AlgoDescription> | |
204 % | |
205 % 1) Check that the number of elements in 'out' is the same as in 'acv2' | |
206 % 2) Check that each output AO contains the correct data. | |
207 % | |
208 % </AlgoDescription> | |
209 | |
210 atest = true; | |
211 if stest | |
212 % <AlgoCode> | |
213 % Check we have the correct number of outputs | |
214 if ~isequal(size(out), size(av)), atest = false; end | |
215 | |
216 % check if the number of output is even or odd | |
217 if rem(numel(out),2) | |
218 % check the last object for odd input | |
219 h = numel(out); | |
220 if isa(out(h).data, 'tsdata') | |
221 % Check the last object if nargin is odd (they must be the same) | |
222 if ~eq(out(h), av(h), ple1), atest = false; end | |
223 else | |
224 % Check the other objects (they must be the same) | |
225 if ~eq(out(h), av(h), ple1), atest = false; end | |
226 end | |
227 else | |
228 % Check each output against the absolute value of the input for even | |
229 % input | |
230 for kk=1:2:numel(out)-1 | |
231 clear used_filt11 used_filt12 used_filt21 used_filt22 | |
232 % Check the noisegen ao(tsdata) objects | |
233 if isa(out(kk).data, 'tsdata') | |
234 used_filt11 = out(kk).procinfo.find('Filt11'); | |
235 used_filt12 = out(kk).procinfo.find('Filt12'); | |
236 used_filt21 = out(kk+1).procinfo.find('Filt21'); | |
237 used_filt22 = out(kk+1).procinfo.find('Filt22'); | |
238 obj1 = filter(av(kk),used_filt11)+filter(av(kk+1),used_filt12); | |
239 if ~eq(out(kk), obj1, ple3), atest = false; end | |
240 obj2 = filter(av(kk),used_filt21)+filter(av(kk+1),used_filt22); | |
241 if ~eq(out(kk), obj2, ple3), atest = false; end | |
242 else | |
243 % Check the other objects (they must be the same) | |
244 if ~eq(out(kk), av(kk), ple1), atest = false; end | |
245 end | |
246 end | |
247 end | |
248 % </AlgoCode> | |
249 else | |
250 atest = false; | |
251 end | |
252 | |
253 % Return a result structure | |
254 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
255 end % END UTP_02 | |
256 | |
257 %% UTP_03 | |
258 | |
259 % <TestDescription> | |
260 % | |
261 % Tests that the whiten2D method works with a matrix of AOs as input. | |
262 % | |
263 % </TestDescription> | |
264 function result = utp_03 | |
265 | |
266 % <SyntaxDescription> | |
267 % | |
268 % Test that the whiten2D method works for a matrix of AOs as input. | |
269 % | |
270 % </SyntaxDescription> | |
271 | |
272 try | |
273 % <SyntaxCode> | |
274 out = whiten2D(am,plstd); | |
275 % </SyntaxCode> | |
276 stest = true; | |
277 catch err | |
278 disp(err.message) | |
279 stest = false; | |
280 end | |
281 | |
282 % <AlgoDescription> | |
283 % | |
284 % 1) Check that the number of elements in 'out' is the same as in 'atmat' | |
285 % 2) Check that each output AO contains the correct data. | |
286 % | |
287 % </AlgoDescription> | |
288 | |
289 atest = true; | |
290 if stest | |
291 % <AlgoCode> | |
292 % Check we have the correct number of outputs | |
293 if ~isequal(size(out), size(am)), atest = false; end | |
294 | |
295 % check if the number of output is even or odd | |
296 if rem(numel(out),2) | |
297 % check the last object for odd input | |
298 h = numel(out); | |
299 if isa(out(h).data, 'tsdata') | |
300 % Check the last object if nargin is odd (they must be the same) | |
301 if ~eq(out(h), am(h), ple1), atest = false; end | |
302 else | |
303 % Check the other objects (they must be the same) | |
304 if ~eq(out(h), am(h), ple1), atest = false; end | |
305 end | |
306 else | |
307 % Check each output against the absolute value of the input for even | |
308 % input | |
309 for kk=1:2:numel(out)-1 | |
310 clear used_filt11 used_filt12 used_filt21 used_filt22 | |
311 % Check the noisegen ao(tsdata) objects | |
312 if isa(out(kk).data, 'tsdata') | |
313 used_filt11 = out(kk).procinfo.find('Filt11'); | |
314 used_filt12 = out(kk).procinfo.find('Filt12'); | |
315 used_filt21 = out(kk+1).procinfo.find('Filt21'); | |
316 used_filt22 = out(kk+1).procinfo.find('Filt22'); | |
317 obj1 = filter(am(kk),used_filt11)+filter(am(kk+1),used_filt12); | |
318 if ~eq(out(kk), obj1, ple3), atest = false; end | |
319 obj2 = filter(am(kk),used_filt21)+filter(am(kk+1),used_filt22); | |
320 if ~eq(out(kk+1), obj2, ple3), atest = false; end | |
321 else | |
322 % Check the other objects (they must be the same) | |
323 if ~eq(out(kk), am(kk), ple1), atest = false; end | |
324 end | |
325 end | |
326 end | |
327 % </AlgoCode> | |
328 else | |
329 atest = false; | |
330 end | |
331 | |
332 % Return a result structure | |
333 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
334 end % END UTP_03 | |
335 | |
336 %% UTP_04 | |
337 | |
338 % <TestDescription> | |
339 % | |
340 % Tests that the whiten2D method works with a list of AOs as input. | |
341 % | |
342 % </TestDescription> | |
343 function result = utp_04 | |
344 | |
345 % <SyntaxDescription> | |
346 % | |
347 % Test that the whiten2D method works for a list of AOs as input. | |
348 % | |
349 % </SyntaxDescription> | |
350 | |
351 try | |
352 % <SyntaxCode> | |
353 out = whiten2D(a1,a2,a3,a4,a5,plstd); | |
354 % </SyntaxCode> | |
355 stest = true; | |
356 catch err | |
357 disp(err.message) | |
358 stest = false; | |
359 end | |
360 | |
361 % <AlgoDescription> | |
362 % | |
363 % 1) Check that the number of elements in 'out' is the same as in | |
364 % input. | |
365 % 2) Check that each output AO contains the correct data. | |
366 % | |
367 % </AlgoDescription> | |
368 | |
369 atest = true; | |
370 aoin = [a1 a2 a3 a4 a5]; | |
371 if stest | |
372 % <AlgoCode> | |
373 % Check we have the correct number of outputs | |
374 if ~isequal(size(out), size(aoin)), atest = false; end | |
375 | |
376 % check if the number of output is even or odd | |
377 if rem(numel(out),2) | |
378 % check the last object for odd input | |
379 h = numel(out); | |
380 if isa(out(h).data, 'tsdata') | |
381 % Check the last object if nargin is odd (they must be the same) | |
382 if ~eq(out(h), aoin(h), ple1), atest = false; end | |
383 else | |
384 % Check the other objects (they must be the same) | |
385 if ~eq(out(h), aoin(h), ple1), atest = false; end | |
386 end | |
387 else | |
388 % Check each output against the absolute value of the input for even | |
389 % input | |
390 for kk=1:2:numel(out)-1 | |
391 clear used_filt11 used_filt12 used_filt21 used_filt22 | |
392 % Check the noisegen ao(tsdata) objects | |
393 if isa(out(kk).data, 'tsdata') | |
394 used_filt11 = out(kk).procinfo.find('Filt11'); | |
395 used_filt12 = out(kk).procinfo.find('Filt12'); | |
396 used_filt21 = out(kk+1).procinfo.find('Filt21'); | |
397 used_filt22 = out(kk+1).procinfo.find('Filt22'); | |
398 obj1 = filter(aoin(kk),used_filt11)+filter(aoin(kk+1),used_filt12); | |
399 if ~eq(out(kk), obj1, ple3), atest = false; end | |
400 obj2 = filter(aoin(kk),used_filt21)+filter(aoin(kk+1),used_filt22); | |
401 if ~eq(out(kk+1), obj2, ple3), atest = false; end | |
402 else | |
403 % Check the other objects (they must be the same) | |
404 if ~eq(out(kk), aoin(kk), ple1), atest = false; end | |
405 end | |
406 end | |
407 end | |
408 % </AlgoCode> | |
409 else | |
410 atest = false; | |
411 end | |
412 | |
413 % Return a result structure | |
414 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
415 end % END UTP_04 | |
416 | |
417 %% UTP_05 | |
418 | |
419 % <TestDescription> | |
420 % | |
421 % Tests that the whiten2D method works with a mix of different shaped AOs as | |
422 % input. | |
423 % | |
424 % </TestDescription> | |
425 function result = utp_05 | |
426 | |
427 % <SyntaxDescription> | |
428 % | |
429 % Test that the whiten1D method works with an input of matrices and vectors | |
430 % and single AOs. | |
431 % | |
432 % </SyntaxDescription> | |
433 | |
434 try | |
435 % <SyntaxCode> | |
436 % [1,reshape([2 3],1,[]),reshape([4 6; 5 7],1,[])]; | |
437 out = whiten2D(a1,[a2 a3],[a4 a2; a1 a3],plstd); | |
438 % </SyntaxCode> | |
439 stest = true; | |
440 catch err | |
441 disp(err.message) | |
442 stest = false; | |
443 end | |
444 | |
445 % <AlgoDescription> | |
446 % | |
447 % 1) Check that the number of elements in 'out' is the same as in | |
448 % input. | |
449 % 2) Check that each output AO contains the correct data. | |
450 % | |
451 % </AlgoDescription> | |
452 | |
453 atest = true; | |
454 % [1,reshape([2 3],1,[]),reshape([4 6; 5 7],1,[])]; | |
455 aoin = [a1,reshape([a2 a3],1,[]),reshape([a4 a2; a1 a3],1,[])]; | |
456 if stest | |
457 % <AlgoCode> | |
458 % Check we have the correct number of outputs | |
459 if ~isequal(size(out), size(aoin)), atest = false; end | |
460 | |
461 % check if the number of output is even or odd | |
462 if rem(numel(out),2) | |
463 % check the last object for odd input | |
464 h = numel(out); | |
465 if isa(out(h).data, 'tsdata') | |
466 % Check the last object if nargin is odd (they must be the same) | |
467 if ~eq(out(h), aoin(h), ple1), atest = false; end | |
468 else | |
469 % Check the other objects (they must be the same) | |
470 if ~eq(out(h), aoin(h), ple1), atest = false; end | |
471 end | |
472 else | |
473 % Check each output against the absolute value of the input for even | |
474 % input | |
475 for kk=1:2:numel(out)-1 | |
476 clear used_filt11 used_filt12 used_filt21 used_filt22 | |
477 % Check the noisegen ao(tsdata) objects | |
478 if isa(out(kk).data, 'tsdata') | |
479 used_filt11 = out(kk).procinfo.find('Filt11'); | |
480 used_filt12 = out(kk).procinfo.find('Filt12'); | |
481 used_filt21 = out(kk+1).procinfo.find('Filt21'); | |
482 used_filt22 = out(kk+1).procinfo.find('Filt22'); | |
483 obj1 = filter(aoin(kk),used_filt11)+filter(aoin(kk+1),used_filt12); | |
484 if ~eq(out(kk), obj1, ple3), atest = false; end | |
485 obj2 = filter(aoin(kk),used_filt21)+filter(aoin(kk+1),used_filt22); | |
486 if ~eq(out(kk+1), obj2, ple3), atest = false; end | |
487 else | |
488 % Check the other objects (they must be the same) | |
489 if ~eq(out(kk), aoin(kk), ple1), atest = false; end | |
490 end | |
491 end | |
492 end | |
493 % </AlgoCode> | |
494 else | |
495 atest = false; | |
496 end | |
497 | |
498 % Return a result structure | |
499 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
500 end % END UTP_05 | |
501 | |
502 %% UTP_06 | |
503 | |
504 % <TestDescription> | |
505 % | |
506 % Tests that the whiten2D method properly applies history. | |
507 % | |
508 % </TestDescription> | |
509 function result = utp_06 | |
510 | |
511 % <SyntaxDescription> | |
512 % | |
513 % Test that the result of applying the whiten2D method can be processed back. | |
514 % | |
515 % </SyntaxDescription> | |
516 | |
517 try | |
518 % <SyntaxCode> | |
519 out = whiten2D(av,plstd); | |
520 o1 = out.index(1); | |
521 o2 = out.index(2); | |
522 o3 = out(3); % It is not necessary to index the third element | |
523 % of 'out' because this is not touched by 'whiten2D' | |
524 mout1 = rebuild(o1); | |
525 mout2 = rebuild(o2); | |
526 mout3 = rebuild(o3); | |
527 % </SyntaxCode> | |
528 stest = true; | |
529 catch err | |
530 disp(err.message) | |
531 stest = false; | |
532 end | |
533 | |
534 % <AlgoDescription> | |
535 % | |
536 % 1) Check that the last entry in the history of 'out' corresponds to | |
537 % 'whiten2D'. | |
538 % 2) Check that the re-built object is the same object as the input. | |
539 % | |
540 % </AlgoDescription> | |
541 | |
542 atest = true; | |
543 if stest | |
544 % <AlgoCode> | |
545 % Check the last step in the history of 'out' | |
546 if ~strcmp(out(1).hist.methodInfo.mname, 'whiten2D'), atest = false; end | |
547 if ~strcmp(out(2).hist.methodInfo.mname, 'whiten2D'), atest = false; end | |
548 % Check the re-built object | |
549 if ~eq(mout1, o1, ple2), atest = false; end | |
550 if ~eq(mout2, o2, ple2), atest = false; end | |
551 if ~eq(mout3, o3, ple2), atest = false; end | |
552 % Check the unchanged object (the last one) | |
553 if ~eq(av(3), out(3), ple1), atest = false; end | |
554 % </AlgoCode> | |
555 else | |
556 atest = false; | |
557 end | |
558 | |
559 % Return a result structure | |
560 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
561 end % END UTP_06 | |
562 | |
563 %% UTP_07 | |
564 | |
565 % <TestDescription> | |
566 % | |
567 % Tests that the whiten2D method can modify the input AO. | |
568 % | |
569 % </TestDescription> | |
570 function result = utp_07 | |
571 | |
572 % <SyntaxDescription> | |
573 % | |
574 % Test that the whiten2D method can modify the input AO by calling with no | |
575 % output and that the method doesn't change the input of the function | |
576 % notation (with a equal sign). | |
577 % | |
578 % </SyntaxDescription> | |
579 | |
580 try | |
581 % <SyntaxCode> | |
582 amodi = [ao(a1) ao(a2)]; | |
583 aeq = [ao(a1) ao(a2)]; | |
584 amodi.whiten2D(plstd); | |
585 out = aeq.whiten2D(plstd); | |
586 stest = false; | |
587 % </SyntaxCode> | |
588 catch | |
589 stest = true; | |
590 end | |
591 | |
592 % <AlgoDescription> | |
593 % | |
594 % 1) Nothing to do. | |
595 % | |
596 % </AlgoDescription> | |
597 | |
598 atest = true; | |
599 if stest | |
600 % <AlgoCode> | |
601 % </AlgoCode> | |
602 else | |
603 atest = false; | |
604 end | |
605 | |
606 % Return a result structure | |
607 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
608 end % END UTP_07 | |
609 | |
610 %% UTP_08 | |
611 | |
612 % <TestDescription> | |
613 % | |
614 % Test the shape of the output. | |
615 % | |
616 % </TestDescription> | |
617 function result = utp_08 | |
618 | |
619 % <SyntaxDescription> | |
620 % | |
621 % Test that the whiten2D method keeps the data shape of the input object. The | |
622 % input AO must be an AO with row data and an AO with column data. | |
623 % | |
624 % </SyntaxDescription> | |
625 | |
626 try | |
627 % <SyntaxCode> | |
628 out = whiten2D(a3,a4,a5,a6,plstd); | |
629 out1 = out(1); | |
630 out2 = out(2); | |
631 out3 = out(3); | |
632 out4 = out(4); | |
633 % </SyntaxCode> | |
634 stest = true; | |
635 catch err | |
636 disp(err.message) | |
637 stest = false; | |
638 end | |
639 | |
640 % <AlgoDescription> | |
641 % | |
642 % 1) Check that the shape of the data doesn't change. | |
643 % | |
644 % </AlgoDescription> | |
645 | |
646 atest = true; | |
647 if stest | |
648 % <AlgoCode> | |
649 % Check the shape of the output data | |
650 if size(out1.data.x) ~= size(a3.data.x), atest = false; end | |
651 if size(out1.data.y) ~= size(a3.data.y), atest = false; end | |
652 if size(out2.data.x) ~= size(a4.data.x), atest = false; end | |
653 if size(out2.data.y) ~= size(a4.data.y), atest = false; end | |
654 if size(out3.data.x) ~= size(a5.data.x), atest = false; end | |
655 if size(out3.data.y) ~= size(a5.data.y), atest = false; end | |
656 if size(out4.data.x) ~= size(a6.data.x), atest = false; end | |
657 if size(out4.data.y) ~= size(a6.data.y), atest = false; end | |
658 % </AlgoCode> | |
659 else | |
660 atest = false; | |
661 end | |
662 | |
663 % Return a result structure | |
664 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
665 end % END UTP_08 | |
666 | |
667 %% UTP_09 | |
668 | |
669 % <TestDescription> | |
670 % | |
671 % Check that the noisegen2D method pass back the output objects to a list of | |
672 % output variables or to a single variable. | |
673 % | |
674 % </TestDescription> | |
675 function result = utp_09 | |
676 | |
677 % <SyntaxDescription> | |
678 % | |
679 % Call the method with a list of output variables and with a single output | |
680 % variable. Additionaly check that the rebuild method works on the output. | |
681 % | |
682 % </SyntaxDescription> | |
683 | |
684 try | |
685 % <SyntaxCode> | |
686 [o1,o2] = whiten2D(a1,a2,plstd); | |
687 o3 = whiten2D(a1,a2,plstd); | |
688 o31 = o3.index(1); | |
689 o32 = o3.index(2); | |
690 mout1 = rebuild(o1); | |
691 mout2 = rebuild(o2); | |
692 mout31 = rebuild(o31); | |
693 mout32 = rebuild(o32); | |
694 % </SyntaxCode> | |
695 stest = true; | |
696 catch err | |
697 disp(err.message) | |
698 stest = false; | |
699 end | |
700 | |
701 % <AlgoDescription> | |
702 % | |
703 % 1) Check that the output contains the right number of objects | |
704 % 2) Check that the 'rebuild' method produces the same object as 'out'. | |
705 % | |
706 % </AlgoDescription> | |
707 | |
708 atest = true; | |
709 if stest | |
710 % <AlgoCode> | |
711 % Check the number of outputs | |
712 if numel(o1) ~=1, atest = false; end | |
713 if numel(o2) ~=1, atest = false; end | |
714 if numel(o3) ~=2, atest = false; end | |
715 % Check the rebuilding of the object | |
716 if ~eq(o1, mout1, ple2), atest = false; end | |
717 if ~eq(o2, mout2, ple2), atest = false; end | |
718 if ~eq(o31, mout31, ple2), atest = false; end | |
719 if ~eq(o32, mout32, ple2), atest = false; end | |
720 % </AlgoCode> | |
721 else | |
722 atest = false; | |
723 end | |
724 | |
725 % Return a result structure | |
726 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
727 end % END UTP_09 | |
728 | |
729 | |
730 end |