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