CLI SHELL MODE only test
[scilab.git] / scilab / modules / hdf5 / tests / unit_tests / loadhdf5data.dia.ref
1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2011 - DIGITEO - Sylvestre LEDRU
4 //
5 //  This file is distributed under the same license as the Scilab package.
6 // =============================================================================
7 // <-- CLI SHELL MODE -->
8 // Load previously saved data (check backward compatibility)
9 ///// Empty matrix
10 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/emptymatrix.sod");
11 assert_checkequal(emptymatrix, []);
12 ///// Double
13 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/matricedoublescalar.sod");
14 assert_checkequal(ascalar,42);
15 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/matricedouble.sod");
16 assert_checkequal(a,[2,3;4,5]);
17 ///// Double complex
18 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/matricedoublecomplex.sod");
19 assert_checkequal(b,[2+%i,3+%i*2;4+%i*%pi,5]);
20 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/matricedoublecomplexscalar.sod");
21 assert_checkequal(bscalar,42+%i);
22 ///// String
23 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/matricestring.sod");
24 assert_checkequal(c,["my matrix","of strings";"is","saved in Scilab data format"]);
25 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/matricestringscalar.sod");
26 assert_checkequal(cscalar,["my single string"]);
27 // Polynomials
28 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/polynomials.sod");
29 p_reference=poly([1 2],'s') ;
30 assert_checkequal(p,p_reference);
31 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/polynomialscoef.sod");
32 q_reference=poly([1 42],'s','c');
33 assert_checkequal(q,q_reference);
34 // Boolean matrices
35 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/booleanscalar.sod");
36 assert_checkequal(bm,%t);
37 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/booleanmatrix.sod");
38 assert_checkequal(bmm,[%t,%f; %f, %t]);
39 // Sparse
40 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/sparsematrix.sod");
41 assert_checkequal(sp,sparse([1,2;4,5;3,10],[1,2,3]));
42 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/emptysparse.sod");
43 assert_checkequal(emptysparse,sparse([]));
44 // boolean sparse
45 dense=[%F, %F, %T, %F, %F
46 %T, %F, %F, %F, %F
47 %F, %F, %F, %F, %F
48 %F, %F, %F, %F, %T];
49 sp_reference=sparse(dense);
50 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/booleansparse.sod");
51 assert_checkequal(sp,sp_reference);
52 // List
53 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/list.sod");
54 assert_checkequal(ls,list(2,%i,'f',ones(3,3)));
55 ls(2) =  list( %t, [32,42]); // alter ls to add the list
56 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/listnested.sod");
57 assert_checkequal(lsnested,ls);
58 // tlist
59 lst_reference  =  tlist(['random numbers';'Name';'Example'], 'Uniform',ones(1,2, 3));
60 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/tlist.sod");
61 assert_checkequal(lst,lst_reference);
62 // mlist
63 M_ref=mlist(['V','name','value'],['a','b';'c' 'd'],[1 2; 3 4]);
64 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/mlist.sod");
65 // Commented because of bug 9531
66 //assert_checkequal(M_ref,M);
67 // hypermatrices
68 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/hypermatrix.sod");
69 assert_checkequal(HM,hypermat([2 3 2 2],1:24));
70 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/hypermatrixcomplex.sod");
71 HMC_reference(1,1,1,1:2)=[1+%i 2*2*%i];
72 assert_checkequal(HMC,HMC_reference);
73 // int
74 emptyint8matrix_ref = int8([]);
75 int8scalar_ref = int8(1);
76 int8rowvector_ref = int8([1 -4 7]);
77 int8colvector_ref = int8([1;-4;7]);
78 int8matrix_ref = int8([1 -4 7;-9 6 -3]);
79 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/int8.sod");
80 assert_checkequal(emptyint8matrix, emptyint8matrix_ref);
81 assert_checkequal(int8scalar, int8scalar_ref);
82 assert_checkequal(int8rowvector, int8rowvector_ref);
83 assert_checkequal(int8colvector, int8colvector_ref);
84 assert_checkequal(int8matrix, int8matrix_ref);
85 emptyint16matrix_ref = int16([]);
86 int16scalar_ref = int16(1);
87 int16rowvector_ref = int16([1 -4 7]);
88 int16colvector_ref = int16([1;-4;7]);
89 int16matrix_ref = int16([1 -4 7;-9 6 -3]);
90 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/int16.sod");
91 assert_checkequal(emptyint16matrix, emptyint16matrix_ref);
92 assert_checkequal(int16scalar, int16scalar_ref);
93 assert_checkequal(int16rowvector, int16rowvector_ref);
94 assert_checkequal(int16colvector, int16colvector_ref);
95 assert_checkequal(int16matrix, int16matrix_ref);
96 emptyint32matrix_ref = int32([]);
97 int32scalar_ref = int32(1);
98 int32rowvector_ref = int32([1 -4 7]);
99 int32colvector_ref = int32([1;-4;7]);
100 int32matrix_ref = int32([1 -4 7;-9 6 -3]);
101 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/int32.sod");
102 assert_checkequal(emptyint32matrix, emptyint32matrix_ref);
103 assert_checkequal(int32scalar, int32scalar_ref);
104 assert_checkequal(int32rowvector, int32rowvector_ref);
105 assert_checkequal(int32colvector, int32colvector_ref);
106 assert_checkequal(int32matrix, int32matrix_ref);
107 emptyuint8matrix_ref = uint8([]);
108 uint8scalar_ref = uint8(1);
109 uint8rowvector_ref = uint8([1 4 7]);
110 uint8colvector_ref = uint8([1;4;7]);
111 uint8matrix_ref = uint8([1 4 7;9 6 3]);
112 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/uint8.sod");
113 assert_checkequal(emptyuint8matrix, emptyuint8matrix_ref);
114 assert_checkequal(uint8scalar, uint8scalar_ref);
115 assert_checkequal(uint8rowvector, uint8rowvector_ref);
116 assert_checkequal(uint8colvector, uint8colvector_ref);
117 assert_checkequal(uint8matrix, uint8matrix_ref);
118 emptyuint16matrix_ref = uint16([]);
119 uint16scalar_ref = uint16(1);
120 uint16rowvector_ref = uint16([1 4 7]);
121 uint16colvector_ref = uint16([1;4;7]);
122 uint16matrix_ref = uint16([1 4 7;9 6 3]);
123 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/uint16.sod");
124 assert_checkequal(emptyuint16matrix, emptyuint16matrix_ref);
125 assert_checkequal(uint16scalar, uint16scalar_ref);
126 assert_checkequal(uint16rowvector, uint16rowvector_ref);
127 assert_checkequal(uint16colvector, uint16colvector_ref);
128 assert_checkequal(uint16matrix, uint16matrix_ref);
129 emptyuint32matrix_ref = uint32([]);
130 uint32scalar_ref = uint32(1);
131 uint32rowvector_ref = uint32([1 4 7]);
132 uint32colvector_ref = uint32([1;4;7]);
133 uint32matrix_ref = uint32([1 4 7;9 6 3]);
134 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/uint32.sod");
135 assert_checkequal(emptyuint32matrix, emptyuint32matrix_ref);
136 assert_checkequal(uint32scalar, uint32scalar_ref);
137 assert_checkequal(uint32rowvector, uint32rowvector_ref);
138 assert_checkequal(uint32colvector, uint32colvector_ref);
139 assert_checkequal(uint32matrix, uint32matrix_ref);
140 // undefined
141 undefinedelement_ref=list(2,%i,'f',ones(3,3));
142 undefinedelement_ref(6)="toto";
143 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/undefinedelement.sod");
144 assert_checkequal(undefinedelement, undefinedelement_ref);
145 // void
146 voidelement_ref=list(1,,3);
147 import_from_hdf5(SCI+"/modules/hdf5/tests/sample_scilab_data/voidelement.sod");
148 // Commented because of bug 9529
149 //assert_checkequal(voidelement, voidelement_ref);