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):
return node
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):
array_node = node.obj
......
......@@ -4,6 +4,7 @@
import numpy as np
cimport numpy as np
int64_array = np.ones((3, 2), dtype=np.int64)
def f():
"""
......@@ -14,7 +15,7 @@ def f():
shape[1] 2
strides 16 8
"""
cdef np.ndarray x = np.ones((3, 2), dtype=np.int64)
cdef np.ndarray x = int64_array
cdef int i
cdef Py_ssize_t j, k
cdef char *p
......@@ -23,7 +24,7 @@ def f():
with nogil:
i = x.ndim
print 'ndim', i
with nogil:
p = x.data
print 'data', (<np.int64_t*>p)[0]
......@@ -42,4 +43,12 @@ def f():
j = x.strides[0]
k = x.strides[1]
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