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