FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python/test/numpy/indexing.py at develop · Devsh-Graphics-Programming/python · GitHub
Devsh-Graphics-Programming
/
python
Public
forked from
boostorg/python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python
/
test
/
numpy
/
indexing.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
55 lines (47 loc) · 1.78 KB
Breadcrumbs
python
/
test
/
numpy
/
indexing.py
Copy path
File metadata and controls
55 lines (47 loc) · 1.78 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
#!/usr/bin/env python3
# Copyright Jim Bosch & Ankit Daftery 2010-2012.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
import
unittest
import
numpy
import
indexing_ext
class
TestIndexing
(
unittest
.
TestCase
):
def
testSingle
(
self
):
x
=
numpy
.
arange
(
0
,
10
)
for
i
in
range
(
0
,
10
):
numpy
.
testing
.
assert_equal
(
indexing_ext
.
single
(
x
,
i
),
i
)
for
i
in
range
(
-
10
,
0
):
numpy
.
testing
.
assert_equal
(
indexing_ext
.
single
(
x
,
i
),
10
+
i
)
def
testSlice
(
self
):
x
=
numpy
.
arange
(
0
,
10
)
sl
=
slice
(
3
,
8
)
b
=
[
3
,
4
,
5
,
6
,
7
]
numpy
.
testing
.
assert_equal
(
indexing_ext
.
slice
(
x
,
sl
),
b
)
def
testStepSlice
(
self
):
x
=
numpy
.
arange
(
0
,
10
)
sl
=
slice
(
3
,
8
,
2
)
b
=
[
3
,
5
,
7
]
numpy
.
testing
.
assert_equal
(
indexing_ext
.
slice
(
x
,
sl
),
b
)
def
testIndex
(
self
):
x
=
numpy
.
arange
(
0
,
10
)
chk
=
numpy
.
array
([
3
,
4
,
5
,
6
])
numpy
.
testing
.
assert_equal
(
indexing_ext
.
indexarray
(
x
,
chk
),
chk
)
chk
=
numpy
.
array
([[
0
,
1
],[
2
,
3
]])
numpy
.
testing
.
assert_equal
(
indexing_ext
.
indexarray
(
x
,
chk
),
chk
)
x
=
numpy
.
arange
(
9
).
reshape
(
3
,
3
)
y
=
numpy
.
array
([
0
,
1
])
z
=
numpy
.
array
([
0
,
2
])
chk
=
numpy
.
array
([
0
,
5
])
numpy
.
testing
.
assert_equal
(
indexing_ext
.
indexarray
(
x
,
y
,
z
),
chk
)
x
=
numpy
.
arange
(
0
,
10
)
b
=
x
>
4
chk
=
numpy
.
array
([
5
,
6
,
7
,
8
,
9
])
numpy
.
testing
.
assert_equal
(
indexing_ext
.
indexarray
(
x
,
b
),
chk
)
x
=
numpy
.
arange
(
9
).
reshape
(
3
,
3
)
b
=
numpy
.
array
([
0
,
2
])
sl
=
slice
(
0
,
3
)
chk
=
numpy
.
array
([[
0
,
1
,
2
],[
6
,
7
,
8
]])
numpy
.
testing
.
assert_equal
(
indexing_ext
.
indexslice
(
x
,
b
,
sl
),
chk
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Back
|
FazBrowse Home
|
New Git URL