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
b997c4ae
Commit
b997c4ae
authored
Apr 10, 2012
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow attribute specializations and add some tests
parent
315efe4c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
3 deletions
+56
-3
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-1
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+3
-2
tests/run/numpy_test.pyx
tests/run/numpy_test.pyx
+52
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
b997c4ae
...
...
@@ -2738,7 +2738,7 @@ class IndexNode(ExprNode):
specific_types
=
[]
positions
=
[]
if
self
.
index
.
is_name
:
if
self
.
index
.
is_name
or
self
.
index
.
is_attribute
:
positions
.
append
(
self
.
index
.
pos
)
specific_types
.
append
(
self
.
index
.
analyse_as_type
(
env
))
elif
isinstance
(
self
.
index
,
TupleNode
):
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
b997c4ae
...
...
@@ -1785,7 +1785,7 @@ class AnalyseExpressionsTransform(CythonTransform):
"""
self
.
visit_Node
(
node
)
if
node
.
is_fused_index
and
no
de
.
type
is
not
PyrexTypes
.
error_type
:
if
node
.
is_fused_index
and
no
t
node
.
type
.
is_error
:
node
=
node
.
base
elif
node
.
memslice_ellipsis_noop
:
# memoryviewslice[...] expression, drop the IndexNode
...
...
@@ -1798,7 +1798,8 @@ class AnalyseExpressionsTransform(CythonTransform):
#print node.dump()
#return node
type
=
node
.
obj
.
type
if
type
.
is_extension_type
and
should_apply_numpy_hack
(
type
):
if
(
not
node
.
type
.
is_error
and
type
.
is_extension_type
and
should_apply_numpy_hack
(
type
)):
node
=
numpy_transform_attribute_node
(
node
)
self
.
visitchildren
(
node
)
...
...
tests/run/numpy_test.pyx
View file @
b997c4ae
...
...
@@ -516,4 +516,56 @@ def test_fused_ndarray_dtype(np.ndarray[cython.floating, ndim=1] a):
cdef
np
.
ndarray
[
cython
.
floating
,
ndim
=
1
]
b
=
a
print
cython
.
typeof
(
a
),
cython
.
typeof
(
b
),
a
[
5
],
b
[
6
]
double_array
=
np
.
linspace
(
0
,
1
,
100
)
int32_array
=
np
.
arange
(
100
,
dtype
=
np
.
int32
)
cdef
fused
fused_external
:
np
.
int32_t
np
.
int64_t
np
.
float32_t
np
.
float64_t
def
test_fused_external
(
np
.
ndarray
[
fused_external
,
ndim
=
1
]
a
):
"""
>>> import cython
>>> print sorted(test_fused_external.__signatures__)
['float32_t', 'float64_t', 'int32_t', 'int64_t']
>>> test_fused_external["float64_t"](double_array)
float64
>>> test_fused_external["int32_t"](int32_array)
int32
>>> test_fused_external(np.arange(100)) # fix in next release
Traceback (most recent call last):
File "/Users/mark/source/py/osx/lib/python2.7/doctest.py", line 1248, in __run
compileflags, 1) in test.globs
File "<doctest numpy_test.__test__.test_fused_external (line 525)[5]>", line 1, in <module>
File "numpy_test.pyx", line 525, in numpy_test.__pyx_fused_cpdef (numpy_test.cpp:10264)
TypeError: No matching signature found
"""
print
a
.
dtype
cdef
fused
fused_buffers
:
np
.
ndarray
[
np
.
int32_t
,
ndim
=
1
]
np
.
int64_t
[::
1
]
def
test_fused_buffers
(
fused_buffers
arg
):
"""
>>> sorted(test_fused_buffers.__signatures__)
"""
cpdef
_fused_cpdef_buffers
(
np
.
ndarray
[
fused_external
]
a
):
print
a
.
dtype
def
test_fused_cpdef_buffers
():
"""
>>> test_fused_cpdef_buffers()
"""
_fused_cpdef_buffers
[
np
.
int32_t
](
int32_array
)
cdef
np
.
ndarray
[
np
.
int32_t
]
typed_array
=
int32_array
_fused_cpdef_buffers
(
typed_array
)
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