4
4
import pytest
5
5
6
6
import arrayfire_wrapper .dtypes as dtypes
7
- from arrayfire_wrapper .lib ._constants import Pad
8
- from arrayfire_wrapper .lib .create_and_modify_array .create_array .constant import constant
9
- from arrayfire_wrapper .lib .create_and_modify_array .create_array .pad import pad
10
- from arrayfire_wrapper .lib .create_and_modify_array .manage_array import get_dims
7
+ import arrayfire_wrapper .lib as wrapper
11
8
12
9
13
10
@pytest .mark .parametrize (
21
18
)
22
19
def test_zero_padding (original_shape : tuple ) -> None :
23
20
"""Test if pad creates an array with no padding if no padding is given"""
24
- original_array = constant (2 , original_shape , dtypes .s64 )
25
- padding = Pad (0 )
21
+ original_array = wrapper . constant (2 , original_shape , dtypes .s64 )
22
+ padding = wrapper . Pad (0 )
26
23
27
24
zero_shape = tuple (0 for _ in range (len (original_shape )))
28
- result = pad (original_array , zero_shape , zero_shape , padding )
25
+ result = wrapper . pad (original_array , zero_shape , zero_shape , padding )
29
26
30
- assert get_dims (result )[0 : len (original_shape )] == original_shape
27
+ assert wrapper . get_dims (result )[0 : len (original_shape )] == original_shape # noqa: E203
31
28
32
29
33
30
@pytest .mark .parametrize (
@@ -42,13 +39,13 @@ def test_zero_padding(original_shape: tuple) -> None:
42
39
def test_negative_padding (original_shape : tuple ) -> None :
43
40
"""Test if pad can properly handle if negative padding is given"""
44
41
with pytest .raises (RuntimeError ):
45
- original_array = constant (2 , original_shape , dtypes .s64 )
46
- padding = Pad (0 )
42
+ original_array = wrapper . constant (2 , original_shape , dtypes .s64 )
43
+ padding = wrapper . Pad (0 )
47
44
48
45
neg_shape = tuple (- 1 for _ in range (len (original_shape )))
49
- result = pad (original_array , neg_shape , neg_shape , padding )
46
+ result = wrapper . pad (original_array , neg_shape , neg_shape , padding )
50
47
51
- assert get_dims (result )[0 : len (original_shape )] == original_shape
48
+ assert wrapper . get_dims (result )[0 : len (original_shape )] == original_shape # noqa: E203
52
49
53
50
54
51
@pytest .mark .parametrize (
@@ -62,13 +59,13 @@ def test_negative_padding(original_shape: tuple) -> None:
62
59
)
63
60
def test_padding_shape (original_shape : tuple ) -> None :
64
61
"""Test if pad outputs the correct shape when a padding is adding to the original array"""
65
- original_array = constant (2 , original_shape , dtypes .s64 )
66
- padding = Pad (0 )
62
+ original_array = wrapper . constant (2 , original_shape , dtypes .s64 )
63
+ padding = wrapper . Pad (0 )
67
64
68
65
beg_shape = tuple (random .randint (1 , 10 ) for _ in range (len (original_shape )))
69
66
end_shape = tuple (random .randint (1 , 10 ) for _ in range (len (original_shape )))
70
67
71
- result = pad (original_array , beg_shape , end_shape , padding )
68
+ result = wrapper . pad (original_array , beg_shape , end_shape , padding )
72
69
new_shape = np .array (beg_shape ) + np .array (end_shape ) + np .array (original_shape )
73
70
74
- assert get_dims (result )[0 : len (original_shape )] == tuple (new_shape )
71
+ assert wrapper . get_dims (result )[0 : len (original_shape )] == tuple (new_shape ) # noqa: E203
0 commit comments