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