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
5e6496af
Commit
5e6496af
authored
Mar 22, 2012
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More fused runtime dispatch tests and some fixes
parent
39c966d2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
17 deletions
+31
-17
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+5
-5
Cython/Utility/MemoryView.pyx
Cython/Utility/MemoryView.pyx
+1
-1
tests/run/numpy_test.pyx
tests/run/numpy_test.pyx
+25
-11
No files found.
Cython/Compiler/Nodes.py
View file @
5e6496af
...
@@ -2577,7 +2577,7 @@ class FusedCFuncDefNode(StatListNode):
...
@@ -2577,7 +2577,7 @@ class FusedCFuncDefNode(StatListNode):
memslice = {{coerce_from_py_func}}(arg)
memslice = {{coerce_from_py_func}}(arg)
if memslice.memview:
if memslice.memview:
__PYX_XDEC_MEMVIEW(&memslice, 1)
__PYX_XDEC_MEMVIEW(&memslice, 1)
# print
"found a match for the buffer through format parsing"
# print
'found a match for the buffer through format parsing'
%s
%s
break
break
else:
else:
...
@@ -2603,8 +2603,8 @@ class FusedCFuncDefNode(StatListNode):
...
@@ -2603,8 +2603,8 @@ class FusedCFuncDefNode(StatListNode):
if isinstance(arg, numpy.ndarray):
if isinstance(arg, numpy.ndarray):
dtype = arg.dtype
dtype = arg.dtype
elif (__pyx_memoryview_check(arg) and
elif (__pyx_memoryview_check(arg) and
isinstance(arg.
object
, numpy.ndarray)):
isinstance(arg.
base
, numpy.ndarray)):
dtype = arg.
object
.dtype
dtype = arg.
base
.dtype
else:
else:
dtype = None
dtype = None
...
@@ -2612,7 +2612,7 @@ class FusedCFuncDefNode(StatListNode):
...
@@ -2612,7 +2612,7 @@ class FusedCFuncDefNode(StatListNode):
if dtype is not None:
if dtype is not None:
itemsize = dtype.itemsize
itemsize = dtype.itemsize
kind = ord(dtype.kind)
kind = ord(dtype.kind)
dtype_signed = kind == ord('
u
')
dtype_signed = kind == ord('
i
')
"""
)
"""
)
pyx_code
.
indent
(
2
)
pyx_code
.
indent
(
2
)
pyx_code
.
named_insertion_point
(
"numpy_dtype_checks"
)
pyx_code
.
named_insertion_point
(
"numpy_dtype_checks"
)
...
@@ -2805,7 +2805,7 @@ class FusedCFuncDefNode(StatListNode):
...
@@ -2805,7 +2805,7 @@ class FusedCFuncDefNode(StatListNode):
u"""
u"""
candidates = []
candidates = []
for sig in signatures:
for sig in signatures:
match_found =
True
match_found =
filter(None, dest_sig)
for src_type, dst_type in zip(sig.strip('()').split(', '), dest_sig):
for src_type, dst_type in zip(sig.strip('()').split(', '), dest_sig):
if dst_type is not None and match_found:
if dst_type is not None and match_found:
match_found = src_type == dst_type
match_found = src_type == dst_type
...
...
Cython/Utility/MemoryView.pyx
View file @
5e6496af
...
@@ -978,7 +978,7 @@ cdef memoryview_fromslice({{memviewslice_name}} *memviewslice,
...
@@ -978,7 +978,7 @@ cdef memoryview_fromslice({{memviewslice_name}} *memviewslice,
result
.
from_slice
=
memviewslice
[
0
]
result
.
from_slice
=
memviewslice
[
0
]
__PYX_INC_MEMVIEW
(
memviewslice
,
1
)
__PYX_INC_MEMVIEW
(
memviewslice
,
1
)
result
.
from_object
=
<
object
>
memviewslice
.
memview
.
obj
result
.
from_object
=
(
<
memoryview
>
memviewslice
.
memview
).
base
result
.
typeinfo
=
memviewslice
.
memview
.
typeinfo
result
.
typeinfo
=
memviewslice
.
memview
.
typeinfo
result
.
view
=
memviewslice
.
memview
.
view
result
.
view
=
memviewslice
.
memview
.
view
...
...
tests/run/numpy_test.pyx
View file @
5e6496af
...
@@ -735,19 +735,22 @@ def test_dispatch_typedef(np.ndarray[typedeffed_fused_type] a):
...
@@ -735,19 +735,22 @@ def test_dispatch_typedef(np.ndarray[typedeffed_fused_type] a):
cdef
extern
from
"types.h"
:
cdef
extern
from
"types.h"
:
ctypedef
unsigned
char
actually_long_t
ctypedef
char
actually_long_t
cdef
fused
confusing_fused_typedef
:
cdef
fused
confusing_fused_typedef
:
actually_long_t
actually_long_t
int
unsigned
long
double
complex
unsigned
char
unsigned
char
signed
char
signed
char
def
test_dispatch_external_typedef
(
np
.
ndarray
[
confusing_fused_typedef
]
a
):
def
test_dispatch_external_typedef
(
np
.
ndarray
[
confusing_fused_typedef
]
a
):
"""
"""
>>> test_dispatch_external_typedef(np.arange(
10
, dtype=np.long))
>>> test_dispatch_external_typedef(np.arange(
-5, 5
, dtype=np.long))
5
-2
"""
"""
print
a
[
5
]
print
a
[
3
]
# test fused memoryview slices
# test fused memoryview slices
cdef
fused
memslice_fused_dtype
:
cdef
fused
memslice_fused_dtype
:
...
@@ -787,23 +790,34 @@ cdef fused memslice_fused:
...
@@ -787,23 +790,34 @@ cdef fused memslice_fused:
double
complex
[:]
double
complex
[:]
object
[:]
object
[:]
def
test_fused_memslice
_fused
(
memslice_fused
a
):
def
test_fused_memslice
(
memslice_fused
a
):
"""
"""
>>> import cython
>>> import cython
>>> sorted(test_fused_memslice
_fused
.__signatures__)
>>> sorted(test_fused_memslice.__signatures__)
['double complex[:]', 'double[:]', 'float complex[:]', 'float[:]', 'int[:]', 'long[:]', 'object[:]']
['double complex[:]', 'double[:]', 'float complex[:]', 'float[:]', 'int[:]', 'long[:]', 'object[:]']
>>> test_fused_memslice
_fused
(np.arange(10, dtype=np.complex64))
>>> test_fused_memslice(np.arange(10, dtype=np.complex64))
float complex[:] float complex[:] (5+0j) (6+0j)
float complex[:] float complex[:] (5+0j) (6+0j)
>>> test_fused_memslice
_fused
(np.arange(10, dtype=np.complex128))
>>> test_fused_memslice(np.arange(10, dtype=np.complex128))
double complex[:] double complex[:] (5+0j) (6+0j)
double complex[:] double complex[:] (5+0j) (6+0j)
>>> test_fused_memslice
_fused
(np.arange(10, dtype=np.float32))
>>> test_fused_memslice(np.arange(10, dtype=np.float32))
float[:] float[:] 5.0 6.0
float[:] float[:] 5.0 6.0
>>> test_fused_memslice
_fused
(np.arange(10, dtype=np.dtype('i')))
>>> test_fused_memslice(np.arange(10, dtype=np.dtype('i')))
int[:] int[:] 5 6
int[:] int[:] 5 6
>>> test_fused_memslice
_fused
(np.arange(10, dtype=np.object))
>>> test_fused_memslice(np.arange(10, dtype=np.object))
object[:] object[:] 5 6
object[:] object[:] 5 6
"""
"""
cdef
memslice_fused
b
=
a
cdef
memslice_fused
b
=
a
print
cython
.
typeof
(
a
),
cython
.
typeof
(
b
),
a
[
5
],
b
[
6
]
print
cython
.
typeof
(
a
),
cython
.
typeof
(
b
),
a
[
5
],
b
[
6
]
def
test_dispatch_memoryview_object
():
"""
>>> test_dispatch_memoryview_object()
int[:] int[:] 5 6
"""
cdef
int
[:]
m
=
np
.
arange
(
10
,
dtype
=
np
.
dtype
(
'i'
))
cdef
int
[:]
m2
=
m
cdef
int
[:]
m3
=
<
object
>
m
test_fused_memslice
(
m3
)
include
"numpy_common.pxi"
include
"numpy_common.pxi"
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