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