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
315efe4c
Commit
315efe4c
authored
Apr 10, 2012
by
Mark Florisson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '_numpy' of
git://github.com/dagss/cython
into release
parents
bd7284c2
6f2271d2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
13 deletions
+25
-13
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+4
-5
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+4
-2
Cython/Compiler/NumpySupport.py
Cython/Compiler/NumpySupport.py
+14
-3
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+3
-3
No files found.
Cython/Compiler/ExprNodes.py
View file @
315efe4c
...
...
@@ -34,6 +34,8 @@ import Symtab
import
Options
from
Cython
import
Utils
from
Annotate
import
AnnotationItem
from
NumpySupport
import
numpy_transform_attribute_node
,
\
should_apply_numpy_hack
from
Cython.Debugging
import
print_call_chain
from
DebugFlags
import
debug_disposal_code
,
debug_temp_alloc
,
\
...
...
@@ -4459,10 +4461,8 @@ class AttributeNode(ExprNode):
# attribute.
pass
# NumPy hack
if
(
getattr
(
self
.
obj
,
'type'
,
None
)
and
obj_type
.
is_extension_type
and
obj_type
.
objstruct_cname
==
'PyArrayObject'
):
from
NumpySupport
import
numpy_transform_attribute_node
if
(
getattr
(
self
.
obj
,
'type'
,
None
)
and
obj_type
.
is_extension_type
and
should_apply_numpy_hack
(
obj_type
)):
replacement_node
=
numpy_transform_attribute_node
(
self
)
# Since we can't actually replace our node yet, we only grasp its
# type, and then the replacement happens in
...
...
@@ -4470,7 +4470,6 @@ class AttributeNode(ExprNode):
self
.
type
=
replacement_node
.
type
if
replacement_node
is
not
self
:
return
# If we get here, the base object is not a struct/union/extension
# type, or it is an extension type and the attribute is either not
# declared or is declared as a Python method. Treat it as a Python
...
...
Cython/Compiler/Main.py
View file @
315efe4c
...
...
@@ -24,6 +24,10 @@ module_name_pattern = re.compile(r"[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_
verbose
=
0
standard_include_path
=
os
.
path
.
abspath
(
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
os
.
path
.
pardir
,
'Includes'
)))
class
CompilationData
(
object
):
# Bundles the information that is passed from transform to transform.
# (For now, this is only)
...
...
@@ -70,8 +74,6 @@ class Context(object):
self
.
pxds
=
{}
# full name -> node tree
standard_include_path
=
os
.
path
.
abspath
(
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
os
.
path
.
pardir
,
'Includes'
)))
self
.
include_directories
=
include_directories
+
[
standard_include_path
]
self
.
set_language_level
(
language_level
)
...
...
Cython/Compiler/NumpySupport.py
View file @
315efe4c
...
...
@@ -2,13 +2,24 @@
# the NumPy ABI changed so that the shape, ndim, strides, etc. fields were
# no longer available, however the use of these were so entrenched in
# Cython codes
import
PyrexTypes
import
ExprNodes
import
os
from
StringEncoding
import
EncodedString
def
should_apply_numpy_hack
(
obj_type
):
if
not
obj_type
.
is_extension_type
or
obj_type
.
objstruct_cname
!=
'PyArrayObject'
:
return
False
from
Scanning
import
FileSourceDescriptor
from
Main
import
standard_include_path
type_source
=
obj_type
.
pos
[
0
]
if
isinstance
(
type_source
,
FileSourceDescriptor
):
type_source_path
=
os
.
path
.
abspath
(
os
.
path
.
normpath
(
type_source
.
filename
))
return
type_source_path
==
os
.
path
.
join
(
standard_include_path
,
'numpy.pxd'
)
else
:
return
False
def
numpy_transform_attribute_node
(
node
):
import
PyrexTypes
import
ExprNodes
assert
isinstance
(
node
,
ExprNodes
.
AttributeNode
)
if
node
.
obj
.
type
.
objstruct_cname
!=
'PyArrayObject'
:
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
315efe4c
...
...
@@ -18,7 +18,8 @@ from Cython.Compiler.TreeFragment import TreeFragment
from
Cython.Compiler.StringEncoding
import
EncodedString
from
Cython.Compiler.Errors
import
error
,
warning
,
CompileError
,
InternalError
from
Cython.Compiler.Code
import
UtilityCode
from
Cython.Compiler.NumpySupport
import
(
should_apply_numpy_hack
,
numpy_transform_attribute_node
)
import
copy
...
...
@@ -1797,8 +1798,7 @@ class AnalyseExpressionsTransform(CythonTransform):
#print node.dump()
#return node
type
=
node
.
obj
.
type
if
type
.
is_extension_type
and
type
.
objstruct_cname
==
'PyArrayObject'
:
from
NumpySupport
import
numpy_transform_attribute_node
if
type
.
is_extension_type
and
should_apply_numpy_hack
(
type
):
node
=
numpy_transform_attribute_node
(
node
)
self
.
visitchildren
(
node
)
...
...
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