Mercurial > hg > ltpda
comparison m-toolbox/test/test_pest_eval.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % TEST_PEST_EVAL tests the eval method of the PEST class. | |
2 % | |
3 % M Hueller 02-03-10 | |
4 % | |
5 % $Id: test_pest_eval.m,v 1.3 2010/03/19 11:13:17 mauro Exp $ | |
6 % | |
7 function results = test_pest_eval(varargin) | |
8 | |
9 %% List of runs | |
10 if nargin == 1 | |
11 list = varargin{1}; | |
12 if isa(list, 'cell') | |
13 list = list{:}; | |
14 end | |
15 else | |
16 list = []; | |
17 end | |
18 | |
19 if isempty(list) | |
20 list = [10:17 20:27 30:37 40:47 60:67 80:87]; | |
21 end | |
22 | |
23 %% Prepare test data | |
24 nsecs = 100; | |
25 fs = 10; | |
26 | |
27 unit_list = unit.supportedUnits; | |
28 u1 = unit(cell2mat(utils.math.randelement(unit_list,1))); | |
29 u2 = unit(cell2mat(utils.math.randelement(unit_list,1))); | |
30 u3 = unit(cell2mat(utils.math.randelement(unit_list,1))); | |
31 u4 = unit(cell2mat(utils.math.randelement(unit_list,1))); | |
32 | |
33 pl1 = plist('nsecs', nsecs, 'fs', fs, ... | |
34 'tsfcn', 'polyval([10 1], t) + randn(size(t))', ... | |
35 'xunits', 's', 'yunits', u1); | |
36 | |
37 pl2 = plist('nsecs', nsecs, 'fs', fs, ... | |
38 'tsfcn', 'polyval([-5 0.2], t) + randn(size(t))', ... | |
39 'xunits', 's', 'yunits', u2); | |
40 | |
41 t1 = [0:5:200]'; | |
42 f1 = [1e-3:1e-3:0.1]; | |
43 z1 = [1e-2:1e-2:1]; | |
44 | |
45 T1 = ao(t1, randn(size(t1)), plist('type', 'tsdata'));T1c = ao(t1); | |
46 F1 = ao(f1, randn(size(f1)), plist('type', 'fsdata'));F1c = ao(f1); | |
47 Z1 = ao(z1, randn(size(z1)), plist('type', 'xydata'));Z1c = ao(z1); | |
48 | |
49 a1 = ao(pl1); | |
50 a2 = ao(pl2); | |
51 a2b = ao(pl2); | |
52 a3 = ao(plist('yvals', 2, 'yunits', u4))*a2 + ao(plist('yvals', -3, 'yunits', u4))*a2b; | |
53 | |
54 % Prepare some pest objects: single x | |
55 p_1 = linfit(a1, plist()); | |
56 p_2 = linfit(a1, a2, plist()); | |
57 | |
58 p_t = pest(plist('paramnames', {'a0','a1','a2'}, 'y', [1 2 3], ... | |
59 'cov', [0.1 0.001 -0.001;0.001 0.1 -0.002;-0.001 -0.002 0.1;], ... | |
60 'dy', sqrt([0.1 0.1 0.1]), ... | |
61 'yunits', {u3, u3/unit('s') u3/unit('s^2')}, ... | |
62 'models', smodel(plist('expression', 'a1.*t + a2.*t.^2 + a0', 'xvar', 't', 'yunits', u3, 'xunits', 'ms'))) ... | |
63 ); | |
64 | |
65 p_f = pest(plist('paramnames', {'a0','a1','a2'}, 'y', [1 2 3], ... | |
66 'cov', [0.1 0.001 -0.001;0.001 0.1 -0.002;-0.001 -0.002 0.1;], ... | |
67 'dy', sqrt([0.1 0.1 0.1]), ... | |
68 'yunits', {u3, u3/unit('Hz') u3/unit('Hz^2')}, ... | |
69 'models', smodel(plist('expression', 'a1.*f + a2.*f.^2 + a0', 'xvar', 'f', 'yunits', u3, 'xunits', 'kHz'))) ... | |
70 ); | |
71 | |
72 p_w = pest(plist('paramnames', {'a0','a1','a2'}, 'y', [1 2 3], ... | |
73 'cov', [0.1 0.001 -0.001;0.001 0.1 -0.002;-0.001 -0.002 0.1;], ... | |
74 'dy', sqrt([0.1 0.1 0.1]), ... | |
75 'yunits', {u3, u3/unit('Hz') u3/unit('Hz^2')}, ... | |
76 'models', smodel(plist('expression', 'a1.*w + a2.*w.^2 + a0', 'xvar', 'w', 'yunits', u3, 'xunits', 'MHz'))) ... | |
77 ); | |
78 | |
79 p_z = pest(plist('paramnames', {'a0','a1','a2'}, 'y', [1 2 3], ... | |
80 'cov', [0.1 0.001 -0.001;0.001 0.1 -0.002;-0.001 -0.002 0.1;], ... | |
81 'dy', sqrt([0.1 0.1 0.1]), ... | |
82 'yunits', {u3, u3/unit('') u3/unit('')}, ... | |
83 'models', smodel(plist('expression', 'a1.*z + a2.*z.^2 + a0', 'xvar', 'z', 'yunits', u3))) ... | |
84 ); | |
85 | |
86 % Prepare some pest objects: multiple x | |
87 p_3 = bilinfit(a2, a2b, a3); | |
88 | |
89 p_tt = pest(plist('paramnames', {'a0','a1','a2'}, 'y', [1 2 3], ... | |
90 'cov', [0.1 0.001 -0.001;0.001 0.1 -0.002;-0.001 -0.002 0.1;], ... | |
91 'dy', sqrt([0.1 0.1 0.1]), ... | |
92 'yunits', {u3, u3/unit('s') u3/unit('s^2')}, ... | |
93 'models', smodel(plist('expression', 'a1.*t1 + a2.*t2.^2 + a0', 'xvar', {'t1', 't2'}, 'yunits', u3, 'xunits', {'ms', 'ms'}))) ... | |
94 ); | |
95 | |
96 p_ff = pest(plist('paramnames', {'a0','a1','a2'}, 'y', [1 2 3], ... | |
97 'cov', [0.1 0.001 -0.001;0.001 0.1 -0.002;-0.001 -0.002 0.1;], ... | |
98 'dy', sqrt([0.1 0.1 0.1]), ... | |
99 'yunits', {u3, u3/unit('Hz') u3/unit('Hz^2')}, ... | |
100 'models', smodel(plist('expression', 'a1.*f1 + a2.*f2.^2 + a0', 'xvar', {'f1', 'f2'}, 'yunits', u3, 'xunits', {'kHz', 'kHz'}))) ... | |
101 ); | |
102 | |
103 p_ww = pest(plist('paramnames', {'a0','a1','a2'}, 'y', [1 2 3], ... | |
104 'cov', [0.1 0.001 -0.001;0.001 0.1 -0.002;-0.001 -0.002 0.1;], ... | |
105 'dy', sqrt([0.1 0.1 0.1]), ... | |
106 'yunits', {u3, u3/unit('Hz') u3/unit('Hz^2')}, ... | |
107 'models', smodel(plist('expression', 'a1.*w1 + a2.*w2.^2 + a0', 'xvar', {'w1', 'w2'}, 'yunits', u3, 'xunits', {'MHz', 'MHz'}))) ... | |
108 ); | |
109 | |
110 p_zz = pest(plist('paramnames', {'a0','a1','a2'}, 'y', [1 2 3], ... | |
111 'cov', [0.1 0.001 -0.001;0.001 0.1 -0.002;-0.001 -0.002 0.1;], ... | |
112 'dy', sqrt([0.1 0.1 0.1]), ... | |
113 'yunits', {u3, u3/unit('') u3/unit('')}, ... | |
114 'models', smodel(plist('expression', 'a1.*z1 + a2.*z2.^2 + a0', 'xvar', {'z1', 'z2'}, 'yunits', u3))) ... | |
115 ); | |
116 | |
117 %% Run tests | |
118 results = []; | |
119 | |
120 %% 10) Single Xdata in plist, double, Xvar = x | |
121 test = 10; | |
122 if any(ismember(list, test)) | |
123 o = p_1.eval(plist(... | |
124 'Xdata', t1, ... | |
125 'type', '' ... %% This should be ignored | |
126 )); | |
127 | |
128 results = [results; test check_correctness(o, plist(... | |
129 'type', 'xydata', 'x', t1, 'xunits', a1.xunits, 'yunits', a1.yunits, 'dy', true))]; | |
130 end | |
131 | |
132 %% 11) Single Xdata in plist, double, Xvar = t | |
133 test = 11; | |
134 if any(ismember(list, test)) | |
135 o = p_t.eval(plist(... | |
136 'Xdata', t1, ... | |
137 'type', '' ... %% This should be ignored | |
138 )); | |
139 | |
140 results = [results; test check_correctness(o, plist(... | |
141 'type', 'tsdata', 'x', t1, 'xunits', p_t.models.xunits, 'yunits', u3, 'dy', true))]; | |
142 end | |
143 | |
144 %% 12) Single Xdata in plist, double, Xvar = f | |
145 test = 12; | |
146 if any(ismember(list, test)) | |
147 o = p_f.eval(plist(... | |
148 'Xdata', f1, ... | |
149 'type', '' ... %% This should be ignored | |
150 )); | |
151 | |
152 results = [results; test check_correctness(o, plist(... | |
153 'type', 'fsdata', 'x', f1, 'xunits', p_f.models.xunits, 'yunits', u3, 'dy', true))]; | |
154 end | |
155 | |
156 %% 13) Single Xdata in plist, double, Xvar = w | |
157 test = 13; | |
158 if any(ismember(list, test)) | |
159 o = p_w.eval(plist(... | |
160 'Xdata', f1, ... | |
161 'type', '' ... %% This should be ignored | |
162 )); | |
163 | |
164 results = [results; test check_correctness(o, plist(... | |
165 'type', 'fsdata', 'x', f1, 'xunits', p_w.models.xunits, 'yunits', u3, 'dy', true))]; | |
166 end | |
167 %% 14) Single Xdata in plist, double, Xvar = z, specify data type | |
168 test = 14; | |
169 if any(ismember(list, test)) | |
170 type = 'tsdata'; | |
171 o = p_z.eval(plist(... | |
172 'Xdata', t1, ... | |
173 'type', type ... | |
174 )); | |
175 | |
176 results = [results; test check_correctness(o, plist(... | |
177 'type', type, 'x', t1, 'xunits', 's', 'yunits', u3, 'dy', true))]; | |
178 end | |
179 | |
180 %% 15) Single Xdata in plist, double, Xvar = z, specify data type | |
181 test = 15; | |
182 if any(ismember(list, test)) | |
183 type = 'fsdata'; | |
184 o = p_z.eval(plist(... | |
185 'Xdata', z1, ... | |
186 'type', type ... | |
187 )); | |
188 | |
189 results = [results; test check_correctness(o, plist(... | |
190 'type', type, 'x', z1, 'xunits', 'Hz', 'yunits', u3, 'dy', true))]; | |
191 end | |
192 | |
193 %% 16) Single Xdata in plist, double, Xvar = z, specify data type | |
194 test = 16; | |
195 if any(ismember(list, test)) | |
196 type = 'xydata'; | |
197 o = p_z.eval(plist(... | |
198 'Xdata', z1, ... | |
199 'type', type ... | |
200 )); | |
201 | |
202 results = [results; test check_correctness(o, plist(... | |
203 'type', type, 'x', z1, 'xunits', '', 'yunits', u3, 'dy', true))]; | |
204 end | |
205 | |
206 %% 17) Single Xdata in plist, double, Xvar = z, do not specify data type | |
207 test = 17; | |
208 if any(ismember(list, test)) | |
209 o = p_z.eval(plist(... | |
210 'Xdata', z1)); | |
211 | |
212 results = [results; test check_correctness(o, plist(... | |
213 'type', 'xydata', 'x', z1, 'xunits', '', 'yunits', u3, 'dy', true))]; | |
214 end | |
215 | |
216 %% 20) Single Xdata in plist, ao, Xvar = x | |
217 test = 20; | |
218 if any(ismember(list, test)) | |
219 o = p_1.eval(plist(... | |
220 'Xdata', T1, ... | |
221 'type', '' ... %% This should be ignored | |
222 )); | |
223 | |
224 results = [results; test check_correctness(o, plist(... | |
225 'type', 'xydata', 'x', T1.x, 'xunits', a1.xunits, 'yunits', a1.yunits, 'dy', true))]; | |
226 | |
227 | |
228 o = p_1.eval(plist(... | |
229 'Xdata', T1c, ... | |
230 'type', '' ... %% This should be ignored | |
231 )); | |
232 | |
233 results = [results; test check_correctness(o, plist(... | |
234 'type', 'xydata', 'x', T1c.y, 'xunits', a1.xunits, 'yunits', a1.yunits, 'dy', true))]; | |
235 end | |
236 | |
237 %% 21) Single Xdata in plist, ao, Xvar = t | |
238 test = 21; | |
239 if any(ismember(list, test)) | |
240 o = p_t.eval(plist(... | |
241 'Xdata', T1, ... | |
242 'type', '' ... %% This should be ignored | |
243 )); | |
244 | |
245 results = [results; test check_correctness(o, plist(... | |
246 'type', 'tsdata', 'x', T1.x, 'xunits', p_t.models.xunits, 'yunits', u3, 'dy', true))]; | |
247 | |
248 o = p_t.eval(plist(... | |
249 'Xdata', T1c, ... | |
250 'type', '' ... %% This should be ignored | |
251 )); | |
252 | |
253 results = [results; test check_correctness(o, plist(... | |
254 'type', 'tsdata', 'x', T1c.y, 'xunits', p_t.models.xunits, 'yunits', u3, 'dy', true))]; | |
255 end | |
256 | |
257 %% 22) Single Xdata in plist, ao, Xvar = f | |
258 test = 22; | |
259 if any(ismember(list, test)) | |
260 o = p_f.eval(plist(... | |
261 'Xdata', F1, ... | |
262 'type', '' ... %% This should be ignored | |
263 )); | |
264 | |
265 results = [results; test check_correctness(o, plist(... | |
266 'type', 'fsdata', 'x', F1.x, 'xunits', p_f.models.xunits, 'yunits', u3, 'dy', true))]; | |
267 | |
268 o = p_f.eval(plist(... | |
269 'Xdata', F1c, ... | |
270 'type', '' ... %% This should be ignored | |
271 )); | |
272 | |
273 results = [results; test check_correctness(o, plist(... | |
274 'type', 'fsdata', 'x', F1c.y, 'xunits', p_f.models.xunits, 'yunits', u3, 'dy', true))]; | |
275 end | |
276 | |
277 %% 23) Single Xdata in plist, ao, Xvar = w | |
278 test = 23; | |
279 if any(ismember(list, test)) | |
280 o = p_w.eval(plist(... | |
281 'Xdata', F1, ... | |
282 'type', '' ... %% This should be ignored | |
283 )); | |
284 | |
285 results = [results; test check_correctness(o, plist(... | |
286 'type', 'fsdata', 'x', F1.x, 'xunits', p_w.models.xunits, 'yunits', u3, 'dy', true))]; | |
287 | |
288 o = p_w.eval(plist(... | |
289 'Xdata', F1c, ... | |
290 'type', '' ... %% This should be ignored | |
291 )); | |
292 | |
293 results = [results; test check_correctness(o, plist(... | |
294 'type', 'fsdata', 'x', F1c.y, 'xunits', p_w.models.xunits, 'yunits', u3, 'dy', true))]; | |
295 end | |
296 | |
297 %% 24) Single Xdata in plist, ao, Xvar = z, specify data type | |
298 test = 24; | |
299 if any(ismember(list, test)) | |
300 type = 'tsdata'; | |
301 o = p_z.eval(plist(... | |
302 'Xdata', T1, ... | |
303 'type', type ... | |
304 )); | |
305 | |
306 results = [results; test check_correctness(o, plist(... | |
307 'type', type, 'x', T1.x, 'xunits', 's', 'yunits', u3, 'dy', true))]; | |
308 | |
309 o = p_z.eval(plist(... | |
310 'Xdata', T1c, ... | |
311 'type', type)); | |
312 | |
313 results = [results; test check_correctness(o, plist(... | |
314 'type', type, 'x', T1c.y, 'xunits', 's', 'yunits', u3, 'dy', true))]; | |
315 end | |
316 | |
317 %% 25) Single Xdata in plist, ao, Xvar = z, specify data type | |
318 test = 25; | |
319 if any(ismember(list, test)) | |
320 type = 'fsdata'; | |
321 o = p_z.eval(plist(... | |
322 'Xdata', Z1, ... | |
323 'type', type ... | |
324 )); | |
325 | |
326 results = [results; test check_correctness(o, plist(... | |
327 'type', type, 'x', Z1.x, 'xunits', 'Hz', 'yunits', u3, 'dy', true))]; | |
328 | |
329 o = p_z.eval(plist(... | |
330 'Xdata', Z1c, ... | |
331 'type', type ... | |
332 )); | |
333 | |
334 results = [results; test check_correctness(o, plist(... | |
335 'type', type, 'x', Z1c.y, 'xunits', 'Hz', 'yunits', u3, 'dy', true))]; | |
336 end | |
337 | |
338 %% 26) Single Xdata in plist, ao, Xvar = z, specify data type | |
339 test = 26; | |
340 if any(ismember(list, test)) | |
341 type = 'xydata'; | |
342 o = p_z.eval(plist(... | |
343 'Xdata', Z1, ... | |
344 'type', type ... | |
345 )); | |
346 | |
347 results = [results; test check_correctness(o, plist(... | |
348 'type', type, 'x', Z1.x, 'xunits', '', 'yunits', u3, 'dy', true))]; | |
349 | |
350 o = p_z.eval(plist(... | |
351 'Xdata', Z1c, ... | |
352 'type', type ... | |
353 )); | |
354 | |
355 results = [results; test check_correctness(o, plist(... | |
356 'type', type, 'x', Z1c.y, 'xunits', '', 'yunits', u3, 'dy', true))]; | |
357 end | |
358 | |
359 %% 27) Single Xdata in plist, ao, Xvar = z, do not specify data type | |
360 test = 27; | |
361 if any(ismember(list, test)) | |
362 o = p_z.eval(plist(... | |
363 'Xdata', Z1)); | |
364 | |
365 results = [results; test check_correctness(o, plist(... | |
366 'type', 'xydata', 'x', Z1.x, 'xunits', '', 'yunits', u3, 'dy', true))]; | |
367 | |
368 o = p_z.eval(plist(... | |
369 'Xdata', Z1c)); | |
370 | |
371 results = [results; test check_correctness(o, plist(... | |
372 'type', 'xydata', 'x', Z1c.y, 'xunits', '', 'yunits', u3, 'dy', true))]; | |
373 end | |
374 | |
375 %% 30) Multiple Xdata in plist, double, Xvar = x | |
376 test = 30; | |
377 if any(ismember(list, test)) | |
378 o = p_3.eval(plist(... | |
379 'Xdata', {t1, t1}, ... | |
380 'type', '' ... %% This should be ignored | |
381 )); | |
382 | |
383 results = [results; test check_correctness(o, plist(... | |
384 'type', 'xydata', 'x', t1, 'xunits', '', 'yunits', a3.yunits, 'dy', true))]; | |
385 end | |
386 | |
387 %% 31) Multiple Xdata in plist, double, Xvar = t, specify data type | |
388 test = 31; | |
389 if any(ismember(list, test)) | |
390 type = 'tsdata'; | |
391 o = p_tt.eval(plist(... | |
392 'Xdata', {t1 t1}, ... | |
393 'type', type ... | |
394 )); | |
395 | |
396 results = [results; test check_correctness(o, plist(... | |
397 'type', type, 'x', t1, 'xunits', 's', 'yunits', u3, 'dy', true))]; | |
398 end | |
399 | |
400 %% 32) Multiple Xdata in plist, double, Xvar = f, don't specify data type | |
401 test = 32; | |
402 if any(ismember(list, test)) | |
403 o = p_ff.eval(plist(... | |
404 'Xdata', {f1 f1}, ... | |
405 'type', '' ... | |
406 )); | |
407 | |
408 results = [results; test check_correctness(o, plist(... | |
409 'type', 'xydata', 'x', f1, 'xunits', '', 'yunits', u3, 'dy', true))]; | |
410 end | |
411 | |
412 %% 33) Multiple Xdata in plist, double, Xvar = w, specify data type | |
413 test = 33; | |
414 if any(ismember(list, test)) | |
415 type = 'xydata'; | |
416 o = p_ww.eval(plist(... | |
417 'Xdata', {f1 f1}, ... | |
418 'type', type ... | |
419 )); | |
420 | |
421 results = [results; test check_correctness(o, plist(... | |
422 'type', type, 'x', f1, 'xunits', '', 'yunits', u3, 'dy', true))]; | |
423 end | |
424 | |
425 %% 34) Multiple Xdata in plist, double, Xvar = z, specify data type | |
426 test = 34; | |
427 if any(ismember(list, test)) | |
428 type = 'tsdata'; | |
429 o = p_zz.eval(plist(... | |
430 'Xdata', {t1 t1}, ... | |
431 'type', type ... | |
432 )); | |
433 | |
434 results = [results; test check_correctness(o, plist(... | |
435 'type', type, 'x', t1, 'xunits', 's', 'yunits', u3, 'dy', true))]; | |
436 end | |
437 | |
438 %% 35) Multiple Xdata in plist, double, Xvar = z, specify data type | |
439 test = 35; | |
440 if any(ismember(list, test)) | |
441 type = 'fsdata'; | |
442 o = p_zz.eval(plist(... | |
443 'Xdata', {z1 z1}, ... | |
444 'type', type ... | |
445 )); | |
446 | |
447 results = [results; test check_correctness(o, plist(... | |
448 'type', type, 'x', z1, 'xunits', 'Hz', 'yunits', u3, 'dy', true))]; | |
449 end | |
450 | |
451 %% 36) Multiple Xdata in plist, double, Xvar = z, specify data type | |
452 test = 36; | |
453 if any(ismember(list, test)) | |
454 type = 'xydata'; | |
455 o = p_zz.eval(plist(... | |
456 'Xdata', {z1 z1}, ... | |
457 'type', type ... | |
458 )); | |
459 | |
460 results = [results; test check_correctness(o, plist(... | |
461 'type', type, 'x', z1, 'xunits', '', 'yunits', u3, 'dy', true))]; | |
462 end | |
463 | |
464 %% 37) Multiple Xdata in plist, double, Xvar = z, do not specify data type | |
465 test = 37; | |
466 if any(ismember(list, test)) | |
467 o = p_zz.eval(plist(... | |
468 'Xdata', {z1 z1})); | |
469 | |
470 results = [results; test check_correctness(o, plist(... | |
471 'type', 'xydata', 'x', z1, 'xunits', '', 'yunits', u3, 'dy', true))]; | |
472 end | |
473 | |
474 %% 40) Multiple Xdata in plist, ao, Xvar = x | |
475 test = 40; | |
476 if any(ismember(list, test)) | |
477 o = p_3.eval(plist(... | |
478 'Xdata', {T1, T1}, ... | |
479 'type', '' ... %% This should be ignored | |
480 )); | |
481 | |
482 results = [results; test check_correctness(o, plist(... | |
483 'type', class(T1.data), 'x', T1.x, 'xunits', T1.xunits, 'yunits', a3.yunits, 'dy', true))]; | |
484 | |
485 o = p_3.eval(plist(... | |
486 'Xdata', {T1c, T1c}, ... | |
487 'type', '' ... %% This should be ignored | |
488 )); | |
489 | |
490 results = [results; test check_correctness(o, plist(... % No need to pass x & xunits in this case | |
491 'type', class(T1c.data), 'yunits', a3.yunits, 'dy', true))]; | |
492 end | |
493 | |
494 %% 41) Multiple Xdata in plist, ao, Xvar = t, specify data type | |
495 test = 41; | |
496 if any(ismember(list, test)) | |
497 type = 'tsdata'; | |
498 o = p_tt.eval(plist(... | |
499 'Xdata', {T1 T1}, ... | |
500 'type', type ... % This should be ignored | |
501 )); | |
502 | |
503 results = [results; test check_correctness(o, plist(... | |
504 'type', class(T1.data), 'x', T1.x, 'xunits', T1.xunits, 'yunits', u3, 'dy', true))]; | |
505 | |
506 o = p_tt.eval(plist(... | |
507 'Xdata', {T1c, T1c}, ... | |
508 'type', '' ... %% This should be ignored | |
509 )); | |
510 | |
511 results = [results; test check_correctness(o, plist(...% No need to pass x & xunits in this case | |
512 'type', class(T1c.data), 'yunits', u3, 'dy', true))]; | |
513 end | |
514 | |
515 %% 42) Multiple Xdata in plist, ao, Xvar = f, don't specify data type | |
516 test = 42; | |
517 if any(ismember(list, test)) | |
518 o = p_ff.eval(plist(... | |
519 'Xdata', {F1 F1}, ... | |
520 'type', '' ... %% This should be ignored | |
521 )); | |
522 | |
523 results = [results; test check_correctness(o, plist(... | |
524 'type', class(F1.data), 'x', F1.x, 'xunits', F1.xunits, 'yunits', u3, 'dy', true))]; | |
525 | |
526 o = p_ff.eval(plist(... | |
527 'Xdata', {F1c, F1c}, ... | |
528 'type', '' ... %% This should be ignored | |
529 )); | |
530 | |
531 results = [results; test check_correctness(o, plist(...% No need to pass x & xunits in this case | |
532 'type', class(F1c.data), 'yunits', u3, 'dy', true))]; | |
533 end | |
534 | |
535 %% 43) Multiple Xdata in plist, ao, Xvar = w, specify data type | |
536 test = 43; | |
537 if any(ismember(list, test)) | |
538 type = 'xydata'; | |
539 o = p_ww.eval(plist(... | |
540 'Xdata', {F1 F1}, ... | |
541 'type', type ... %% This should be ignored | |
542 )); | |
543 | |
544 results = [results; test check_correctness(o, plist(... | |
545 'type', class(F1.data), 'x', F1.x, 'xunits', F1.xunits, 'yunits', u3, 'dy', true))]; | |
546 | |
547 o = p_ff.eval(plist(... | |
548 'Xdata', {F1c, F1c}, ... | |
549 'type', '' ... %% This should be ignored | |
550 )); | |
551 | |
552 results = [results; test check_correctness(o, plist(...% No need to pass x & xunits in this case | |
553 'type', class(F1c.data), 'yunits', u3, 'dy', true))]; | |
554 end | |
555 | |
556 %% 44) Multiple Xdata in plist, ao, Xvar = z, specify data type | |
557 test = 44; | |
558 if any(ismember(list, test)) | |
559 type = 'tsdata'; | |
560 o = p_zz.eval(plist(... | |
561 'Xdata', {T1 T1}, ... | |
562 'type', type ... %% This should be ignored | |
563 )); | |
564 | |
565 results = [results; test check_correctness(o, plist(... | |
566 'type', class(T1.data), 'x', T1.x, 'xunits', T1.xunits, 'yunits', u3, 'dy', true))]; | |
567 | |
568 o = p_ff.eval(plist(... | |
569 'Xdata', {T1c, T1c}, ... | |
570 'type', '' ... %% This should be ignored | |
571 )); | |
572 | |
573 results = [results; test check_correctness(o, plist(...% No need to pass x & xunits in this case | |
574 'type', class(T1c.data), 'yunits', u3, 'dy', true))]; | |
575 end | |
576 | |
577 %% 45) Multiple Xdata in plist, ao, Xvar = z, specify data type | |
578 test = 45; | |
579 if any(ismember(list, test)) | |
580 type = 'fsdata'; | |
581 o = p_zz.eval(plist(... | |
582 'Xdata', {Z1 Z1}, ... | |
583 'type', type ... %% This should be ignored | |
584 )); | |
585 | |
586 results = [results; test check_correctness(o, plist(... | |
587 'type', class(Z1.data), 'x', Z1.x, 'xunits', Z1.xunits, 'yunits', u3, 'dy', true))]; | |
588 | |
589 o = p_ff.eval(plist(... | |
590 'Xdata', {Z1c, Z1c}, ... | |
591 'type', '' ... %% This should be ignored | |
592 )); | |
593 | |
594 results = [results; test check_correctness(o, plist(...% No need to pass x & xunits in this case | |
595 'type', class(Z1c.data), 'yunits', u3, 'dy', true))]; | |
596 end | |
597 | |
598 %% 46) Multiple Xdata in plist, ao, Xvar = z, specify data type | |
599 test = 46; | |
600 if any(ismember(list, test)) | |
601 type = 'xydata'; | |
602 o = p_zz.eval(plist(... | |
603 'Xdata', {Z1 Z1}, ... | |
604 'type', type ... %% This should be ignored | |
605 )); | |
606 | |
607 results = [results; test check_correctness(o, plist(... | |
608 'type', class(Z1.data), 'x', Z1.x, 'xunits', Z1.xunits, 'yunits', u3, 'dy', true))]; | |
609 | |
610 o = p_ff.eval(plist(... | |
611 'Xdata', {Z1c, Z1c}, ... | |
612 'type', '' ... %% This should be ignored | |
613 )); | |
614 | |
615 results = [results; test check_correctness(o, plist(...% No need to pass x & xunits in this case | |
616 'type', class(Z1c.data), 'yunits', u3, 'dy', true))]; | |
617 end | |
618 | |
619 %% 47) Multiple Xdata in plist, ao, Xvar = z, do not specify data type | |
620 test = 47; | |
621 if any(ismember(list, test)) | |
622 o = p_zz.eval(plist(... | |
623 'Xdata', {Z1 Z1})); | |
624 | |
625 results = [results; test check_correctness(o, plist(... | |
626 'type', 'xydata', 'x', Z1.x, 'xunits', Z1.xunits, 'yunits', u3, 'dy', true))]; | |
627 | |
628 o = p_zz.eval(plist(... | |
629 'Xdata', {Z1c, Z1c}, ... | |
630 'type', '' ... %% This should be ignored | |
631 )); | |
632 | |
633 results = [results; test check_correctness(o, plist(...% No need to pass x & xunits in this case | |
634 'type', class(Z1c.data), 'yunits', u3, 'dy', true))]; | |
635 end | |
636 | |
637 %% 50) Single Xdata in input, double, Xvar = x | |
638 test = 50; | |
639 if any(ismember(list, test)) | |
640 disp('Syntax not supported') | |
641 end | |
642 | |
643 %% 60) Single Xdata in input, ao, Xvar = x | |
644 test = 60; | |
645 if any(ismember(list, test)) | |
646 o = p_1.eval(T1, plist(... | |
647 'type', '' ... %% This should be ignored | |
648 )); | |
649 | |
650 results = [results; test check_correctness(o, plist(... | |
651 'type', 'xydata', 'x', T1.x, 'xunits', a1.xunits, 'yunits', a1.yunits, 'dy', true))]; | |
652 | |
653 o = p_1.eval(T1c, plist(... | |
654 'type', '' ... %% This should be ignored | |
655 )); | |
656 | |
657 results = [results; test check_correctness(o, plist(... | |
658 'type', 'xydata', 'x', T1c.y, 'xunits', a1.xunits, 'yunits', a1.yunits, 'dy', true))]; | |
659 end | |
660 | |
661 %% 61) Single Xdata in input, ao, Xvar = t | |
662 test = 61; | |
663 if any(ismember(list, test)) | |
664 o = p_t.eval(T1, plist(... | |
665 'type', '' ... %% This should be ignored | |
666 )); | |
667 | |
668 results = [results; test check_correctness(o, plist(... | |
669 'type', 'tsdata', 'x', T1.x, 'xunits', p_t.models.xunits, 'yunits', u3, 'dy', true))]; | |
670 | |
671 o = p_t.eval(T1c, plist(... | |
672 'type', '' ... %% This should be ignored | |
673 )); | |
674 | |
675 results = [results; test check_correctness(o, plist(... | |
676 'type', 'tsdata', 'x', T1c.y, 'xunits', p_t.models.xunits, 'yunits', u3, 'dy', true))]; | |
677 end | |
678 | |
679 %% 62) Single Xdata in plist, ao, Xvar = f | |
680 test = 62; | |
681 if any(ismember(list, test)) | |
682 o = p_f.eval(F1, plist(... | |
683 'type', '' ... %% This should be ignored | |
684 )); | |
685 | |
686 results = [results; test check_correctness(o, plist(... | |
687 'type', 'fsdata', 'x', F1.x, 'xunits', p_f.models.xunits, 'yunits', u3, 'dy', true))]; | |
688 | |
689 o = p_f.eval(F1c, plist(... | |
690 'type', '' ... %% This should be ignored | |
691 )); | |
692 | |
693 results = [results; test check_correctness(o, plist(... | |
694 'type', 'fsdata', 'x', F1c.y, 'xunits', p_f.models.xunits, 'yunits', u3, 'dy', true))]; | |
695 end | |
696 | |
697 %% 63) Single Xdata in plist, ao, Xvar = w | |
698 test = 63; | |
699 if any(ismember(list, test)) | |
700 o = p_w.eval(F1, plist(... | |
701 'type', '' ... %% This should be ignored | |
702 )); | |
703 | |
704 results = [results; test check_correctness(o, plist(... | |
705 'type', 'fsdata', 'x', F1.x, 'xunits', p_w.models.xunits, 'yunits', u3, 'dy', true))]; | |
706 | |
707 o = p_w.eval(F1c, plist(... | |
708 'type', '' ... %% This should be ignored | |
709 )); | |
710 | |
711 results = [results; test check_correctness(o, plist(... | |
712 'type', 'fsdata', 'x', F1c.y, 'xunits', p_w.models.xunits, 'yunits', u3, 'dy', true))]; | |
713 end | |
714 | |
715 %% 64) Single Xdata in plist, ao, Xvar = z, specify data type | |
716 test = 64; | |
717 if any(ismember(list, test)) | |
718 type = 'tsdata'; | |
719 o = p_z.eval(T1, plist(... | |
720 'type', type ... | |
721 )); | |
722 | |
723 results = [results; test check_correctness(o, plist(... | |
724 'type', type, 'x', T1.x, 'xunits', 's', 'yunits', u3, 'dy', true))]; | |
725 | |
726 o = p_z.eval(T1c, plist(... | |
727 'type', type)); | |
728 | |
729 results = [results; test check_correctness(o, plist(... | |
730 'type', type, 'x', T1c.y, 'xunits', 's', 'yunits', u3, 'dy', true))]; | |
731 end | |
732 | |
733 %% 65) Single Xdata in plist, ao, Xvar = z, specify data type | |
734 test = 65; | |
735 if any(ismember(list, test)) | |
736 type = 'fsdata'; | |
737 o = p_z.eval(Z1, plist(... | |
738 'type', type ... | |
739 )); | |
740 | |
741 results = [results; test check_correctness(o, plist(... | |
742 'type', type, 'x', Z1.x, 'xunits', 'Hz', 'yunits', u3, 'dy', true))]; | |
743 | |
744 o = p_z.eval(Z1c, plist(... | |
745 'type', type ... | |
746 )); | |
747 | |
748 results = [results; test check_correctness(o, plist(... | |
749 'type', type, 'x', Z1c.y, 'xunits', 'Hz', 'yunits', u3, 'dy', true))]; | |
750 end | |
751 | |
752 %% 66) Single Xdata in plist, ao, Xvar = z, specify data type | |
753 test = 66; | |
754 if any(ismember(list, test)) | |
755 type = 'xydata'; | |
756 o = p_z.eval(Z1, plist(... | |
757 'type', type ... | |
758 )); | |
759 | |
760 results = [results; test check_correctness(o, plist(... | |
761 'type', type, 'x', Z1.x, 'xunits', '', 'yunits', u3, 'dy', true))]; | |
762 | |
763 o = p_z.eval(Z1c, plist(... | |
764 'type', type ... | |
765 )); | |
766 | |
767 results = [results; test check_correctness(o, plist(... | |
768 'type', type, 'x', Z1c.y, 'xunits', '', 'yunits', u3, 'dy', true))]; | |
769 end | |
770 | |
771 %% 67) Single Xdata in plist, ao, Xvar = z, do not specify data type | |
772 test = 67; | |
773 if any(ismember(list, test)) | |
774 o = p_z.eval(Z1, plist()); | |
775 | |
776 results = [results; test check_correctness(o, plist(... | |
777 'type', 'xydata', 'x', Z1.x, 'xunits', '', 'yunits', u3, 'dy', true))]; | |
778 | |
779 o = p_z.eval(Z1c, plist()); | |
780 | |
781 results = [results; test check_correctness(o, plist(... | |
782 'type', 'xydata', 'x', Z1c.y, 'xunits', '', 'yunits', u3, 'dy', true))]; | |
783 end | |
784 | |
785 %% 70) Multiple Xdata in input, double | |
786 test = 70; | |
787 if any(ismember(list, test)) | |
788 disp('Syntax not supported') | |
789 end | |
790 | |
791 %% 80) Multiple Xdata in input, ao, Xvar = x | |
792 test = 80; | |
793 if any(ismember(list, test)) | |
794 o = p_3.eval(T1, T1, plist(... | |
795 'type', '' ... %% This should be ignored | |
796 )); | |
797 | |
798 results = [results; test check_correctness(o, plist(... | |
799 'type', class(T1.data), 'x', T1.x, 'xunits', T1.xunits, 'yunits', a3.yunits, 'dy', true))]; | |
800 | |
801 o = p_3.eval([T1 T1], plist(... | |
802 'type', '' ... %% This should be ignored | |
803 )); | |
804 | |
805 results = [results; test check_correctness(o, plist(... | |
806 'type', class(T1.data), 'x', T1.x, 'xunits', T1.xunits, 'yunits', a3.yunits, 'dy', true))]; | |
807 | |
808 end | |
809 | |
810 %% 81) Multiple Xdata in input, ao, Xvar = t, specify data type | |
811 test = 81; | |
812 if any(ismember(list, test)) | |
813 type = 'tsdata'; | |
814 o = p_tt.eval(T1, T1, plist(... | |
815 'type', type ... % This should be ignored | |
816 )); | |
817 | |
818 results = [results; test check_correctness(o, plist(... | |
819 'type', class(T1.data), 'x', T1.x, 'xunits', T1.xunits, 'yunits', u3, 'dy', true))]; | |
820 | |
821 o = p_tt.eval([T1 T1], plist(... | |
822 'type', type ... % This should be ignored | |
823 )); | |
824 | |
825 results = [results; test check_correctness(o, plist(... | |
826 'type', class(T1.data), 'x', T1.x, 'xunits', T1.xunits, 'yunits', u3, 'dy', true))]; | |
827 end | |
828 | |
829 %% 82) Multiple Xdata in input, ao, Xvar = f, don't specify data type | |
830 test = 82; | |
831 if any(ismember(list, test)) | |
832 o = p_ff.eval(F1, F1, plist(... | |
833 'type', '' ... %% This should be ignored | |
834 )); | |
835 | |
836 results = [results; test check_correctness(o, plist(... | |
837 'type', class(F1.data), 'x', F1.x, 'xunits', F1.xunits, 'yunits', u3, 'dy', true))]; | |
838 | |
839 o = p_ff.eval([F1 F1], plist(... | |
840 'type', '' ... %% This should be ignored | |
841 )); | |
842 | |
843 results = [results; test check_correctness(o, plist(... | |
844 'type', class(F1.data), 'x', F1.x, 'xunits', F1.xunits, 'yunits', u3, 'dy', true))]; | |
845 end | |
846 | |
847 %% 83) Multiple Xdata in input, ao, Xvar = w, specify data type | |
848 test = 83; | |
849 if any(ismember(list, test)) | |
850 type = 'xydata'; | |
851 o = p_ww.eval(F1, F1, plist(... | |
852 'type', type ... %% This should be ignored | |
853 )); | |
854 | |
855 results = [results; test check_correctness(o, plist(... | |
856 'type', class(F1.data), 'x', F1.x, 'xunits', F1.xunits, 'yunits', u3, 'dy', true))]; | |
857 | |
858 o = p_ww.eval([F1 F1], plist(... | |
859 'type', type ... %% This should be ignored | |
860 )); | |
861 | |
862 results = [results; test check_correctness(o, plist(... | |
863 'type', class(F1.data), 'x', F1.x, 'xunits', F1.xunits, 'yunits', u3, 'dy', true))]; | |
864 end | |
865 | |
866 %% 84) Multiple Xdata in input, ao, Xvar = z, specify data type | |
867 test = 84; | |
868 if any(ismember(list, test)) | |
869 type = 'tsdata'; | |
870 o = p_zz.eval(T1, T1, plist(... | |
871 'type', type ... %% This should be ignored | |
872 )); | |
873 | |
874 results = [results; test check_correctness(o, plist(... | |
875 'type', class(T1.data), 'x', T1.x, 'xunits', T1.xunits, 'yunits', u3, 'dy', true))]; | |
876 | |
877 o = p_zz.eval([T1 T1], plist(... | |
878 'type', type ... %% This should be ignored | |
879 )); | |
880 | |
881 results = [results; test check_correctness(o, plist(... | |
882 'type', class(T1.data), 'x', T1.x, 'xunits', T1.xunits, 'yunits', u3, 'dy', true))]; | |
883 end | |
884 | |
885 %% 85) Multiple Xdata in input, ao, Xvar = z, specify data type | |
886 test = 85; | |
887 if any(ismember(list, test)) | |
888 type = 'fsdata'; | |
889 o = p_zz.eval(Z1, Z1, plist(... | |
890 'type', type ... %% This should be ignored | |
891 )); | |
892 | |
893 results = [results; test check_correctness(o, plist(... | |
894 'type', class(Z1.data), 'x', Z1.x, 'xunits', Z1.xunits, 'yunits', u3, 'dy', true))]; | |
895 | |
896 o = p_zz.eval([Z1 Z1], plist(... | |
897 'type', type ... %% This should be ignored | |
898 )); | |
899 | |
900 results = [results; test check_correctness(o, plist(... | |
901 'type', class(Z1.data), 'x', Z1.x, 'xunits', Z1.xunits, 'yunits', u3, 'dy', true))]; | |
902 end | |
903 | |
904 %% 86) Multiple Xdata in plist, ao, Xvar = z, specify data type | |
905 test = 86; | |
906 if any(ismember(list, test)) | |
907 type = 'xydata'; | |
908 o = p_zz.eval(Z1, Z1, plist(... | |
909 'type', type ... %% This should be ignored | |
910 )); | |
911 | |
912 results = [results; test check_correctness(o, plist(... | |
913 'type', class(Z1.data), 'x', Z1.x, 'xunits', Z1.xunits, 'yunits', u3, 'dy', true))]; | |
914 | |
915 o = p_zz.eval([Z1 Z1], plist(... | |
916 'type', type ... %% This should be ignored | |
917 )); | |
918 | |
919 results = [results; test check_correctness(o, plist(... | |
920 'type', class(Z1.data), 'x', Z1.x, 'xunits', Z1.xunits, 'yunits', u3, 'dy', true))]; | |
921 end | |
922 | |
923 %% 87) Multiple Xdata in plist, ao, Xvar = z, do not specify data type | |
924 test = 87; | |
925 if any(ismember(list, test)) | |
926 o = p_zz.eval(Z1, Z1, plist()); | |
927 | |
928 results = [results; test check_correctness(o, plist(... | |
929 'type', 'xydata', 'x', Z1.x, 'xunits', Z1.xunits, 'yunits', u3, 'dy', true))]; | |
930 | |
931 o = p_zz.eval([Z1 Z1], plist()); | |
932 | |
933 results = [results; test check_correctness(o, plist(... | |
934 'type', 'xydata', 'x', Z1.x, 'xunits', Z1.xunits, 'yunits', u3, 'dy', true))]; | |
935 | |
936 o = p_zz.eval(Z1c, Z1c, plist(... | |
937 'type', '' ... %% This should be ignored | |
938 )); | |
939 | |
940 results = [results; test check_correctness(o, plist(...% No need to pass x & xunits in this case | |
941 'type', class(Z1c.data), 'yunits', u3, 'dy', true))]; | |
942 | |
943 o = p_zz.eval([Z1c Z1c], plist(... | |
944 'type', '' ... %% This should be ignored | |
945 )); | |
946 | |
947 results = [results; test check_correctness(o, plist(...% No need to pass x & xunits in this case | |
948 'type', class(Z1c.data), 'yunits', u3, 'dy', true))]; | |
949 end | |
950 | |
951 %% 90) Cases where we eval the x(s) in the models field (no input x) | |
952 | |
953 %% 100) An smodel with no xvar (should give cdata output) | |
954 | |
955 %% 110) Cases where we don't calculate dy | |
956 end | |
957 | |
958 function atest = check_correctness(o, pl) | |
959 | |
960 % Exceptions plist for ao/eq | |
961 ple = plist('Exceptions', ... | |
962 {'created', 'proctime', 'UUID', 'param/desc', 'name', 'methodInvars', 'version'}); | |
963 | |
964 % Start testing | |
965 atest = true; | |
966 % Check the output is of the proper type | |
967 if ~isa (o.data, pl.find('type')) | |
968 atest = false; | |
969 end | |
970 % Check the output x is the one provided (modulo the size, which is a problem of the "x" method) | |
971 if ~isa(o.data, 'cdata') | |
972 if ~isequal(size(o.x), size(pl.find('x'))) | |
973 if ~isequal(size(o.x'), size(pl.find('x'))) | |
974 atest = 0; | |
975 else | |
976 if ~isequal(o.x', pl.find('x')) | |
977 atest = 0; | |
978 end | |
979 end | |
980 else | |
981 if ~isequal(o.x, pl.find('x')) | |
982 atest = 0; | |
983 end | |
984 end | |
985 | |
986 % Check xunits | |
987 if ~eq(o.xunits, unit(pl.find('xunits'))) | |
988 atest = false; | |
989 end | |
990 end | |
991 % Check yunits | |
992 if ~eq(o.yunits, unit(pl.find('yunits'))) | |
993 atest = false; | |
994 end | |
995 % Check uncertainty | |
996 if isempty(o.dy) | |
997 atest = false; | |
998 end | |
999 % Check rebuild | |
1000 if ~eq(o.rebuild, o, ple) | |
1001 atest = false; | |
1002 end | |
1003 end |