Author: mattip <matti.pi...@gmail.com>
Branch: nditer-external_loop
Changeset: r74291:c3b9de259f37
Date: 2014-10-30 00:06 +0200
http://bitbucket.org/pypy/pypy/changeset/c3b9de259f37/

Log:    fix translation, code cleanup needed

diff --git a/pypy/module/micronumpy/concrete.py 
b/pypy/module/micronumpy/concrete.py
--- a/pypy/module/micronumpy/concrete.py
+++ b/pypy/module/micronumpy/concrete.py
@@ -449,7 +449,7 @@
                 strides.reverse()
                 backstrides.reverse()
                 new_shape.reverse()
-            return type(self)(self.start, strides, backstrides, new_shape,
+            return self.__class__(self.start, strides, backstrides, new_shape,
                               self, orig_array)
         new_strides = calc_new_strides(new_shape, self.get_shape(),
                                        self.get_strides(),
@@ -460,7 +460,7 @@
         new_backstrides = [0] * len(new_shape)
         for nd in range(len(new_shape)):
             new_backstrides[nd] = (new_shape[nd] - 1) * new_strides[nd]
-        return type(self)(self.start, new_strides, new_backstrides, new_shape,
+        return self.__class__(self.start, new_strides, new_backstrides, 
new_shape,
                           self, orig_array)
 
 
diff --git a/pypy/module/micronumpy/iterators.py 
b/pypy/module/micronumpy/iterators.py
--- a/pypy/module/micronumpy/iterators.py
+++ b/pypy/module/micronumpy/iterators.py
@@ -99,7 +99,7 @@
 class ArrayIter(object):
     _immutable_fields_ = ['contiguous', 'array', 'size', 'ndim_m1', 
'shape_m1[*]',
                           'strides[*]', 'backstrides[*]', 'factors[*]',
-                          'track_index', 'operand_type']
+                          'track_index', 'operand_type', 'slice_operand_type']
 
     track_index = True
 
@@ -116,6 +116,7 @@
         self.shape_m1 = [s - 1 for s in shape]
         self.strides = strides
         self.backstrides = backstrides
+        self.slice_operand_type = concrete.SliceArray
 
         ndim = len(shape)
         factors = [0] * ndim
@@ -243,39 +244,36 @@
     used with external loops, getitem and setitem return a SliceArray
     view into the original array
     '''
+    _immutable_fields_ = ['base', 'slice_shape[*]', 'slice_stride[*]', 
'slice_backstride[*]']
 
     def __init__(self, array, size, shape, strides, backstrides, slice_shape,
                  slice_stride, slice_backstride, op_flags, base):
         from pypy.module.micronumpy import concrete
         ArrayIter.__init__(self, array, size, shape, strides, backstrides, 
op_flags)
-        self.shape = shape[:]
         self.slice_shape = slice_shape
         self.slice_stride = slice_stride
         self.slice_backstride = slice_backstride
         self.base = base
         if op_flags.rw == 'r':
-            self.operand_type = concrete.NonWritableSliceArray
+            self.slice_operand_type = concrete.NonWritableSliceArray
         else:
-            self.operand_type = concrete.SliceArray
+            self.slice_operand_type = concrete.SliceArray
 
     def getitem(self, state):
+        # XXX cannot be called - must return a boxed value
+        assert False
+
+    def getitem_bool(self, state):
+        # XXX cannot be called - must return a boxed value
+        assert False
+
+    def setitem(self, state, elem):
+        # XXX cannot be called - must return a boxed value
+        assert False
+
+    def getoperand(self, state, base):
         assert state.iterator is self
-        impl = self.operand_type
+        impl = self.slice_operand_type
         arr = impl(state.offset, [self.slice_stride], [self.slice_backstride],
                    [self.slice_shape], self.array, self.base)
         return arr
-
-    def getitem_bool(self, state):
-        # XXX cannot be called
-        assert False
-
-    def setitem(self, state, elem):
-        assert state.iterator is self
-        impl = self.operand_type
-        slice = impl(state.offset, [self.slice_stride], 
[self.slice_backstride],
-                     [self.shape], self.array, self.base)
-        # TODO: implement
-        assert False
-
-    def getoperand(self, state, base):
-        return self.getitem(state)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to