Commit 29d68530 authored by Mark Florisson's avatar Mark Florisson

Don't assume a NameNode attribute base in NumpySupport

parent 05739037
...@@ -26,7 +26,7 @@ def numpy_transform_attribute_node(node): ...@@ -26,7 +26,7 @@ def numpy_transform_attribute_node(node):
return node return node
pos = node.pos pos = node.pos
numpy_pxd_scope = node.obj.entry.type.scope.parent_scope numpy_pxd_scope = node.obj.type.scope.parent_scope
def macro_call_node(numpy_macro_name): def macro_call_node(numpy_macro_name):
array_node = node.obj array_node = node.obj
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import numpy as np import numpy as np
cimport numpy as np cimport numpy as np
int64_array = np.ones((3, 2), dtype=np.int64)
def f(): def f():
""" """
...@@ -14,7 +15,7 @@ def f(): ...@@ -14,7 +15,7 @@ def f():
shape[1] 2 shape[1] 2
strides 16 8 strides 16 8
""" """
cdef np.ndarray x = np.ones((3, 2), dtype=np.int64) cdef np.ndarray x = int64_array
cdef int i cdef int i
cdef Py_ssize_t j, k cdef Py_ssize_t j, k
cdef char *p cdef char *p
...@@ -43,3 +44,11 @@ def f(): ...@@ -43,3 +44,11 @@ def f():
k = x.strides[1] k = x.strides[1]
print 'strides', j, k print 'strides', j, k
def test_non_namenode_attribute_access(obj):
"""
>>> test_non_namenode_attribute_access(int64_array)
data 1
"""
# Try casting, resulting in an AttributeNode with a TypeCastNode as object
# and 'data' as attribute
print "data", (<np.int64_t *> (<np.ndarray> obj).data)[0]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment