-
Notifications
You must be signed in to change notification settings - Fork 0
/
neo.Test.pas
234 lines (189 loc) · 8.65 KB
/
neo.Test.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
uses neo;
uses patest;
type
TestArithmeticOperators = class(patest.TestCase)
public
procedure test_add_0;
begin
var ndarray_0_shape: array of integer := (1, 1, 1, 1, 1, 1, 1, 1, 1, 32);
var ndarray_0 := neo.arange(32).reshape(ndarray_0_shape);
var ndarray_1_shape: array of integer := (1, 1, 1, 1, 1, 1, 1, 1, 1, 32);
var ndarray_1 := neo.arange(32).reshape(ndarray_1_shape);
var res := ndarray_0 + ndarray_1;
var f := System.IO.File.Open('./neo.Test/test_add_0.neo', System.IO.FileMode.Open);
var true_res := neo.ndarray.load(new System.IO.BinaryReader(f));
f.Close();
self.assertEqual(res, true_res);
end;
procedure test_add_1;
begin
var ndarray_0_shape: array of integer := (32);
var ndarray_0 := neo.arange(32).reshape(ndarray_0_shape);
var ndarray_1_shape: array of integer := (32);
var ndarray_1 := neo.arange(32).reshape(ndarray_1_shape);
var res := ndarray_0 + ndarray_1;
var f := System.IO.File.Open('./neo.Test/test_add_1.neo', System.IO.FileMode.Open);
var true_res := neo.ndarray.load(new System.IO.BinaryReader(f));
f.Close;
self.assertEqual(res, true_res);
end;
procedure test_add_2;
begin
var ndarray_0_shape: array of integer := (32, 32);
var ndarray_0 := neo.arange(1024).reshape(ndarray_0_shape);
var ndarray_1_shape: array of integer := (32, 32);
var ndarray_1 := neo.arange(1024).reshape(ndarray_1_shape);
var res := ndarray_0 + ndarray_1;
var f := System.IO.File.Open('./neo.Test/test_add_2.neo', System.IO.FileMode.Open);
var true_res := neo.ndarray.load(new System.IO.BinaryReader(f));
f.Close;
self.assertEqual(res, true_res);
end;
procedure _test_add_3_helper;
begin
var ndarray_0_shape: array of integer := (8, 4);
var ndarray_0 := neo.arange(32).reshape(ndarray_0_shape);
var ndarray_1_shape: array of integer := (8);
var ndarray_1 := neo.arange(8).reshape(ndarray_1_shape);
var r := ndarray_0 + ndarray_1;
end;
procedure test_add_3;
begin
self.assertRaises&<System.ArithmeticException>(_test_add_3_helper);
end;
procedure test_add_4;
begin
var ndarray_0_shape: array of integer := (8, 4, 2);
var ndarray_0 := neo.arange(64).reshape(ndarray_0_shape);
var ndarray_1_shape: array of integer := (4, 2);
var ndarray_1 := neo.arange(64).reshape(ndarray_1_shape);
var res := ndarray_0 + ndarray_1;
var f := System.IO.File.Open('./neo.Test/test_add_4.neo', System.IO.FileMode.Open);
var true_res := neo.ndarray.load(new System.IO.BinaryReader(f));
f.Close;
self.assertEqual(res, true_res);
end;
procedure test_sub_0;
begin
var ndarray_0_shape: array of integer := (1, 1, 1, 1, 1, 1, 1, 1, 1, 32);
var ndarray_0 := neo.arange(32).reshape(ndarray_0_shape);
var ndarray_1_shape: array of integer := (1, 1, 1, 1, 1, 1, 1, 1, 1, 32);
var ndarray_1 := neo.arange(32).reshape(ndarray_1_shape);
var res := ndarray_0 - ndarray_1;
var f := System.IO.File.Open('./neo.Test/test_sub_0.neo', System.IO.FileMode.Open);
var true_res := neo.ndarray.load(new System.IO.BinaryReader(f));
f.Close;
self.assertEqual(res, true_res);
end;
procedure test_sub_1;
begin
var ndarray_0_shape: array of integer := (32);
var ndarray_0 := neo.arange(32).reshape(ndarray_0_shape);
var ndarray_1_shape: array of integer := (32);
var ndarray_1 := neo.arange(32).reshape(ndarray_1_shape);
var res := ndarray_0 - ndarray_1;
var f := System.IO.File.Open('./neo.Test/test_sub_1.neo', System.IO.FileMode.Open);
var true_res := neo.ndarray.load(new System.IO.BinaryReader(f));
f.Close;
self.assertEqual(res, true_res);
end;
procedure test_sub_2;
begin
var ndarray_0_shape: array of integer := (32, 32);
var ndarray_0 := neo.arange(1024).reshape(ndarray_0_shape);
var ndarray_1_shape: array of integer := (32, 32);
var ndarray_1 := neo.arange(1024).reshape(ndarray_1_shape);
var res := ndarray_0 - ndarray_1;
var f := System.IO.File.Open('./neo.Test/test_sub_2.neo', System.IO.FileMode.Open);
var true_res := neo.ndarray.load(new System.IO.BinaryReader(f));
f.Close;
self.assertEqual(res, true_res);
end;
procedure _test_sub_3_helper;
begin
var ndarray_0_shape: array of integer := (8, 4);
var ndarray_0 := neo.arange(32).reshape(ndarray_0_shape);
var ndarray_1_shape: array of integer := (8);
var ndarray_1 := neo.arange(8).reshape(ndarray_1_shape);
var r := ndarray_0 - ndarray_1;
end;
procedure test_sub_3;
begin
self.assertRaises&<System.ArithmeticException>(_test_sub_3_helper);
end;
procedure test_sub_4;
begin
var ndarray_0_shape: array of integer := (8, 4, 2);
var ndarray_0 := neo.arange(64).reshape(ndarray_0_shape);
var ndarray_1_shape: array of integer := (4, 2);
var ndarray_1 := neo.arange(64).reshape(ndarray_1_shape);
var res := ndarray_0 - ndarray_1;
var f := System.IO.File.Open('./neo.Test/test_sub_4.neo', System.IO.FileMode.Open);
var true_res := neo.ndarray.load(new System.IO.BinaryReader(f));
f.Close;
self.assertEqual(res, true_res);
end;
procedure test_mul_0;
begin
var ndarray_0_shape: array of integer := (1, 1, 1, 1, 1, 1, 1, 1, 1, 32);
var ndarray_0 := neo.arange(32).reshape(ndarray_0_shape);
var ndarray_1_shape: array of integer := (1, 1, 1, 1, 1, 1, 1, 1, 1, 32);
var ndarray_1 := neo.arange(32).reshape(ndarray_1_shape);
var res := ndarray_0 * ndarray_1;
var f := System.IO.File.Open('./neo.Test/test_mul_0.neo', System.IO.FileMode.Open);
var true_res := neo.ndarray.load(new System.IO.BinaryReader(f));
f.Close;
self.assertEqual(res, true_res);
end;
procedure test_mul_1;
begin
var ndarray_0_shape: array of integer := (32);
var ndarray_0 := neo.arange(32).reshape(ndarray_0_shape);
var ndarray_1_shape: array of integer := (32);
var ndarray_1 := neo.arange(32).reshape(ndarray_1_shape);
var res := ndarray_0 * ndarray_1;
var f := System.IO.File.Open('./neo.Test/test_mul_1.neo', System.IO.FileMode.Open);
var true_res := neo.ndarray.load(new System.IO.BinaryReader(f));
f.Close;
self.assertEqual(res, true_res);
end;
procedure test_mul_2;
begin
var ndarray_0_shape: array of integer := (32, 32);
var ndarray_0 := neo.arange(1024).reshape(ndarray_0_shape);
var ndarray_1_shape: array of integer := (32, 32);
var ndarray_1 := neo.arange(1024).reshape(ndarray_1_shape);
var res := ndarray_0 * ndarray_1;
var f := System.IO.File.Open('./neo.Test/test_mul_2.neo', System.IO.FileMode.Open);
var true_res := neo.ndarray.load(new System.IO.BinaryReader(f));
f.Close;
self.assertEqual(res, true_res);
end;
procedure _test_mul_3_helper;
begin
var ndarray_0_shape: array of integer := (8, 4);
var ndarray_0 := neo.arange(32).reshape(ndarray_0_shape);
var ndarray_1_shape: array of integer := (8);
var ndarray_1 := neo.arange(8).reshape(ndarray_1_shape);
var r := ndarray_0 * ndarray_1;
end;
procedure test_mul_3;
begin
self.assertRaises&<System.ArithmeticException>(_test_mul_3_helper);
end;
procedure test_mul_4;
begin
var ndarray_0_shape: array of integer := (8, 4, 2);
var ndarray_0 := neo.arange(64).reshape(ndarray_0_shape);
var ndarray_1_shape: array of integer := (4, 2);
var ndarray_1 := neo.arange(64).reshape(ndarray_1_shape);
var res := ndarray_0 * ndarray_1;
var f := System.IO.File.Open('./neo.Test/test_mul_4.neo', System.IO.FileMode.Open);
var true_res := neo.ndarray.load(new System.IO.BinaryReader(f));
f.Close;
self.assertEqual(res, true_res);
end;
end;
begin
patest.main();
end.