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