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
d125223d
Commit
d125223d
authored
May 14, 2009
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Buffer support for complex numbers
parent
f8e7386d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
3 deletions
+24
-3
Cython/Compiler/Buffer.py
Cython/Compiler/Buffer.py
+1
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+1
-1
tests/run/bufaccess.pyx
tests/run/bufaccess.pyx
+22
-1
No files found.
Cython/Compiler/Buffer.py
View file @
d125223d
...
...
@@ -635,7 +635,7 @@ def get_type_information_cname(code, dtype, maxdepth=None):
typegroup
=
'U'
else
:
typegroup
=
'I'
elif
complex_possible
:
elif
complex_possible
or
dtype
.
is_complex
:
typegroup
=
'C'
elif
dtype
.
is_float
:
typegroup
=
'R'
...
...
Cython/Compiler/PyrexTypes.py
View file @
d125223d
...
...
@@ -142,7 +142,7 @@ class PyrexType(BaseType):
return
1
def
is_simple_buffer_dtype
(
self
):
return
(
self
.
is_int
or
self
.
is_float
or
self
.
is_pyobject
or
return
(
self
.
is_int
or
self
.
is_float
or
self
.
is_
complex
or
self
.
is_
pyobject
or
self
.
is_extension_type
or
self
.
is_ptr
)
def
struct_nesting_depth
(
self
):
...
...
tests/run/bufaccess.pyx
View file @
d125223d
...
...
@@ -1333,10 +1333,31 @@ cdef class LongComplexMockBuffer(MockBuffer):
cdef
get_itemsize
(
self
):
return
sizeof
(
LongComplex
)
cdef
get_default_format
(
self
):
return
b"Zg"
#cdef extern from "complex.h":
# pass
@
testcase
def
complex_dtype
(
object
[
long
double
complex
]
buf
):
"""
>>> complex_dtype(LongComplexMockBuffer(None, [(0, -1)]))
-1j
"""
print
buf
[
0
]
@
testcase
def
complex_inplace
(
object
[
long
double
complex
]
buf
):
"""
>>> complex_inplace(LongComplexMockBuffer(None, [(0, -1)]))
(1+1j)
"""
buf
[
0
]
=
buf
[
0
]
+
1
+
2j
print
buf
[
0
]
@
testcase
def
complex_struct_dtype
(
object
[
LongComplex
]
buf
):
"""
Note that the format string is "Zg" rather than "2g"...
Note that the format string is "Zg" rather than "2g", yet a struct
is accessed.
>>> complex_struct_dtype(LongComplexMockBuffer(None, [(0, -1)]))
0.0 -1.0
"""
...
...
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