Commit daa49dd4 authored by Kurt Smith's avatar Kurt Smith Committed by Mark Florisson

set cython.array entry as used when imported.

parent ece0f48a
...@@ -543,6 +543,8 @@ def use_py2_buffer_functions(env): ...@@ -543,6 +543,8 @@ def use_py2_buffer_functions(env):
for e in scope.type_entries: for e in scope.type_entries:
t = e.type t = e.type
if t.is_extension_type: if t.is_extension_type:
if e.name == 'array' and not e.used:
continue
release = get = None release = get = None
for x in t.scope.pyfunc_entries: for x in t.scope.pyfunc_entries:
if x.name == u"__getbuffer__": get = x.func_cname if x.name == u"__getbuffer__": get = x.func_cname
......
...@@ -5808,6 +5808,7 @@ class FromCImportStatNode(StatNode): ...@@ -5808,6 +5808,7 @@ class FromCImportStatNode(StatNode):
if entry: if entry:
if kind and not self.declaration_matches(entry, kind): if kind and not self.declaration_matches(entry, kind):
entry.redeclared(pos) entry.redeclared(pos)
entry.used = 1
else: else:
if kind == 'struct' or kind == 'union': if kind == 'struct' or kind == 'union':
entry = module_scope.declare_struct_or_union(name, entry = module_scope.declare_struct_or_union(name,
......
from cython cimport array # from cython cimport array
# cimport cython.array as array
cimport cython as cy
# array = cython.array
def contiguity(): def contiguity():
''' '''
...@@ -10,13 +13,13 @@ def contiguity(): ...@@ -10,13 +13,13 @@ def contiguity():
2 3 2 3
2 2
''' '''
cdef array cvarray = array(shape=(2,3), itemsize=sizeof(int), format="i", mode='c') cdef cy.array cvarray = cy.array(shape=(2,3), itemsize=sizeof(int), format="i", mode='c')
assert cvarray.len == 2*3*sizeof(int) assert cvarray.len == 2*3*sizeof(int)
assert cvarray.itemsize == sizeof(int) assert cvarray.itemsize == sizeof(int)
print cvarray.strides[0], cvarray.strides[1] print cvarray.strides[0], cvarray.strides[1]
print cvarray.shape[0], cvarray.shape[1] print cvarray.shape[0], cvarray.shape[1]
print cvarray.ndim print cvarray.ndim
cdef array farray = array(shape=(2,3), itemsize=sizeof(int), format="i", mode='fortran') cdef cy.array farray = cy.array(shape=(2,3), itemsize=sizeof(int), format="i", mode='fortran')
assert farray.len == 2*3*sizeof(int) assert farray.len == 2*3*sizeof(int)
assert farray.itemsize == sizeof(int) assert farray.itemsize == sizeof(int)
print farray.strides[0], farray.strides[1] print farray.strides[0], farray.strides[1]
...@@ -28,19 +31,19 @@ def acquire(): ...@@ -28,19 +31,19 @@ def acquire():
>>> acquire() >>> acquire()
''' '''
cdef object[int, ndim=1, mode="c"] buf1d = \ cdef object[int, ndim=1, mode="c"] buf1d = \
array(shape=(10,), itemsize=sizeof(int), format='i', mode='c') cy.array(shape=(10,), itemsize=sizeof(int), format='i', mode='c')
cdef object[int, ndim=2, mode="c"] buf2d = \ cdef object[int, ndim=2, mode="c"] buf2d = \
array(shape=(10,10), itemsize=sizeof(int), format='i') cy.array(shape=(10,10), itemsize=sizeof(int), format='i')
cdef object[unsigned long, ndim=3, mode='fortran'] buf3d = \ cdef object[unsigned long, ndim=3, mode='fortran'] buf3d = \
array(shape=(1,2,3), itemsize=sizeof(unsigned long), format='L', mode='fortran') cy.array(shape=(1,2,3), itemsize=sizeof(unsigned long), format='L', mode='fortran')
cdef object[long double, ndim=3, mode='fortran'] bufld = \ cdef object[long double, ndim=3, mode='fortran'] bufld = \
array(shape=(1,2,3), itemsize=sizeof(long double), format='g', mode='fortran') cy.array(shape=(1,2,3), itemsize=sizeof(long double), format='g', mode='fortran')
def full_or_strided(): def full_or_strided():
''' '''
>>> full_or_strided() >>> full_or_strided()
''' '''
cdef object[float, ndim=2, mode='full'] fullbuf = \ cdef object[float, ndim=2, mode='full'] fullbuf = \
array(shape=(10,10), itemsize=sizeof(float), format='f', mode='c') cy.array(shape=(10,10), itemsize=sizeof(float), format='f', mode='c')
cdef object[long long int, ndim=3, mode='strided'] stridedbuf = \ cdef object[long long int, ndim=3, mode='strided'] stridedbuf = \
array(shape=(1,2,3), itemsize=sizeof(long long int), format='q', mode='fortran') cy.array(shape=(1,2,3), itemsize=sizeof(long long int), format='q', mode='fortran')
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