FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
arrayfire-binary-python-wrapper/tests/test_trig.py at master · arrayfire/arrayfire-binary-python-wrapper · GitHub
arrayfire
arrayfire-binary-python-wrapper
Repository navigation
Code
Issues
1
(1)
Pull requests
2
(2)
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
arrayfire-binary-python-wrapper
/
tests
/
test_trig.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
156 lines (138 loc) · 5.79 KB
Breadcrumbs
arrayfire-binary-python-wrapper
/
tests
/
test_trig.py
Copy path
File metadata and controls
156 lines (138 loc) · 5.79 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import
random
import
pytest
import
arrayfire_wrapper
.
dtypes
as
dtype
import
arrayfire_wrapper
.
lib
as
wrapper
from
tests
.
utility_functions
import
check_type_supported
,
get_all_types
,
get_float_types
@
pytest
.
mark
.
parametrize
(
"shape"
,
[
(),
(
random
.
randint
(
1
,
10
),),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
],
)
@
pytest
.
mark
.
parametrize
(
"dtype_name"
,
get_all_types
())
def
test_asin_shape_dtypes
(
shape
:
tuple
,
dtype_name
:
dtype
.
Dtype
)
->
None
:
"""Test inverse sine operation across all supported data types."""
check_type_supported
(
dtype_name
)
values
=
wrapper
.
randu
(
shape
,
dtype_name
)
result
=
wrapper
.
asin
(
values
)
assert
wrapper
.
get_dims
(
result
)[
0
:
len
(
shape
)]
==
shape
,
f"failed for shape:
{
shape
}
"
# noqa
@
pytest
.
mark
.
parametrize
(
"shape"
,
[
(),
(
random
.
randint
(
1
,
10
),),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
],
)
@
pytest
.
mark
.
parametrize
(
"dtype_name"
,
get_all_types
())
def
test_acos_shape_dtypes
(
shape
:
tuple
,
dtype_name
:
dtype
.
Dtype
)
->
None
:
"""Test inverse cosine operation across all supported data types."""
check_type_supported
(
dtype_name
)
values
=
wrapper
.
randu
(
shape
,
dtype_name
)
result
=
wrapper
.
acos
(
values
)
assert
wrapper
.
get_dims
(
result
)[
0
:
len
(
shape
)]
==
shape
,
f"failed for shape:
{
shape
}
"
# noqa
@
pytest
.
mark
.
parametrize
(
"shape"
,
[
(),
(
random
.
randint
(
1
,
10
),),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
],
)
@
pytest
.
mark
.
parametrize
(
"dtype_name"
,
get_all_types
())
def
test_atan_shape_dtypes
(
shape
:
tuple
,
dtype_name
:
dtype
.
Dtype
)
->
None
:
"""Test inverse tan operation across all supported data types."""
check_type_supported
(
dtype_name
)
values
=
wrapper
.
randu
(
shape
,
dtype_name
)
result
=
wrapper
.
atan
(
values
)
assert
wrapper
.
get_dims
(
result
)[
0
:
len
(
shape
)]
==
shape
,
f"failed for shape:
{
shape
}
"
# noqa
@
pytest
.
mark
.
parametrize
(
"shape"
,
[
(),
(
random
.
randint
(
1
,
10
),),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
],
)
@
pytest
.
mark
.
parametrize
(
"dtype_name"
,
get_float_types
())
def
test_atan2_shape_dtypes
(
shape
:
tuple
,
dtype_name
:
dtype
.
Dtype
)
->
None
:
"""Test inverse tan operation across all supported data types."""
check_type_supported
(
dtype_name
)
if
dtype_name
==
dtype
.
f16
:
pytest
.
skip
()
lhs
=
wrapper
.
randu
(
shape
,
dtype_name
)
rhs
=
wrapper
.
randu
(
shape
,
dtype_name
)
result
=
wrapper
.
atan2
(
lhs
,
rhs
)
assert
wrapper
.
get_dims
(
result
)[
0
:
len
(
shape
)]
==
shape
,
f"failed for shape:
{
shape
}
"
# noqa
@
pytest
.
mark
.
parametrize
(
"invdtypes"
,
[
dtype
.
int16
,
dtype
.
bool
,
],
)
def
test_atan2_unsupported_dtypes
(
invdtypes
:
dtype
.
Dtype
)
->
None
:
"""Test inverse tan operation for unsupported data types."""
with
pytest
.
raises
(
RuntimeError
):
wrapper
.
atan2
(
wrapper
.
randu
((
10
,
10
),
invdtypes
),
wrapper
.
randu
((
10
,
10
),
invdtypes
))
@
pytest
.
mark
.
parametrize
(
"shape"
,
[
(),
(
random
.
randint
(
1
,
10
),),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
],
)
@
pytest
.
mark
.
parametrize
(
"dtype_name"
,
get_all_types
())
def
test_cos_shape_dtypes
(
shape
:
tuple
,
dtype_name
:
dtype
.
Dtype
)
->
None
:
"""Test cosine operation across all supported data types."""
check_type_supported
(
dtype_name
)
values
=
wrapper
.
randu
(
shape
,
dtype_name
)
result
=
wrapper
.
cos
(
values
)
assert
wrapper
.
get_dims
(
result
)[
0
:
len
(
shape
)]
==
shape
,
f"failed for shape:
{
shape
}
"
# noqa
@
pytest
.
mark
.
parametrize
(
"shape"
,
[
(),
(
random
.
randint
(
1
,
10
),),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
],
)
@
pytest
.
mark
.
parametrize
(
"dtype_name"
,
get_all_types
())
def
test_sin_shape_dtypes
(
shape
:
tuple
,
dtype_name
:
dtype
.
Dtype
)
->
None
:
"""Test sin operation across all supported data types."""
check_type_supported
(
dtype_name
)
values
=
wrapper
.
randu
(
shape
,
dtype_name
)
result
=
wrapper
.
sin
(
values
)
assert
wrapper
.
get_dims
(
result
)[
0
:
len
(
shape
)]
==
shape
,
f"failed for shape:
{
shape
}
"
# noqa
@
pytest
.
mark
.
parametrize
(
"shape"
,
[
(),
(
random
.
randint
(
1
,
10
),),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
)),
],
)
@
pytest
.
mark
.
parametrize
(
"dtype_name"
,
get_all_types
())
def
test_tan_shape_dtypes
(
shape
:
tuple
,
dtype_name
:
dtype
.
Dtype
)
->
None
:
"""Test tan operation across all supported data types."""
check_type_supported
(
dtype_name
)
values
=
wrapper
.
randu
(
shape
,
dtype_name
)
result
=
wrapper
.
tan
(
values
)
assert
wrapper
.
get_dims
(
result
)[
0
:
len
(
shape
)]
==
shape
,
f"failed for shape:
{
shape
}
"
# noqa
Back
|
FazBrowse Home
|
New Git URL