FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
arrayfire-binary-python-wrapper/tests/test_range.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_range.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
61 lines (49 loc) · 1.74 KB
Breadcrumbs
arrayfire-binary-python-wrapper
/
tests
/
test_range.py
Copy path
File metadata and controls
61 lines (49 loc) · 1.74 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
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_range_shape
(
shape
:
tuple
)
->
None
:
"""Test if the range function output an AFArray with the correct shape"""
dim
=
2
dtype
=
dtypes
.
s16
result
=
wrapper
.
range
(
shape
,
dim
,
dtype
)
assert
wrapper
.
get_dims
(
result
)[
0
:
len
(
shape
)]
==
shape
# noqa: E203
def
test_range_invalid_shape
()
->
None
:
"""Test if range function correctly handles an invalid shape"""
with
pytest
.
raises
(
TypeError
):
shape
=
(
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
random
.
randint
(
1
,
10
),
)
dim
=
2
dtype
=
dtypes
.
s16
wrapper
.
range
(
shape
,
dim
,
dtype
)
@
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_range_invalid_dim
(
shape
:
tuple
)
->
None
:
"""Test if the range function can properly handle and invalid dimension given"""
with
pytest
.
raises
(
RuntimeError
):
dim
=
random
.
randint
(
4
,
10
)
dtype
=
dtypes
.
s16
wrapper
.
range
(
shape
,
dim
,
dtype
)
Back
|
FazBrowse Home
|
New Git URL