Skip to content

Commit 56ffc28

Browse files
AzeezIshsyurkevi
AzeezIsh
authored andcommitted
Adhered to checkstyle and modified import.
1 parent 55e9d2e commit 56ffc28

File tree

1 file changed

+29
-31
lines changed

1 file changed

+29
-31
lines changed

tests/test_numeric.py

+29-31
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
import arrayfire_wrapper.dtypes as dtype
77
import arrayfire_wrapper.lib as wrapper
8-
9-
from . import utility_functions as util
8+
from tests.utility_functions import check_type_supported, get_all_types, get_real_types, get_complex_types
109

1110

1211
@pytest.mark.parametrize(
@@ -19,10 +18,10 @@
1918
(random.randint(1, 10), random.randint(1, 10), random.randint(1, 10), random.randint(1, 10)),
2019
],
2120
)
22-
@pytest.mark.parametrize("dtype_name", util.get_all_types())
21+
@pytest.mark.parametrize("dtype_name", get_all_types())
2322
def test_abs_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
2423
"""Test absolute value operation between two arrays of the same shape"""
25-
util.check_type_supported(dtype_name)
24+
check_type_supported(dtype_name)
2625
out = wrapper.randu(shape, dtype_name)
2726

2827
result = wrapper.abs_(out)
@@ -41,10 +40,10 @@ def test_abs_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
4140
(random.randint(1, 10), random.randint(1, 10), random.randint(1, 10), random.randint(1, 10)),
4241
],
4342
)
44-
@pytest.mark.parametrize("dtype_name", util.get_all_types())
43+
@pytest.mark.parametrize("dtype_name", get_all_types())
4544
def test_arg_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
4645
"""Test arg operation between two arrays of the same shape"""
47-
util.check_type_supported(dtype_name)
46+
check_type_supported(dtype_name)
4847
out = wrapper.randu(shape, dtype_name)
4948

5049
result = wrapper.arg(out)
@@ -63,10 +62,10 @@ def test_arg_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
6362
(random.randint(1, 10), random.randint(1, 10), random.randint(1, 10), random.randint(1, 10)),
6463
],
6564
)
66-
@pytest.mark.parametrize("dtype_name", util.get_real_types())
65+
@pytest.mark.parametrize("dtype_name", get_real_types())
6766
def test_ceil_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
6867
"""Test ceil operation between two arrays of the same shape"""
69-
util.check_type_supported(dtype_name)
68+
check_type_supported(dtype_name)
7069
out = wrapper.randu(shape, dtype_name)
7170

7271
result = wrapper.ceil(out)
@@ -104,10 +103,10 @@ def test_ceil_shapes_invalid(invdtypes: dtype.Dtype) -> None:
104103
(random.randint(1, 10), random.randint(1, 10), random.randint(1, 10), random.randint(1, 10)),
105104
],
106105
)
107-
@pytest.mark.parametrize("dtype_name", util.get_all_types())
106+
@pytest.mark.parametrize("dtype_name", get_all_types())
108107
def test_maxof_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
109108
"""Test maxof operation between two arrays of the same shape"""
110-
util.check_type_supported(dtype_name)
109+
check_type_supported(dtype_name)
111110
lhs = wrapper.randu(shape, dtype_name)
112111
rhs = wrapper.randu(shape, dtype_name)
113112

@@ -150,10 +149,10 @@ def test_maxof_varying_dimensionality(shape_a: tuple, shape_b: tuple) -> None:
150149
(random.randint(1, 10), random.randint(1, 10), random.randint(1, 10), random.randint(1, 10)),
151150
],
152151
)
153-
@pytest.mark.parametrize("dtype_name", util.get_all_types())
152+
@pytest.mark.parametrize("dtype_name", get_all_types())
154153
def test_minof_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
155154
"""Test minof operation between two arrays of the same shape"""
156-
util.check_type_supported(dtype_name)
155+
check_type_supported(dtype_name)
157156
lhs = wrapper.randu(shape, dtype_name)
158157
rhs = wrapper.randu(shape, dtype_name)
159158

@@ -196,10 +195,10 @@ def test_minof_varying_dimensionality(shape_a: tuple, shape_b: tuple) -> None:
196195
(random.randint(1, 10), random.randint(1, 10), random.randint(1, 10), random.randint(1, 10)),
197196
],
198197
)
199-
@pytest.mark.parametrize("dtype_name", util.get_real_types())
198+
@pytest.mark.parametrize("dtype_name", get_real_types())
200199
def test_mod_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
201200
"""Test mod operation between two arrays of the same shape"""
202-
util.check_type_supported(dtype_name)
201+
check_type_supported(dtype_name)
203202
lhs = wrapper.randu(shape, dtype_name)
204203
rhs = wrapper.randu(shape, dtype_name)
205204

@@ -210,7 +209,7 @@ def test_mod_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
210209
), f"failed for shape: {shape} and dtype {dtype_name}"
211210

212211

213-
@pytest.mark.parametrize("invdtypes", util.get_complex_types())
212+
@pytest.mark.parametrize("invdtypes", get_complex_types())
214213
def test_mod_shapes_invalid(invdtypes: dtype.Dtype) -> None:
215214
"""Test mod operation between two arrays of the same shape"""
216215
with pytest.raises(RuntimeError):
@@ -235,10 +234,10 @@ def test_mod_shapes_invalid(invdtypes: dtype.Dtype) -> None:
235234
(random.randint(1, 10), random.randint(1, 10), random.randint(1, 10), random.randint(1, 10)),
236235
],
237236
)
238-
@pytest.mark.parametrize("dtype_name", util.get_all_types())
237+
@pytest.mark.parametrize("dtype_name", get_all_types())
239238
def test_neg_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
240239
"""Test arg operation between two arrays of the same shape"""
241-
util.check_type_supported(dtype_name)
240+
check_type_supported(dtype_name)
242241
out = wrapper.randu(shape, dtype_name)
243242

244243
result = wrapper.neg(out)
@@ -257,10 +256,10 @@ def test_neg_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
257256
(random.randint(1, 10), random.randint(1, 10), random.randint(1, 10), random.randint(1, 10)),
258257
],
259258
)
260-
@pytest.mark.parametrize("dtype_name", util.get_real_types())
259+
@pytest.mark.parametrize("dtype_name", get_real_types())
261260
def test_rem_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
262261
"""Test remainder operation between two arrays of the same shape"""
263-
util.check_type_supported(dtype_name)
262+
check_type_supported(dtype_name)
264263
lhs = wrapper.randu(shape, dtype_name)
265264
rhs = wrapper.randu(shape, dtype_name)
266265

@@ -281,10 +280,10 @@ def test_rem_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
281280
(random.randint(1, 10), random.randint(1, 10), random.randint(1, 10), random.randint(1, 10)),
282281
],
283282
)
284-
@pytest.mark.parametrize("dtype_name", util.get_real_types())
283+
@pytest.mark.parametrize("dtype_name", get_real_types())
285284
def test_round_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
286285
"""Test round operation between two arrays of the same shape"""
287-
util.check_type_supported(dtype_name)
286+
check_type_supported(dtype_name)
288287
out = wrapper.randu(shape, dtype_name)
289288

290289
result = wrapper.round_(out)
@@ -293,7 +292,7 @@ def test_round_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
293292
), f"failed for shape: {shape} and dtype {dtype_name}"
294293

295294

296-
@pytest.mark.parametrize("invdtypes", util.get_complex_types())
295+
@pytest.mark.parametrize("invdtypes", get_complex_types())
297296
def test_round_shapes_invalid(invdtypes: dtype.Dtype) -> None:
298297
"""Test round operation between two arrays of the same shape"""
299298
with pytest.raises(RuntimeError):
@@ -316,10 +315,10 @@ def test_round_shapes_invalid(invdtypes: dtype.Dtype) -> None:
316315
(random.randint(1, 10), random.randint(1, 10), random.randint(1, 10), random.randint(1, 10)),
317316
],
318317
)
319-
@pytest.mark.parametrize("dtype_name", util.get_real_types())
318+
@pytest.mark.parametrize("dtype_name", get_real_types())
320319
def test_sign_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
321320
"""Test round operation between two arrays of the same shape"""
322-
util.check_type_supported(dtype_name)
321+
check_type_supported(dtype_name)
323322
out = wrapper.randu(shape, dtype_name)
324323

325324
result = wrapper.sign(out)
@@ -328,7 +327,7 @@ def test_sign_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
328327
), f"failed for shape: {shape} and dtype {dtype_name}"
329328

330329

331-
@pytest.mark.parametrize("invdtypes", util.get_complex_types())
330+
@pytest.mark.parametrize("invdtypes", get_complex_types())
332331
def test_sign_shapes_invalid(invdtypes: dtype.Dtype) -> None:
333332
"""Test sign operation between two arrays of the same shape"""
334333
with pytest.raises(RuntimeError):
@@ -351,10 +350,10 @@ def test_sign_shapes_invalid(invdtypes: dtype.Dtype) -> None:
351350
(random.randint(1, 10), random.randint(1, 10), random.randint(1, 10), random.randint(1, 10)),
352351
],
353352
)
354-
@pytest.mark.parametrize("dtype_name", util.get_real_types())
353+
@pytest.mark.parametrize("dtype_name", get_real_types())
355354
def test_trunc_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
356355
"""Test truncating operation for an array with varying shape"""
357-
util.check_type_supported(dtype_name)
356+
check_type_supported(dtype_name)
358357
out = wrapper.randu(shape, dtype_name)
359358

360359
result = wrapper.trunc(out)
@@ -363,7 +362,7 @@ def test_trunc_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
363362
), f"failed for shape: {shape} and dtype {dtype_name}"
364363

365364

366-
@pytest.mark.parametrize("invdtypes", util.get_complex_types())
365+
@pytest.mark.parametrize("invdtypes", get_complex_types())
367366
def test_trunc_shapes_invalid(invdtypes: dtype.Dtype) -> None:
368367
"""Test trunc operation for an array with varrying shape and invalid dtypes"""
369368
with pytest.raises(RuntimeError):
@@ -424,14 +423,13 @@ def test_hypot_unsupported_dtypes(invdtypes: dtype.Dtype) -> None:
424423
(random.randint(1, 10), random.randint(1, 10), random.randint(1, 10), random.randint(1, 10)),
425424
],
426425
)
427-
@pytest.mark.parametrize("dtype_name", util.get_real_types())
426+
@pytest.mark.parametrize("dtype_name", get_real_types())
428427
def test_clamp_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
429428
"""Test clamp operation between two arrays of the same shape"""
430-
util.check_type_supported(dtype_name)
429+
check_type_supported(dtype_name)
431430
og = wrapper.randu(shape, dtype_name)
432431
low = wrapper.randu(shape, dtype_name)
433432
high = wrapper.randu(shape, dtype_name)
434-
# talked to stefan about this, testing broadcasting is unnecessary
435433
result = wrapper.clamp(og, low, high, False)
436434
assert (
437435
wrapper.get_dims(result)[0 : len(shape)] == shape # noqa

0 commit comments

Comments
 (0)