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
Gwenaël Samain
cython
Commits
1d00d8ad
Commit
1d00d8ad
authored
Mar 30, 2012
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix two memoryview related tests (py3k)
parent
8512993a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
18 deletions
+15
-18
tests/run/memoryviewattrs.pyx
tests/run/memoryviewattrs.pyx
+6
-14
tests/run/numpy_memoryview.pyx
tests/run/numpy_memoryview.pyx
+9
-4
No files found.
tests/run/memoryviewattrs.pyx
View file @
1d00d8ad
...
@@ -55,24 +55,16 @@ def test_copy_to():
...
@@ -55,24 +55,16 @@ def test_copy_to():
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7
'''
'''
cdef
int
[:,
:,
:]
from_mvs
,
to_mvs
cdef
int
[:,
:,
:]
from_mvs
,
to_mvs
from_mvs
=
np
.
arange
(
8
,
dtype
=
np
.
int32
).
reshape
(
2
,
2
,
2
)
from_mvs
=
np
.
arange
(
8
,
dtype
=
np
.
int32
).
reshape
(
2
,
2
,
2
)
cdef
int
*
from_dta
=
<
int
*>
from_mvs
.
_data
cdef
int
*
from_data
=
<
int
*>
from_mvs
.
_data
for
i
in
range
(
2
*
2
*
2
):
print
' '
.
join
(
str
(
from_data
[
i
])
for
i
in
range
(
2
*
2
*
2
))
print
from_dta
[
i
],
print
# for i in range(2*2*2):
# from_dta[i] = i
to_mvs
=
array
((
2
,
2
,
2
),
sizeof
(
int
),
'i'
)
to_mvs
=
array
((
2
,
2
,
2
),
sizeof
(
int
),
'i'
)
to_mvs
[...]
=
from_mvs
to_mvs
[...]
=
from_mvs
cdef
int
*
to_data
=
<
int
*>
to_mvs
.
_data
cdef
int
*
to_data
=
<
int
*>
to_mvs
.
_data
for
i
in
range
(
2
*
2
*
2
):
print
' '
.
join
(
str
(
from_data
[
i
])
for
i
in
range
(
2
*
2
*
2
))
print
from_dta
[
i
],
print
' '
.
join
(
str
(
to_data
[
i
])
for
i
in
range
(
2
*
2
*
2
))
print
for
i
in
range
(
2
*
2
*
2
):
print
to_data
[
i
],
print
@
testcase
@
testcase
def
test_overlapping_copy
():
def
test_overlapping_copy
():
...
...
tests/run/numpy_memoryview.pyx
View file @
1d00d8ad
...
@@ -243,9 +243,12 @@ ctypedef td_h_short td_h_cy_short
...
@@ -243,9 +243,12 @@ ctypedef td_h_short td_h_cy_short
cdef
void
dealloc_callback
(
void
*
data
):
cdef
void
dealloc_callback
(
void
*
data
):
print
"deallocating..."
print
"deallocating..."
def
index
(
array
array
):
def
build_numarray
(
array
array
):
array
.
callback_free_data
=
dealloc_callback
array
.
callback_free_data
=
dealloc_callback
print
np
.
asarray
(
array
)[
3
,
2
]
return
np
.
asarray
(
array
)
def
index
(
array
array
):
print
build_numarray
(
array
)[
3
,
2
]
@
testcase_numpy_1_5
@
testcase_numpy_1_5
def
test_coerce_to_numpy
():
def
test_coerce_to_numpy
():
...
@@ -254,7 +257,7 @@ def test_coerce_to_numpy():
...
@@ -254,7 +257,7 @@ def test_coerce_to_numpy():
generated format strings.
generated format strings.
>>> test_coerce_to_numpy()
>>> test_coerce_to_numpy()
(97, 98, 600L, 700, 800)
[97, 98, 600, 700, 800]
deallocating...
deallocating...
(600, 700)
(600, 700)
deallocating...
deallocating...
...
@@ -359,7 +362,9 @@ def test_coerce_to_numpy():
...
@@ -359,7 +362,9 @@ def test_coerce_to_numpy():
#
#
### Create a NumPy array and see if our element can be correctly retrieved
### Create a NumPy array and see if our element can be correctly retrieved
#
#
index
(
<
MyStruct
[:
4
,
:
5
]
>
<
MyStruct
*>
mystructs
)
mystruct_array
=
build_numarray
(
<
MyStruct
[:
4
,
:
5
]
>
<
MyStruct
*>
mystructs
)
print
[
int
(
x
)
for
x
in
mystruct_array
[
3
,
2
]]
del
mystruct_array
index
(
<
SmallStruct
[:
4
,
:
5
]
>
<
SmallStruct
*>
smallstructs
)
index
(
<
SmallStruct
[:
4
,
:
5
]
>
<
SmallStruct
*>
smallstructs
)
index
(
<
NestedStruct
[:
4
,
:
5
]
>
<
NestedStruct
*>
nestedstructs
)
index
(
<
NestedStruct
[:
4
,
:
5
]
>
<
NestedStruct
*>
nestedstructs
)
index
(
<
PackedStruct
[:
4
,
:
5
]
>
<
PackedStruct
*>
packedstructs
)
index
(
<
PackedStruct
[:
4
,
:
5
]
>
<
PackedStruct
*>
packedstructs
)
...
...
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