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
Kirill Smelkov
cython
Commits
aed824f2
Commit
aed824f2
authored
Sep 29, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Buffers: Complex number structs work.
parent
c587c449
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
17 deletions
+14
-17
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+7
-12
tests/run/bufaccess.pyx
tests/run/bufaccess.pyx
+7
-1
tests/run/numpy_test.pyx
tests/run/numpy_test.pyx
+0
-4
No files found.
Cython/Compiler/ExprNodes.py
View file @
aed824f2
...
...
@@ -1473,11 +1473,8 @@ class IndexNode(ExprNode):
self
.
is_buffer_access
=
True
self
.
buffer_type
=
self
.
base
.
entry
.
type
if
getting
:
# we only need a temp because result_code isn't refactored to
# generation time, but this seems an ok shortcut to take
if
getting
and
self
.
type
.
is_pyobject
:
self
.
is_temp
=
True
self
.
result_ctype
=
PyrexTypes
.
c_ptr_type
(
self
.
type
)
if
setting
:
if
not
self
.
base
.
entry
.
type
.
writable
:
error
(
self
.
pos
,
"Writing to readonly buffer"
)
...
...
@@ -1528,7 +1525,7 @@ class IndexNode(ExprNode):
def
calculate_result_code
(
self
):
if
self
.
is_buffer_access
:
return
"
<not used>"
return
"
(*%s)"
%
self
.
buffer_ptr_code
else
:
return
"(%s[%s])"
%
(
self
.
base
.
result
(),
self
.
index
.
result
())
...
...
@@ -1562,12 +1559,10 @@ class IndexNode(ExprNode):
if
self
.
is_buffer_access
:
if
code
.
globalstate
.
directives
[
'nonecheck'
]:
self
.
put_nonecheck
(
code
)
ptrcode
=
self
.
buffer_lookup_code
(
code
)
code
.
putln
(
"%s = *%s;"
%
(
self
.
result
(),
self
.
buffer_type
.
buffer_ptr_type
.
cast_code
(
ptrcode
)))
# Must incref the value we pulled out.
if
self
.
buffer_type
.
dtype
.
is_pyobject
:
self
.
buffer_ptr_code
=
self
.
buffer_lookup_code
(
code
)
if
self
.
type
.
is_pyobject
:
# is_temp is True, so must pull out value and incref it.
code
.
putln
(
"%s = *%s;"
%
(
self
.
result
(),
self
.
buffer_ptr_code
))
code
.
putln
(
"Py_INCREF((PyObject*)%s);"
%
self
.
result
())
elif
self
.
type
.
is_pyobject
:
if
self
.
index
.
type
.
is_int
:
...
...
tests/run/bufaccess.pyx
View file @
aed824f2
...
...
@@ -25,7 +25,13 @@ setup_string = u"""
"""
import
re
exclude
=
[]
#re.compile('object').search]
def
testcase
(
func
):
for
e
in
exclude
:
if
e
(
func
.
__name__
):
return
func
__test__
[
func
.
__name__
]
=
setup_string
+
func
.
__doc__
return
func
...
...
@@ -1326,7 +1332,7 @@ def complex_struct_dtype(object[LongComplex] buf):
@
testcase
def
complex_struct_inplace
(
object
[
LongComplex
]
buf
):
"""
>>> complex_struct_
dtyp
e(LongComplexMockBuffer(None, [(0, -1)]))
>>> complex_struct_
inplac
e(LongComplexMockBuffer(None, [(0, -1)]))
1.0 1.0
"""
buf
[
0
].
real
+=
1
...
...
tests/run/numpy_test.pyx
View file @
aed824f2
...
...
@@ -229,14 +229,10 @@ def inc1_cdouble(np.ndarray[cdouble] arr):
arr
[
1
].
imag
+=
1
def
inc1_clongdouble
(
np
.
ndarray
[
clongdouble
]
arr
):
print
arr
[
1
].
real
print
arr
[
1
].
imag
cdef
long
double
x
x
=
arr
[
1
].
real
+
1
arr
[
1
].
real
=
x
arr
[
1
].
imag
=
arr
[
1
].
imag
+
1
print
arr
[
1
].
real
print
arr
[
1
].
imag
def
inc1_object
(
np
.
ndarray
[
object
]
arr
):
o
=
arr
[
1
]
...
...
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