11import random
22
3- import numpy as np
43import pytest
54
65import arrayfire_wrapper .dtypes as dtype
76import arrayfire_wrapper .lib as wrapper
87
9- from arrayfire_wrapper .lib .create_and_modify_array .helper_functions import array_to_string
10-
118dtype_map = {
129 "int16" : dtype .s16 ,
1310 "int32" : dtype .s32 ,
@@ -56,7 +53,10 @@ def test_and_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
5653
5754 result = wrapper .and_ (lhs , rhs )
5855
59- assert wrapper .get_dims (result )[0 : len (shape )] == shape , f"failed for shape: { shape } and dtype { dtype_name } " # noqa
56+ assert (
57+ wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
58+ ), f"failed for shape: { shape } and dtype { dtype_name } "
59+
6060
6161@pytest .mark .parametrize (
6262 "invdtypes" ,
@@ -74,7 +74,11 @@ def test_and_shapes_invalid(invdtypes: dtype.Dtype) -> None:
7474
7575 result = wrapper .and_ (lhs , rhs )
7676
77- assert wrapper .get_dims (result )[0 : len (shape )] == shape , f"failed for shape: { shape } and dtype { invdtypes } " # noqa
77+ assert (
78+ wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
79+ ), f"failed for shape: { shape } and dtype { invdtypes } "
80+
81+
7882@pytest .mark .parametrize (
7983 "shape" ,
8084 [
@@ -88,14 +92,23 @@ def test_and_shapes_invalid(invdtypes: dtype.Dtype) -> None:
8892@pytest .mark .parametrize ("dtype_name" , dtype_map .values ())
8993def test_bitand_shape_dtypes (shape : tuple , dtype_name : dtype .Dtype ) -> None :
9094 """Test bitand operation between two arrays of the same shape"""
91- if dtype_name == dtype .c32 or dtype_name == dtype .c64 or dtype_name == dtype .f32 or dtype_name == dtype .f64 or dtype_name == dtype .f16 :
95+ if (
96+ dtype_name == dtype .c32
97+ or dtype_name == dtype .c64
98+ or dtype_name == dtype .f32
99+ or dtype_name == dtype .f64
100+ or dtype_name == dtype .f16
101+ ):
92102 pytest .skip ()
93103 lhs = wrapper .randu (shape , dtype_name )
94104 rhs = wrapper .randu (shape , dtype_name )
95105
96106 result = wrapper .bitand (lhs , rhs )
97107
98- assert wrapper .get_dims (result )[0 : len (shape )] == shape , f"failed for shape: { shape } and dtype { dtype_name } " # noqa
108+ assert (
109+ wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
110+ ), f"failed for shape: { shape } and dtype { dtype_name } "
111+
99112
100113@pytest .mark .parametrize (
101114 "invdtypes" ,
@@ -111,6 +124,8 @@ def test_bitand_shapes_invalid(invdtypes: dtype.Dtype) -> None:
111124 lhs = wrapper .randu (shape , invdtypes )
112125 rhs = wrapper .randu (shape , invdtypes )
113126 wrapper .bitand (lhs , rhs )
127+
128+
114129@pytest .mark .parametrize (
115130 "shape" ,
116131 [
@@ -124,13 +139,22 @@ def test_bitand_shapes_invalid(invdtypes: dtype.Dtype) -> None:
124139@pytest .mark .parametrize ("dtype_name" , dtype_map .values ())
125140def test_bitnot_shape_dtypes (shape : tuple , dtype_name : dtype .Dtype ) -> None :
126141 """Test bitnot operation between two arrays of the same shape"""
127- if dtype_name == dtype .c32 or dtype_name == dtype .c64 or dtype_name == dtype .f32 or dtype_name == dtype .f64 or dtype_name == dtype .f16 :
142+ if (
143+ dtype_name == dtype .c32
144+ or dtype_name == dtype .c64
145+ or dtype_name == dtype .f32
146+ or dtype_name == dtype .f64
147+ or dtype_name == dtype .f16
148+ ):
128149 pytest .skip ()
129150 out = wrapper .randu (shape , dtype_name )
130151
131152 result = wrapper .bitnot (out )
132153
133- assert wrapper .get_dims (result )[0 : len (shape )] == shape , f"failed for shape: { shape } and dtype { dtype_name } " # noqa
154+ assert (
155+ wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
156+ ), f"failed for shape: { shape } and dtype { dtype_name } "
157+
134158
135159@pytest .mark .parametrize (
136160 "invdtypes" ,
@@ -145,6 +169,8 @@ def test_bitnot_shapes_invalid(invdtypes: dtype.Dtype) -> None:
145169 shape = (3 , 3 )
146170 out = wrapper .randu (shape , invdtypes )
147171 wrapper .bitnot (out )
172+
173+
148174@pytest .mark .parametrize (
149175 "shape" ,
150176 [
@@ -158,14 +184,23 @@ def test_bitnot_shapes_invalid(invdtypes: dtype.Dtype) -> None:
158184@pytest .mark .parametrize ("dtype_name" , dtype_map .values ())
159185def test_bitor_shape_dtypes (shape : tuple , dtype_name : dtype .Dtype ) -> None :
160186 """Test bitor operation between two arrays of the same shape"""
161- if dtype_name == dtype .c32 or dtype_name == dtype .c64 or dtype_name == dtype .f32 or dtype_name == dtype .f64 or dtype_name == dtype .f16 :
187+ if (
188+ dtype_name == dtype .c32
189+ or dtype_name == dtype .c64
190+ or dtype_name == dtype .f32
191+ or dtype_name == dtype .f64
192+ or dtype_name == dtype .f16
193+ ):
162194 pytest .skip ()
163195 lhs = wrapper .randu (shape , dtype_name )
164196 rhs = wrapper .randu (shape , dtype_name )
165197
166198 result = wrapper .bitor (lhs , rhs )
167199
168- assert wrapper .get_dims (result )[0 : len (shape )] == shape , f"failed for shape: { shape } and dtype { dtype_name } " # noqa
200+ assert (
201+ wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
202+ ), f"failed for shape: { shape } and dtype { dtype_name } "
203+
169204
170205@pytest .mark .parametrize (
171206 "invdtypes" ,
@@ -182,6 +217,7 @@ def test_bitor_shapes_invalid(invdtypes: dtype.Dtype) -> None:
182217 rhs = wrapper .randu (shape , invdtypes )
183218 wrapper .bitor (lhs , rhs )
184219
220+
185221@pytest .mark .parametrize (
186222 "shape" ,
187223 [
@@ -195,14 +231,23 @@ def test_bitor_shapes_invalid(invdtypes: dtype.Dtype) -> None:
195231@pytest .mark .parametrize ("dtype_name" , dtype_map .values ())
196232def test_bitxor_shape_dtypes (shape : tuple , dtype_name : dtype .Dtype ) -> None :
197233 """Test bitxor operation between two arrays of the same shape"""
198- if dtype_name == dtype .c32 or dtype_name == dtype .c64 or dtype_name == dtype .f32 or dtype_name == dtype .f64 or dtype_name == dtype .f16 :
234+ if (
235+ dtype_name == dtype .c32
236+ or dtype_name == dtype .c64
237+ or dtype_name == dtype .f32
238+ or dtype_name == dtype .f64
239+ or dtype_name == dtype .f16
240+ ):
199241 pytest .skip ()
200242 lhs = wrapper .randu (shape , dtype_name )
201243 rhs = wrapper .randu (shape , dtype_name )
202244
203245 result = wrapper .bitxor (lhs , rhs )
204246
205- assert wrapper .get_dims (result )[0 : len (shape )] == shape , f"failed for shape: { shape } and dtype { dtype_name } " # noqa
247+ assert (
248+ wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
249+ ), f"failed for shape: { shape } and dtype { dtype_name } "
250+
206251
207252@pytest .mark .parametrize (
208253 "invdtypes" ,
@@ -218,6 +263,8 @@ def test_bitxor_shapes_invalid(invdtypes: dtype.Dtype) -> None:
218263 lhs = wrapper .randu (shape , invdtypes )
219264 rhs = wrapper .randu (shape , invdtypes )
220265 wrapper .bitxor (lhs , rhs )
266+
267+
221268@pytest .mark .parametrize (
222269 "shape" ,
223270 [
@@ -231,14 +278,23 @@ def test_bitxor_shapes_invalid(invdtypes: dtype.Dtype) -> None:
231278@pytest .mark .parametrize ("dtype_name" , dtype_map .values ())
232279def test_eq_shape_dtypes (shape : tuple , dtype_name : dtype .Dtype ) -> None :
233280 """Test eq operation between two arrays of the same shape"""
234- if dtype_name == dtype .c32 or dtype_name == dtype .c64 or dtype_name == dtype .f32 or dtype_name == dtype .f64 or dtype_name == dtype .f16 :
281+ if (
282+ dtype_name == dtype .c32
283+ or dtype_name == dtype .c64
284+ or dtype_name == dtype .f32
285+ or dtype_name == dtype .f64
286+ or dtype_name == dtype .f16
287+ ):
235288 pytest .skip ()
236289 lhs = wrapper .randu (shape , dtype_name )
237290 rhs = wrapper .randu (shape , dtype_name )
238291
239292 result = wrapper .eq (lhs , rhs )
240293
241- assert wrapper .get_dims (result )[0 : len (shape )] == shape , f"failed for shape: { shape } and dtype { dtype_name } " # noqa
294+ assert (
295+ wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
296+ ), f"failed for shape: { shape } and dtype { dtype_name } "
297+
242298
243299@pytest .mark .parametrize (
244300 "invdtypes" ,
@@ -254,6 +310,8 @@ def test_eq_shapes_invalid(invdtypes: dtype.Dtype) -> None:
254310 lhs = wrapper .randu (shape , invdtypes )
255311 rhs = wrapper .randu (shape , invdtypes )
256312 wrapper .eq (lhs , rhs )
313+
314+
257315@pytest .mark .parametrize (
258316 "shape" ,
259317 [
@@ -272,7 +330,10 @@ def test_ge_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
272330
273331 result = wrapper .ge (lhs , rhs )
274332
275- assert wrapper .get_dims (result )[0 : len (shape )] == shape , f"failed for shape: { shape } and dtype { dtype_name } " # noqa
333+ assert (
334+ wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
335+ ), f"failed for shape: { shape } and dtype { dtype_name } "
336+
276337
277338@pytest .mark .parametrize (
278339 "invdtypes" ,
@@ -289,6 +350,7 @@ def test_ge_shapes_invalid(invdtypes: dtype.Dtype) -> None:
289350 rhs = wrapper .randu (shape , invdtypes )
290351 wrapper .ge (lhs , rhs )
291352
353+
292354@pytest .mark .parametrize (
293355 "shape" ,
294356 [
@@ -307,7 +369,10 @@ def test_gt_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
307369
308370 result = wrapper .gt (lhs , rhs )
309371
310- assert wrapper .get_dims (result )[0 : len (shape )] == shape , f"failed for shape: { shape } and dtype { dtype_name } " # noqa
372+ assert (
373+ wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
374+ ), f"failed for shape: { shape } and dtype { dtype_name } "
375+
311376
312377@pytest .mark .parametrize (
313378 "invdtypes" ,
@@ -324,6 +389,7 @@ def test_gt_shapes_invalid(invdtypes: dtype.Dtype) -> None:
324389 rhs = wrapper .randu (shape , invdtypes )
325390 wrapper .gt (lhs , rhs )
326391
392+
327393@pytest .mark .parametrize (
328394 "shape" ,
329395 [
@@ -342,7 +408,10 @@ def test_le_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
342408
343409 result = wrapper .le (lhs , rhs )
344410
345- assert wrapper .get_dims (result )[0 : len (shape )] == shape , f"failed for shape: { shape } and dtype { dtype_name } " # noqa
411+ assert (
412+ wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
413+ ), f"failed for shape: { shape } and dtype { dtype_name } "
414+
346415
347416@pytest .mark .parametrize (
348417 "invdtypes" ,
@@ -358,6 +427,8 @@ def test_le_shapes_invalid(invdtypes: dtype.Dtype) -> None:
358427 lhs = wrapper .randu (shape , invdtypes )
359428 rhs = wrapper .randu (shape , invdtypes )
360429 wrapper .le (lhs , rhs )
430+
431+
361432@pytest .mark .parametrize (
362433 "shape" ,
363434 [
@@ -376,7 +447,10 @@ def test_lt_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
376447
377448 result = wrapper .lt (lhs , rhs )
378449
379- assert wrapper .get_dims (result )[0 : len (shape )] == shape , f"failed for shape: { shape } and dtype { dtype_name } " # noqa
450+ assert (
451+ wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
452+ ), f"failed for shape: { shape } and dtype { dtype_name } "
453+
380454
381455@pytest .mark .parametrize (
382456 "invdtypes" ,
@@ -392,6 +466,8 @@ def test_lt_shapes_invalid(invdtypes: dtype.Dtype) -> None:
392466 lhs = wrapper .randu (shape , invdtypes )
393467 rhs = wrapper .randu (shape , invdtypes )
394468 wrapper .lt (lhs , rhs )
469+
470+
395471@pytest .mark .parametrize (
396472 "shape" ,
397473 [
@@ -410,7 +486,10 @@ def test_neq_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
410486
411487 result = wrapper .neq (lhs , rhs )
412488
413- assert wrapper .get_dims (result )[0 : len (shape )] == shape , f"failed for shape: { shape } and dtype { dtype_name } " # noqa
489+ assert (
490+ wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
491+ ), f"failed for shape: { shape } and dtype { dtype_name } "
492+
414493
415494@pytest .mark .parametrize (
416495 "invdtypes" ,
@@ -426,6 +505,8 @@ def test_neq_shapes_invalid(invdtypes: dtype.Dtype) -> None:
426505 lhs = wrapper .randu (shape , invdtypes )
427506 rhs = wrapper .randu (shape , invdtypes )
428507 wrapper .neq (lhs , rhs )
508+
509+
429510@pytest .mark .parametrize (
430511 "shape" ,
431512 [
@@ -439,13 +520,22 @@ def test_neq_shapes_invalid(invdtypes: dtype.Dtype) -> None:
439520@pytest .mark .parametrize ("dtype_name" , dtype_map .values ())
440521def test_not_shape_dtypes (shape : tuple , dtype_name : dtype .Dtype ) -> None :
441522 """Test not operation between two arrays of the same shape"""
442- if dtype_name == dtype .c32 or dtype_name == dtype .c64 or dtype_name == dtype .f32 or dtype_name == dtype .f64 or dtype_name == dtype .f16 :
523+ if (
524+ dtype_name == dtype .c32
525+ or dtype_name == dtype .c64
526+ or dtype_name == dtype .f32
527+ or dtype_name == dtype .f64
528+ or dtype_name == dtype .f16
529+ ):
443530 pytest .skip ()
444531 out = wrapper .randu (shape , dtype_name )
445532
446533 result = wrapper .not_ (out )
447534
448- assert wrapper .get_dims (result )[0 : len (shape )] == shape , f"failed for shape: { shape } and dtype { dtype_name } " # noqa
535+ assert (
536+ wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
537+ ), f"failed for shape: { shape } and dtype { dtype_name } "
538+
449539
450540@pytest .mark .parametrize (
451541 "invdtypes" ,
@@ -460,6 +550,8 @@ def test_not_shapes_invalid(invdtypes: dtype.Dtype) -> None:
460550 shape = (3 , 3 )
461551 out = wrapper .randu (shape , invdtypes )
462552 wrapper .not_ (out )
553+
554+
463555@pytest .mark .parametrize (
464556 "shape" ,
465557 [
@@ -478,7 +570,10 @@ def test_or_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
478570
479571 result = wrapper .or_ (lhs , rhs )
480572
481- assert wrapper .get_dims (result )[0 : len (shape )] == shape , f"failed for shape: { shape } and dtype { dtype_name } " # noqa
573+ assert (
574+ wrapper .get_dims (result )[0 : len (shape )] == shape # noqa
575+ ), f"failed for shape: { shape } and dtype { dtype_name } "
576+
482577
483578@pytest .mark .parametrize (
484579 "invdtypes" ,
@@ -493,4 +588,4 @@ def test_or_shapes_invalid(invdtypes: dtype.Dtype) -> None:
493588 shape = (3 , 3 )
494589 lhs = wrapper .randu (shape , invdtypes )
495590 rhs = wrapper .randu (shape , invdtypes )
496- wrapper .or_ (lhs , rhs )
591+ wrapper .or_ (lhs , rhs )
0 commit comments