Simple fix for #155
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Tue, 28 Apr 2009 13:02:09 +0000 (15:02 +0200)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Tue, 28 Apr 2009 13:02:09 +0000 (15:02 +0200)
Cython/Compiler/ExprNodes.py
Cython/Compiler/Visitor.py
tests/run/numpy_bufacc_T155.pyx [new file with mode: 0644]

index b8d41ec04b65de1f9b18dbbdb2e82dcaf99a06d6..c1bc8ea4bc5509c46bb2d27a7de458a4b2769651 100644 (file)
@@ -1705,8 +1705,6 @@ class IndexNode(ExprNode):
             if self.indices:
                 indices = self.indices
             else:
-                # On cloning, indices is cloned. Otherwise, unpack index into indices
-                assert not isinstance(self.index, CloneNode)
                 if isinstance(self.index, TupleNode):
                     indices = self.index.args
                 else:
@@ -1719,6 +1717,9 @@ class IndexNode(ExprNode):
                     if not x.type.is_int:
                         buffer_access = False
 
+        # On cloning, indices is cloned. Otherwise, unpack index into indices
+        assert not (buffer_access and isinstance(self.index, CloneNode))
+
         if buffer_access:
             self.indices = indices
             self.index = None
index c7739f8d6554efb7ecab1007366657e430f8c739..6e40d858de3ad3c367d6bc71eea2996209f50d2d 100644 (file)
@@ -150,6 +150,7 @@ class TreeVisitor(BasicVisitor):
         except Errors.CompileError:
             raise
         except Exception, e:
+            raise
             import sys
             trace = ['']
             for parent, attribute, index in self.access_path:
diff --git a/tests/run/numpy_bufacc_T155.pyx b/tests/run/numpy_bufacc_T155.pyx
new file mode 100644 (file)
index 0000000..7d0bb6b
--- /dev/null
@@ -0,0 +1,15 @@
+"""
+>>> myfunc()
+0.5
+"""
+
+cimport numpy as np
+import numpy as np
+
+def myfunc():
+    cdef np.ndarray[float, ndim=2] A = np.ones((1,1), dtype=np.float32)
+    cdef int i
+
+    for i from 0 <= i < A.shape[0]:
+        A[i, :] /= 2
+    return A[0,0]