Typo fixes
[scilab.git] / scilab / modules / graphics / tests / unit_tests / barhomogenize.tst
1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET
4 //
5 //  This file is distributed under the same license as the Scilab package.
6 // =============================================================================
7 //
8 // <-- TEST WITH GRAPHIC -->
9
10 // Unit test for barhomogenize
11
12 subplot(2,3,1);
13 xtitle("ex1: creation of 1 yellow bar and  3 bars");
14 x=1:3; y1=1:3; y2=[4 3 5;6 7 8;9 10 11];
15 bar(x,y1,"yellow");bar(x,y2);
16
17 subplot(2,3,2);
18 xtitle("grouped homogenization");
19 x=1:3; y1=1:3; y2=[4 3 5;6 7 8;9 10 11];
20 bar(x,y1,"yellow");bar(x,y2);
21 barhomogenize();
22
23 subplot(2,3,3);
24 xtitle("stacked homogenization");
25 x=1:3; y1=1:3; y2=[4 3 5;6 7 8;9 10 11];
26 bar(x,y1,"yellow");bar(x,y2);
27 barhomogenize("stacked",1);
28
29 f=gcf();
30 a1=f.children(1);
31 a2=f.children(2);
32 a3=f.children(3);
33 c11=a1.children(1);
34 c12=a1.children(2);
35 c21=a2.children(1);
36 c22=a2.children(2);
37 c31=a3.children(1);
38 c32=a3.children(2);
39 // Third graphic: stacked
40 p111=c11.children(1); // red polyline
41 p112=c11.children(2); // green polyline
42 p113=c11.children(3); // blue polyline
43 p121=c12.children(1); // yellow polyline
44 // Second graphic: grouped
45 p211=c21.children(1); // red polyline
46 p212=c21.children(2); // green polyline
47 p213=c21.children(3); // blue polyline
48 p221=c22.children(1); // yellow polyline
49 // First graphic: no homogenized
50 p311=c31.children(1); // red polyline
51 p312=c31.children(2); // green polyline
52 p313=c31.children(3); // blue polyline
53 p321=c32.children(1); // yellow polyline
54
55
56 // Check First graphic axes
57 assert_checkequal(a3.x_location, "bottom");
58 assert_checkequal(a3.y_location, "left");
59 assert_checkequal(a3.auto_ticks, ["off", "on", "on"]);
60 assert_checkequal(a3.x_ticks.locations, [1;2;3]);
61 assert_checkequal(a3.y_ticks.locations, [0;2;4;6;8;10;12]);
62 assert_checkequal(a3.z_ticks.locations, []);
63 assert_checkequal(a3.x_ticks.labels, ["1";"2";"3"]);
64 assert_checkequal(a3.y_ticks.labels, ["0";"2";"4";"6";"8";"10";"12"]);
65 assert_checkequal(a3.z_ticks.labels, []);
66 assert_checkequal(a3.sub_ticks, [0,1]);
67 assert_checktrue(abs(a3.data_bounds - [0.55,0;3.45,11]) < 0.05);
68 assert_checkequal(a3.margins(2:$), [0.125,0.125,0.125]);
69 assert_checktrue(abs(a3.axes_bounds - [0,0,0.3333333333,0.5]) < 0.0005);
70
71 // Check Second
72 assert_checkequal(a2.x_location, a3.x_location);
73 assert_checkequal(a2.y_location, a3.y_location);
74 assert_checkequal(a2.auto_ticks, a3.auto_ticks);
75 assert_checkequal(a2.x_ticks.locations, a3.x_ticks.locations);
76 assert_checkequal(a2.y_ticks.locations, a3.y_ticks.locations);
77 assert_checkequal(a2.z_ticks.locations, a3.z_ticks.locations);
78 assert_checkequal(a2.x_ticks.labels, a3.x_ticks.labels);
79 assert_checkequal(a2.y_ticks.labels, a3.y_ticks.labels);
80 assert_checkequal(a2.z_ticks.labels, a3.z_ticks.labels);
81 assert_checkequal(a2.sub_ticks, a3.sub_ticks);
82 assert_checktrue(abs(a2.data_bounds - a3.data_bounds) < 0.05);
83 assert_checkequal(a2.margins, a3.margins);
84 assert_checktrue(abs(a2.axes_bounds - a3.axes_bounds) < 0.5);
85
86 // Check third
87 assert_checkequal(a1.x_location, a3.x_location);
88 assert_checkequal(a1.y_location, a3.y_location);
89 assert_checkequal(a1.auto_ticks, a3.auto_ticks);
90 assert_checkequal(a1.x_ticks.locations, a3.x_ticks.locations);
91 assert_checkequal(a1.y_ticks.locations, [0;10;20;30]);
92 assert_checkequal(a1.z_ticks.locations, a3.z_ticks.locations);
93 assert_checkequal(a1.x_ticks.labels, a3.x_ticks.labels);
94 assert_checkequal(a1.y_ticks.labels, ["0";"10";"20";"30"]);
95 assert_checkequal(a1.z_ticks.labels, a3.z_ticks.labels);
96 assert_checkequal(a1.sub_ticks, a3.sub_ticks);
97 assert_checktrue(abs(a1.data_bounds - [0.55,0;3.45,33]) < 0.05);
98 assert_checkequal(a1.margins, a3.margins);
99 assert_checktrue(abs(a1.axes_bounds - [0.6666667,0,0.3333333,0.5]) < 0.05);
100
101 // Check polylines of first graphic
102 assert_checkequal(p311.data, [1,5;2,8;3,11]);
103 assert_checkequal(p311.line_style, 1);
104 assert_checkequal(p311.polyline_style, 6);
105 assert_checkequal(p311.foreground, -1);
106 assert_checkequal(p311.background, 5);
107 assert_checkequal(p311.mark_mode, "off");
108 assert_checkequal(p311.mark_style, 0);
109 assert_checkequal(p311.mark_size_unit, "point");
110 assert_checkequal(p311.mark_size, 0);
111 assert_checkequal(p311.mark_foreground, -1);
112 assert_checkequal(p311.mark_background, -2);
113 assert_checkequal(p311.x_shift, [0.3,0.3,0.3]);
114 assert_checkequal(p311.y_shift, []);
115 assert_checkalmostequal(p311.bar_width, 0.24);
116
117 assert_checkequal(p312.data, [1,3;2,7;3,10]);
118 assert_checkequal(p312.line_style, 1);
119 assert_checkequal(p312.polyline_style, 6);
120 assert_checkequal(p312.foreground, -1);
121 assert_checkequal(p312.background, 33);
122 assert_checkequal(p312.mark_mode, "off");
123 assert_checkequal(p312.mark_style, 0);
124 assert_checkequal(p312.mark_size_unit, "point");
125 assert_checkequal(p312.mark_size, 0);
126 assert_checkequal(p312.mark_foreground, -1);
127 assert_checkequal(p312.mark_background, -2);
128 assert_checkequal(p312.x_shift, [0,0,0]);
129 assert_checkequal(p312.y_shift, []);
130 assert_checkalmostequal(p312.bar_width, 0.24);
131
132 assert_checkequal(p313.data, [1,4;2,6;3,9]);
133 assert_checkequal(p313.line_style, 1);
134 assert_checkequal(p313.polyline_style, 6);
135 assert_checkequal(p313.foreground, -1);
136 assert_checkequal(p313.background, 2);
137 assert_checkequal(p313.mark_mode, "off");
138 assert_checkequal(p313.mark_style, 0);
139 assert_checkequal(p313.mark_size_unit, "point");
140 assert_checkequal(p313.mark_size, 0);
141 assert_checkequal(p313.mark_foreground, -1);
142 assert_checkequal(p313.mark_background, -2);
143 assert_checkequal(p313.x_shift, [-0.3,-0.3,-0.3]);
144 assert_checkequal(p313.y_shift, []);
145 assert_checkalmostequal(p313.bar_width, 0.24);
146
147 assert_checkequal(p321.data, [1,1;2,2;3,3]);
148 assert_checkequal(p321.line_style, 1);
149 assert_checkequal(p321.polyline_style, 6);
150 assert_checkequal(p321.foreground, -1);
151 assert_checkequal(p321.background, 7);
152 assert_checkequal(p321.mark_mode, "off");
153 assert_checkequal(p321.mark_style, 0);
154 assert_checkequal(p321.mark_size_unit, "point");
155 assert_checkequal(p321.mark_size, 0);
156 assert_checkequal(p321.mark_foreground, -1);
157 assert_checkequal(p321.mark_background, -2);
158 assert_checkequal(p321.x_shift, [0,0,0]);
159 assert_checkequal(p321.y_shift, []);
160 assert_checkalmostequal(p321.bar_width, 0.8);
161
162 // Check polylines of second graphic
163 assert_checkequal(p211.data, p311.data);
164 assert_checkequal(p211.line_style, p311.line_style);
165 assert_checkequal(p211.polyline_style, p311.polyline_style);
166 assert_checkequal(p211.foreground, p311.foreground);
167 assert_checkequal(p211.background, p311.background);
168 assert_checkequal(p211.mark_mode, p311.mark_mode);
169 assert_checkequal(p211.mark_style, p311.mark_style);
170 assert_checkequal(p211.mark_size_unit, p311.mark_size_unit);
171 assert_checkequal(p211.mark_size, p311.mark_size);
172 assert_checkequal(p211.mark_foreground, p311.mark_foreground);
173 assert_checkequal(p211.mark_background, p311.mark_background);
174 assert_checkequal(p211.x_shift, [-0.3375,-0.3375,-0.3375]);
175 assert_checkequal(p211.y_shift, [0,0,0]);
176 assert_checkalmostequal(p211.bar_width, 0.18);
177
178 assert_checkequal(p212.data, p312.data);
179 assert_checkequal(p212.line_style, p312.line_style);
180 assert_checkequal(p212.polyline_style, p312.polyline_style);
181 assert_checkequal(p212.foreground, p312.foreground);
182 assert_checkequal(p212.background, p312.background);
183 assert_checkequal(p212.mark_mode, p312.mark_mode);
184 assert_checkequal(p212.mark_style, p312.mark_style);
185 assert_checkequal(p212.mark_size_unit, p312.mark_size_unit);
186 assert_checkequal(p212.mark_size, p312.mark_size);
187 assert_checkequal(p212.mark_foreground, p312.mark_foreground);
188 assert_checkequal(p212.mark_background, p312.mark_background);
189 assert_checkequal(p212.x_shift, [-0.1125,-0.1125,-0.1125]);
190 assert_checkequal(p212.y_shift, p211.y_shift);
191 assert_checkalmostequal(p212.bar_width, p211.bar_width);
192
193 assert_checkequal(p213.data, p313.data);
194 assert_checkequal(p213.line_style, p313.line_style);
195 assert_checkequal(p213.polyline_style, p313.polyline_style);
196 assert_checkequal(p213.foreground, p313.foreground);
197 assert_checkequal(p213.background, p313.background);
198 assert_checkequal(p213.mark_mode, p313.mark_mode);
199 assert_checkequal(p213.mark_style, p313.mark_style);
200 assert_checkequal(p213.mark_size_unit, p313.mark_size_unit);
201 assert_checkequal(p213.mark_size, p313.mark_size);
202 assert_checkequal(p213.mark_foreground, p313.mark_foreground);
203 assert_checkequal(p213.mark_background, p313.mark_background);
204 assert_checkequal(p213.x_shift, [0.1125,0.1125,0.1125]);
205 assert_checkequal(p213.y_shift, p211.y_shift);
206 assert_checkalmostequal(p213.bar_width, p211.bar_width);
207
208 assert_checkequal(p221.data, p321.data);
209 assert_checkequal(p221.line_style, p321.line_style);
210 assert_checkequal(p221.polyline_style, p321.polyline_style);
211 assert_checkequal(p221.foreground, p321.foreground);
212 assert_checkequal(p221.background, p321.background);
213 assert_checkequal(p221.mark_mode, p321.mark_mode);
214 assert_checkequal(p221.mark_style, p321.mark_style);
215 assert_checkequal(p221.mark_size_unit, p321.mark_size_unit);
216 assert_checkequal(p221.mark_size, p321.mark_size);
217 assert_checkequal(p221.mark_foreground, p321.mark_foreground);
218 assert_checkequal(p221.mark_background, p321.mark_background);
219 assert_checkequal(p221.x_shift, [0.3375,0.3375,0.3375]);
220 assert_checkequal(p221.y_shift, p211.y_shift);
221 assert_checkalmostequal(p221.bar_width, p211.bar_width);
222
223 // Check polylines of third graphic
224 assert_checkequal(p111.data, p311.data);
225 assert_checkequal(p111.line_style, p311.line_style);
226 assert_checkequal(p111.polyline_style, p311.polyline_style);
227 assert_checkequal(p111.foreground, p311.foreground);
228 assert_checkequal(p111.background, p311.background);
229 assert_checkequal(p111.mark_mode, p311.mark_mode);
230 assert_checkequal(p111.mark_style, p311.mark_style);
231 assert_checkequal(p111.mark_size_unit, p311.mark_size_unit);
232 assert_checkequal(p111.mark_size, p311.mark_size);
233 assert_checkequal(p111.mark_foreground, p311.mark_foreground);
234 assert_checkequal(p111.mark_background, p311.mark_background);
235 assert_checkequal(p111.x_shift, [0,0,0]);
236 assert_checkequal(p111.y_shift, [0,0,0]);
237 assert_checkalmostequal(p111.bar_width, 0.9);
238
239 assert_checkequal(p112.data, p312.data);
240 assert_checkequal(p112.line_style, p312.line_style);
241 assert_checkequal(p112.polyline_style, p312.polyline_style);
242 assert_checkequal(p112.foreground, p312.foreground);
243 assert_checkequal(p112.background, p312.background);
244 assert_checkequal(p112.mark_mode, p312.mark_mode);
245 assert_checkequal(p112.mark_style, p312.mark_style);
246 assert_checkequal(p112.mark_size_unit, p312.mark_size_unit);
247 assert_checkequal(p112.mark_size, p312.mark_size);
248 assert_checkequal(p112.mark_foreground, p312.mark_foreground);
249 assert_checkequal(p112.mark_background, p312.mark_background);
250 assert_checkequal(p112.x_shift, [0,0,0]);
251 assert_checkequal(p112.y_shift, [5,8,11]);
252 assert_checkalmostequal(p112.bar_width, p111.bar_width);
253
254 assert_checkequal(p113.data, p313.data);
255 assert_checkequal(p113.line_style, p313.line_style);
256 assert_checkequal(p113.polyline_style, p313.polyline_style);
257 assert_checkequal(p113.foreground, p313.foreground);
258 assert_checkequal(p113.background, p313.background);
259 assert_checkequal(p113.mark_mode, p313.mark_mode);
260 assert_checkequal(p113.mark_style, p313.mark_style);
261 assert_checkequal(p113.mark_size_unit, p313.mark_size_unit);
262 assert_checkequal(p113.mark_size, p313.mark_size);
263 assert_checkequal(p113.mark_foreground, p313.mark_foreground);
264 assert_checkequal(p113.mark_background, p313.mark_background);
265 assert_checkequal(p113.x_shift, [0,0,0]);
266 assert_checkequal(p113.y_shift, [8,15,21]);
267 assert_checkalmostequal(p113.bar_width, p111.bar_width);
268
269 assert_checkequal(p121.data, p321.data);
270 assert_checkequal(p121.line_style, p321.line_style);
271 assert_checkequal(p121.polyline_style, p321.polyline_style);
272 assert_checkequal(p121.foreground, p321.foreground);
273 assert_checkequal(p121.background, p321.background);
274 assert_checkequal(p121.mark_mode, p321.mark_mode);
275 assert_checkequal(p121.mark_style, p321.mark_style);
276 assert_checkequal(p121.mark_size_unit, p321.mark_size_unit);
277 assert_checkequal(p121.mark_size, p321.mark_size);
278 assert_checkequal(p121.mark_foreground, p321.mark_foreground);
279 assert_checkequal(p121.mark_background, p321.mark_background);
280 assert_checkequal(p121.x_shift, [0,0,0]);
281 assert_checkequal(p121.y_shift, [12,21,30]);
282 assert_checkalmostequal(p121.bar_width, p111.bar_width);