cimport python_dict as asadf, python_exc, cython as cy
-def e(object[int, 2] buf):
+def e(object[int, ndim=2] buf):
print buf[3, 2] # no bc
@cy.boundscheck(False)
-def f(object[int, 2] buf):
+def f(object[int, ndim=2] buf):
print buf[3, 2] # no bc
@cy.boundscheck(True)
-def g(object[int, 2] buf):
+def g(object[int, ndim=2] buf):
# The below line should have no meaning
# boundscheck = False
# even if the above line doesn't follow indentation.
print buf[3, 2] # bc
-def h(object[int, 2] buf):
+def h(object[int, ndim=2] buf):
print buf[3, 2] # no bc
with cy.boundscheck(True):
print buf[3,2] # bc
"""
The challenge here is just compilation.
"""
- cdef object[int, 2] buf
+ cdef object[int, ndim=2] buf
def printbuf():
"""
Just compilation.
"""
- cdef object[int, 2] buf
+ cdef object[int, ndim=2] buf
print buf
@testcase
# Getting items and index bounds checking
#
@testcase
-def get_int_2d(object[int, 2] buf, int i, int j):
+def get_int_2d(object[int, ndim=2] buf, int i, int j):
"""
>>> get_int_2d(C, 1, 1)
acquired C
return buf[i, j]
@testcase
-def get_int_2d_uintindex(object[int, 2] buf, unsigned int i, unsigned int j):
+def get_int_2d_uintindex(object[int, ndim=2] buf, unsigned int i, unsigned int j):
"""
Unsigned indexing:
>>> get_int_2d_uintindex(C, 0, 0)
return buf[i, j]
@testcase
-def set_int_2d(object[int, 2] buf, int i, int j, int value):
+def set_int_2d(object[int, ndim=2] buf, int i, int j, int value):
"""
Uses get_int_2d to read back the value afterwards. For pure
unit test, one should support reading in MockBuffer instead.
"""
@testcase
-def ndim1(object[int, 2] buf):
+def ndim1(object[int, ndim=2] buf):
"""
>>> ndim1(IntMockBuffer("A", range(3)))
Traceback (most recent call last):
>>> [str(x) for x in R.recieved_flags] # Works in both py2 and py3
['FORMAT', 'INDIRECT', 'ND', 'STRIDES']
"""
- cdef object[unsigned short int, 3] buf = obj
+ cdef object[unsigned short int, ndim=3] buf = obj
print buf[2, 2, 1]
@testcase
>>> [str(x) for x in R.recieved_flags] # Py2/3
['FORMAT', 'INDIRECT', 'ND', 'STRIDES', 'WRITABLE']
"""
- cdef object[unsigned short int, 3] buf = obj
+ cdef object[unsigned short int, ndim=3] buf = obj
buf[2, 2, 1] = 23
@testcase
-def strided(object[int, 1, 'strided'] buf):
+def strided(object[int, ndim=1, mode='strided'] buf):
"""
>>> A = IntMockBuffer("A", range(4))
>>> strided(A)
released A
"""
# should make shape builtin
- cdef object[int, 2] buf
+ cdef object[int, ndim=2] buf
buf = o
cdef int i, j
for i in range(shape[0]):
...
TypeError: Cannot convert int to bufaccess.IntMockBuffer
"""
- cdef IntMockBuffer[int, 1] buf = obj
+ cdef IntMockBuffer[int, ndim=1] buf = obj
@testcase
-def typedbuffer2(IntMockBuffer[int, 1] obj):
+def typedbuffer2(IntMockBuffer[int, ndim=1] obj):
"""
>>> typedbuffer2(IntMockBuffer("A", range(10)))
acquired A
# Test __cythonbufferdefaults__
#
@testcase
-def bufdefaults1(IntStridedMockBuffer[int, 1] buf):
+def bufdefaults1(IntStridedMockBuffer[int, ndim=1] buf):
"""
For IntStridedMockBuffer, mode should be
"strided" by defaults which should show