FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
arrayfire-binary-python-wrapper/tests/test_random.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_random.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
111 lines (84 loc) · 3.36 KB
Breadcrumbs
arrayfire-binary-python-wrapper
/
tests
/
test_random.py
Copy path
File metadata and controls
111 lines (84 loc) · 3.36 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
import
random
import
pytest
import
arrayfire_wrapper
.
dtypes
as
dtypes
import
arrayfire_wrapper
.
lib
as
wrapper
@
pytest
.
mark
.
parametrize
(
"shape"
,
[
(),
(
random
.
randint
(
1
,
10
),
1
),
(
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
)),
],
)
def
test_randu_shape
(
shape
:
tuple
)
->
None
:
"""Test if randu function creates an array with the correct shape."""
dtype
=
dtypes
.
s16
result
=
wrapper
.
randu
(
shape
,
dtype
)
assert
wrapper
.
get_dims
(
result
)[
0
:
len
(
shape
)]
==
shape
# noqa: E203
@
pytest
.
mark
.
parametrize
(
"shape"
,
[
(),
(
random
.
randint
(
1
,
10
),
1
),
(
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
)),
],
)
def
test_random_uniform_shape
(
shape
:
tuple
)
->
None
:
"""Test if rand uniform function creates an array with the correct shape."""
dtype
=
dtypes
.
s16
engine
=
wrapper
.
create_random_engine
(
100
,
10
)
result
=
wrapper
.
random_uniform
(
shape
,
dtype
,
engine
)
assert
wrapper
.
get_dims
(
result
)[
0
:
len
(
shape
)]
==
shape
# noqa: E203
@
pytest
.
mark
.
parametrize
(
"shape"
,
[
(),
(
random
.
randint
(
1
,
10
),
1
),
(
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
)),
],
)
def
test_randn_shape
(
shape
:
tuple
)
->
None
:
"""Test if randn function creates an array with the correct shape."""
dtype
=
dtypes
.
f32
result
=
wrapper
.
randn
(
shape
,
dtype
)
assert
wrapper
.
get_dims
(
result
)[
0
:
len
(
shape
)]
==
shape
# noqa: E203
@
pytest
.
mark
.
parametrize
(
"shape"
,
[
(),
(
random
.
randint
(
1
,
10
),
1
),
(
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
)),
],
)
def
test_random_normal_shape
(
shape
:
tuple
)
->
None
:
"""Test if random normal function creates an array with the correct shape."""
dtype
=
dtypes
.
f32
engine
=
wrapper
.
create_random_engine
(
100
,
10
)
result
=
wrapper
.
random_normal
(
shape
,
dtype
,
engine
)
assert
wrapper
.
get_dims
(
result
)[
0
:
len
(
shape
)]
==
shape
# noqa: E203
@
pytest
.
mark
.
parametrize
(
"engine_index"
,
[
100
,
200
,
300
],
)
def
test_create_random_engine
(
engine_index
:
int
)
->
None
:
engine
=
wrapper
.
create_random_engine
(
engine_index
,
10
)
engine_type
=
wrapper
.
random_engine_get_type
(
engine
)
assert
engine_type
==
engine_index
@
pytest
.
mark
.
parametrize
(
"invalid_index"
,
[
random
.
randint
(
301
,
600
),
random
.
randint
(
301
,
600
),
random
.
randint
(
301
,
600
)],
)
def
test_invalid_random_engine
(
invalid_index
:
int
)
->
None
:
"Test if invalid engine types are properly handled"
with
pytest
.
raises
(
RuntimeError
):
invalid_engine
=
wrapper
.
create_random_engine
(
invalid_index
,
10
)
engine_type
=
wrapper
.
random_engine_get_type
(
invalid_engine
)
assert
engine_type
==
invalid_engine
Back
|
FazBrowse Home
|
New Git URL