summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt Smith <kwsmith1@wisc.edu>2009-08-09 18:28:12 -0500
committerKurt Smith <kwsmith1@wisc.edu>2009-08-09 18:28:12 -0500
commit331b21ea0ae35b8c94c3d3e797541d482a3695f9 (patch)
tree5cd0523476506e75c067a6d7eb6ace42376fd965
parentadc3b620a5d0488713e512aea8e8fcd8cda9f62c (diff)
downloadcython-331b21ea0ae35b8c94c3d3e797541d482a3695f9.tar.gz
stride/len bugfix to cython.array
-rw-r--r--Cython/Compiler/CythonScope.py8
-rw-r--r--tests/run/cythonarray.pyx4
2 files changed, 6 insertions, 6 deletions
diff --git a/Cython/Compiler/CythonScope.py b/Cython/Compiler/CythonScope.py
index 1bcf93321..a86182b56 100644
--- a/Cython/Compiler/CythonScope.py
+++ b/Cython/Compiler/CythonScope.py
@@ -392,21 +392,21 @@ cdef class array:
if mode == "fortran":
idx = 0; stride = 1
for dim in shape:
- self.strides[idx] = stride
+ self.strides[idx] = stride*itemsize
int_dim = <Py_ssize_t>dim
stride = stride * int_dim
idx += 1
assert idx == self.ndim
- self.len = stride * self.itemsize
+ self.len = stride * itemsize
elif mode == "c":
idx = self.ndim-1; stride = 1
for dim in reversed(shape):
- self.strides[idx] = stride
+ self.strides[idx] = stride*itemsize
int_dim = <Py_ssize_t>dim
stride = stride * int_dim
idx -= 1
assert idx == -1
- self.len = stride * self.itemsize
+ self.len = stride * itemsize
else:
raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
diff --git a/tests/run/cythonarray.pyx b/tests/run/cythonarray.pyx
index 780b918c9..0bf981698 100644
--- a/tests/run/cythonarray.pyx
+++ b/tests/run/cythonarray.pyx
@@ -10,10 +10,10 @@ from cython cimport array
def contiguity():
u'''
>>> contiguity()
- 3 1
+ 12 4
2 3
2
- 1 2
+ 4 8
2 3
2
'''