Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
ca354aab
Commit
ca354aab
authored
Feb 11, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extended test case
parent
881a4c61
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
4 deletions
+56
-4
tests/run/carray_slicing.pyx
tests/run/carray_slicing.pyx
+56
-4
No files found.
tests/run/carray_slicing.pyx
View file @
ca354aab
...
...
@@ -118,9 +118,9 @@ for i in range(6):
@
cython
.
test_assert_path_exists
(
"//ForFromStatNode"
,
"//ForFromStatNode//IndexNode"
)
@
cython
.
test_fail_if_path_exists
(
"//ForInStatNode"
)
def
slice_int
ptr
_for_loop_c
():
def
slice_int
array
_for_loop_c
():
"""
>>> slice_int
ptr
_for_loop_c()
>>> slice_int
array
_for_loop_c()
[0, 1, 2]
[1, 2, 3, 4]
[4, 5]
...
...
@@ -133,10 +133,62 @@ def slice_intptr_for_loop_c():
@
cython
.
test_assert_path_exists
(
"//ForFromStatNode"
,
"//ForFromStatNode//IndexNode"
)
@
cython
.
test_fail_if_path_exists
(
"//ForInStatNode"
)
def
iter_int
ptr
_for_loop_c
():
def
iter_int
array
_for_loop_c
():
"""
>>> iter_int
ptr
_for_loop_c()
>>> iter_int
array
_for_loop_c()
[0, 1, 2, 3, 4, 5]
"""
cdef
int
i
print
[
i
for
i
in
cints
]
@
cython
.
test_assert_path_exists
(
"//ForFromStatNode"
,
"//ForFromStatNode//IndexNode"
)
@
cython
.
test_fail_if_path_exists
(
"//ForInStatNode"
)
def
slice_intptr_for_loop_c
():
"""
>>> slice_intptr_for_loop_c()
[0, 1, 2]
[1, 2, 3, 4]
[4, 5]
"""
cdef
int
*
nums
=
cints
cdef
int
i
print
[
i
for
i
in
nums
[:
3
]
]
print
[
i
for
i
in
nums
[
1
:
5
]
]
print
[
i
for
i
in
nums
[
4
:
6
]
]
############################################################
# tests for slicing other arrays
cdef
double
cdoubles
[
6
]
for
i
in
range
(
6
):
cdoubles
[
i
]
=
i
+
0.1
cdef
double
*
cdoubles_ptr
=
cdoubles
@
cython
.
test_assert_path_exists
(
"//ForFromStatNode"
,
"//ForFromStatNode//IndexNode"
)
@
cython
.
test_fail_if_path_exists
(
"//ForInStatNode"
)
def
slice_doublptr_for_loop_c
():
"""
>>> slice_doublptr_for_loop_c()
[0.1, 1.1, 2.1]
[1.1, 2.1, 3.1, 4.1]
[4.1, 5.1]
"""
cdef
double
d
print
[
d
for
d
in
cdoubles_ptr
[:
3
]
]
print
[
d
for
d
in
cdoubles_ptr
[
1
:
5
]
]
print
[
d
for
d
in
cdoubles_ptr
[
4
:
6
]
]
@
cython
.
test_assert_path_exists
(
"//ForFromStatNode"
,
"//ForFromStatNode//IndexNode"
)
@
cython
.
test_fail_if_path_exists
(
"//ForInStatNode"
)
def
iter_doublearray_for_loop_c
():
"""
>>> iter_doublearray_for_loop_c()
[0.1, 1.1, 2.1, 3.1, 4.1, 5.1]
"""
cdef
double
d
print
[
d
for
d
in
cdoubles
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment