1
1
import random
2
2
3
- import pytest
4
3
import numpy as np
4
+ import pytest
5
5
6
6
import arrayfire_wrapper .dtypes as dtype
7
7
import arrayfire_wrapper .lib as wrapper
8
8
9
9
from . import utility_functions as util
10
10
11
- @pytest .mark .parametrize (
12
- "shape" ,
13
- [
14
- (),
15
- (random .randint (1 , 10 ),),
16
- (random .randint (1 , 10 ), random .randint (1 , 10 )),
17
- (random .randint (1 , 10 ), random .randint (1 , 10 ), random .randint (1 , 10 )),
18
- (random .randint (1 , 10 ), random .randint (1 , 10 ), random .randint (1 , 10 ), random .randint (1 , 10 )),
19
- ],
20
- )
21
- @pytest .mark .parametrize ("dtype_name" , util .get_all_types ())
22
- def test_abs_shape_dtypes (shape : tuple , dtype_name : dtype .Dtype ) -> None :
23
- """Test absolute value operation between two arrays of the same shape"""
24
- util .check_type_supported (dtype_name )
25
- out = wrapper .randu (shape , dtype_name )
26
-
27
- result = wrapper .abs_ (out )
28
- assert (
29
- wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
30
- ), f"failed for shape: { shape } and dtype { dtype_name } "
31
11
32
12
@pytest .mark .parametrize (
33
13
"shape" ,
@@ -94,6 +74,7 @@ def test_ceil_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
94
74
wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
95
75
), f"failed for shape: { shape } and dtype { dtype_name } "
96
76
77
+
97
78
@pytest .mark .parametrize (
98
79
"invdtypes" ,
99
80
[
@@ -111,6 +92,8 @@ def test_ceil_shapes_invalid(invdtypes: dtype.Dtype) -> None:
111
92
assert (
112
93
wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
113
94
), f"failed for shape: { shape } and dtype { invdtypes } "
95
+
96
+
114
97
@pytest .mark .parametrize (
115
98
"shape" ,
116
99
[
@@ -133,6 +116,8 @@ def test_maxof_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
133
116
assert (
134
117
wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
135
118
), f"failed for shape: { shape } and dtype { dtype_name } "
119
+
120
+
136
121
@pytest .mark .parametrize (
137
122
"shape_a, shape_b" ,
138
123
[
@@ -154,6 +139,7 @@ def test_maxof_varying_dimensionality(shape_a: tuple, shape_b: tuple) -> None:
154
139
wrapper .get_dims (result )[0 : len (expected_shape )] == expected_shape # noqa
155
140
), f"Failed for shapes { shape_a } and { shape_b } "
156
141
142
+
157
143
@pytest .mark .parametrize (
158
144
"shape" ,
159
145
[
@@ -176,6 +162,8 @@ def test_minof_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
176
162
assert (
177
163
wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
178
164
), f"failed for shape: { shape } and dtype { dtype_name } "
165
+
166
+
179
167
@pytest .mark .parametrize (
180
168
"shape_a, shape_b" ,
181
169
[
@@ -197,6 +185,7 @@ def test_minof_varying_dimensionality(shape_a: tuple, shape_b: tuple) -> None:
197
185
wrapper .get_dims (result )[0 : len (expected_shape )] == expected_shape # noqa
198
186
), f"Failed for shapes { shape_a } and { shape_b } "
199
187
188
+
200
189
@pytest .mark .parametrize (
201
190
"shape" ,
202
191
[
@@ -220,6 +209,7 @@ def test_mod_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
220
209
wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
221
210
), f"failed for shape: { shape } and dtype { dtype_name } "
222
211
212
+
223
213
@pytest .mark .parametrize ("invdtypes" , util .get_complex_types ())
224
214
def test_mod_shapes_invalid (invdtypes : dtype .Dtype ) -> None :
225
215
"""Test mod operation between two arrays of the same shape"""
@@ -234,6 +224,7 @@ def test_mod_shapes_invalid(invdtypes: dtype.Dtype) -> None:
234
224
wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
235
225
), f"failed for shape: { shape } and dtype { invdtypes } "
236
226
227
+
237
228
@pytest .mark .parametrize (
238
229
"shape" ,
239
230
[
@@ -255,6 +246,7 @@ def test_neg_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
255
246
wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
256
247
), f"failed for shape: { shape } and dtype { dtype_name } "
257
248
249
+
258
250
@pytest .mark .parametrize (
259
251
"shape" ,
260
252
[
@@ -277,7 +269,8 @@ def test_rem_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
277
269
assert (
278
270
wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
279
271
), f"failed for shape: { shape } and dtype { dtype_name } "
280
-
272
+
273
+
281
274
@pytest .mark .parametrize (
282
275
"shape" ,
283
276
[
@@ -298,7 +291,8 @@ def test_round_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
298
291
assert (
299
292
wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
300
293
), f"failed for shape: { shape } and dtype { dtype_name } "
301
-
294
+
295
+
302
296
@pytest .mark .parametrize ("invdtypes" , util .get_complex_types ())
303
297
def test_round_shapes_invalid (invdtypes : dtype .Dtype ) -> None :
304
298
"""Test round operation between two arrays of the same shape"""
@@ -310,6 +304,8 @@ def test_round_shapes_invalid(invdtypes: dtype.Dtype) -> None:
310
304
assert (
311
305
wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
312
306
), f"failed for shape: { shape } and dtype { invdtypes } "
307
+
308
+
313
309
@pytest .mark .parametrize (
314
310
"shape" ,
315
311
[
@@ -331,6 +327,7 @@ def test_sign_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
331
327
wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
332
328
), f"failed for shape: { shape } and dtype { dtype_name } "
333
329
330
+
334
331
@pytest .mark .parametrize ("invdtypes" , util .get_complex_types ())
335
332
def test_sign_shapes_invalid (invdtypes : dtype .Dtype ) -> None :
336
333
"""Test sign operation between two arrays of the same shape"""
@@ -343,6 +340,7 @@ def test_sign_shapes_invalid(invdtypes: dtype.Dtype) -> None:
343
340
wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
344
341
), f"failed for shape: { shape } and dtype { invdtypes } "
345
342
343
+
346
344
@pytest .mark .parametrize (
347
345
"shape" ,
348
346
[
@@ -364,6 +362,7 @@ def test_trunc_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
364
362
wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
365
363
), f"failed for shape: { shape } and dtype { dtype_name } "
366
364
365
+
367
366
@pytest .mark .parametrize ("invdtypes" , util .get_complex_types ())
368
367
def test_trunc_shapes_invalid (invdtypes : dtype .Dtype ) -> None :
369
368
"""Test trunc operation for an array with varrying shape and invalid dtypes"""
@@ -375,6 +374,8 @@ def test_trunc_shapes_invalid(invdtypes: dtype.Dtype) -> None:
375
374
assert (
376
375
wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
377
376
), f"failed for shape: { shape } and dtype { invdtypes } "
377
+
378
+
378
379
@pytest .mark .parametrize (
379
380
"shape" ,
380
381
[
@@ -395,6 +396,8 @@ def test_hypot_shape_dtypes(shape: tuple) -> None:
395
396
assert (
396
397
wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
397
398
), f"failed for shape: { shape } and dtype { dtype .f32 } "
399
+
400
+
398
401
@pytest .mark .parametrize (
399
402
"invdtypes" ,
400
403
[
@@ -409,6 +412,8 @@ def test_hypot_unsupported_dtypes(invdtypes: dtype.Dtype) -> None:
409
412
lhs = wrapper .randu (shape , invdtypes )
410
413
rhs = wrapper .randu (shape , invdtypes )
411
414
wrapper .hypot (rhs , lhs , True )
415
+
416
+
412
417
@pytest .mark .parametrize (
413
418
"shape" ,
414
419
[
0 commit comments