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