11import random
22
3- import pytest
43import numpy as np
4+ import pytest
55
66import arrayfire_wrapper .dtypes as dtype
77import arrayfire_wrapper .lib as wrapper
88
99from . import utility_functions as util
1010
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 } "
3111
3212@pytest .mark .parametrize (
3313 "shape" ,
@@ -94,6 +74,7 @@ def test_ceil_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
9474 wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
9575 ), f"failed for shape: { shape } and dtype { dtype_name } "
9676
77+
9778@pytest .mark .parametrize (
9879 "invdtypes" ,
9980 [
@@ -111,6 +92,8 @@ def test_ceil_shapes_invalid(invdtypes: dtype.Dtype) -> None:
11192 assert (
11293 wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
11394 ), f"failed for shape: { shape } and dtype { invdtypes } "
95+
96+
11497@pytest .mark .parametrize (
11598 "shape" ,
11699 [
@@ -133,6 +116,8 @@ def test_maxof_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
133116 assert (
134117 wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
135118 ), f"failed for shape: { shape } and dtype { dtype_name } "
119+
120+
136121@pytest .mark .parametrize (
137122 "shape_a, shape_b" ,
138123 [
@@ -154,6 +139,7 @@ def test_maxof_varying_dimensionality(shape_a: tuple, shape_b: tuple) -> None:
154139 wrapper .get_dims (result )[0 : len (expected_shape )] == expected_shape # noqa
155140 ), f"Failed for shapes { shape_a } and { shape_b } "
156141
142+
157143@pytest .mark .parametrize (
158144 "shape" ,
159145 [
@@ -176,6 +162,8 @@ def test_minof_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
176162 assert (
177163 wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
178164 ), f"failed for shape: { shape } and dtype { dtype_name } "
165+
166+
179167@pytest .mark .parametrize (
180168 "shape_a, shape_b" ,
181169 [
@@ -197,6 +185,7 @@ def test_minof_varying_dimensionality(shape_a: tuple, shape_b: tuple) -> None:
197185 wrapper .get_dims (result )[0 : len (expected_shape )] == expected_shape # noqa
198186 ), f"Failed for shapes { shape_a } and { shape_b } "
199187
188+
200189@pytest .mark .parametrize (
201190 "shape" ,
202191 [
@@ -220,6 +209,7 @@ def test_mod_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
220209 wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
221210 ), f"failed for shape: { shape } and dtype { dtype_name } "
222211
212+
223213@pytest .mark .parametrize ("invdtypes" , util .get_complex_types ())
224214def test_mod_shapes_invalid (invdtypes : dtype .Dtype ) -> None :
225215 """Test mod operation between two arrays of the same shape"""
@@ -234,6 +224,7 @@ def test_mod_shapes_invalid(invdtypes: dtype.Dtype) -> None:
234224 wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
235225 ), f"failed for shape: { shape } and dtype { invdtypes } "
236226
227+
237228@pytest .mark .parametrize (
238229 "shape" ,
239230 [
@@ -255,6 +246,7 @@ def test_neg_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
255246 wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
256247 ), f"failed for shape: { shape } and dtype { dtype_name } "
257248
249+
258250@pytest .mark .parametrize (
259251 "shape" ,
260252 [
@@ -277,7 +269,8 @@ def test_rem_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
277269 assert (
278270 wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
279271 ), f"failed for shape: { shape } and dtype { dtype_name } "
280-
272+
273+
281274@pytest .mark .parametrize (
282275 "shape" ,
283276 [
@@ -298,7 +291,8 @@ def test_round_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
298291 assert (
299292 wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
300293 ), f"failed for shape: { shape } and dtype { dtype_name } "
301-
294+
295+
302296@pytest .mark .parametrize ("invdtypes" , util .get_complex_types ())
303297def test_round_shapes_invalid (invdtypes : dtype .Dtype ) -> None :
304298 """Test round operation between two arrays of the same shape"""
@@ -310,6 +304,8 @@ def test_round_shapes_invalid(invdtypes: dtype.Dtype) -> None:
310304 assert (
311305 wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
312306 ), f"failed for shape: { shape } and dtype { invdtypes } "
307+
308+
313309@pytest .mark .parametrize (
314310 "shape" ,
315311 [
@@ -331,6 +327,7 @@ def test_sign_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
331327 wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
332328 ), f"failed for shape: { shape } and dtype { dtype_name } "
333329
330+
334331@pytest .mark .parametrize ("invdtypes" , util .get_complex_types ())
335332def test_sign_shapes_invalid (invdtypes : dtype .Dtype ) -> None :
336333 """Test sign operation between two arrays of the same shape"""
@@ -343,6 +340,7 @@ def test_sign_shapes_invalid(invdtypes: dtype.Dtype) -> None:
343340 wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
344341 ), f"failed for shape: { shape } and dtype { invdtypes } "
345342
343+
346344@pytest .mark .parametrize (
347345 "shape" ,
348346 [
@@ -364,6 +362,7 @@ def test_trunc_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
364362 wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
365363 ), f"failed for shape: { shape } and dtype { dtype_name } "
366364
365+
367366@pytest .mark .parametrize ("invdtypes" , util .get_complex_types ())
368367def test_trunc_shapes_invalid (invdtypes : dtype .Dtype ) -> None :
369368 """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:
375374 assert (
376375 wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
377376 ), f"failed for shape: { shape } and dtype { invdtypes } "
377+
378+
378379@pytest .mark .parametrize (
379380 "shape" ,
380381 [
@@ -395,6 +396,8 @@ def test_hypot_shape_dtypes(shape: tuple) -> None:
395396 assert (
396397 wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
397398 ), f"failed for shape: { shape } and dtype { dtype .f32 } "
399+
400+
398401@pytest .mark .parametrize (
399402 "invdtypes" ,
400403 [
@@ -409,6 +412,8 @@ def test_hypot_unsupported_dtypes(invdtypes: dtype.Dtype) -> None:
409412 lhs = wrapper .randu (shape , invdtypes )
410413 rhs = wrapper .randu (shape , invdtypes )
411414 wrapper .hypot (rhs , lhs , True )
415+
416+
412417@pytest .mark .parametrize (
413418 "shape" ,
414419 [
0 commit comments