Author: Matti Picus <[email protected]>
Branch: numpypy-nditer
Changeset: r70670:873c97659fd1
Date: 2014-04-16 05:57 +0300
http://bitbucket.org/pypy/pypy/changeset/873c97659fd1/

Log:    disable 'external_loop' and 'buffering' flags pending future
        refactor, fix translation

diff --git a/pypy/module/micronumpy/nditer.py b/pypy/module/micronumpy/nditer.py
--- a/pypy/module/micronumpy/nditer.py
+++ b/pypy/module/micronumpy/nditer.py
@@ -155,8 +155,12 @@
                     'expected string or Unicode object, %s found' % typename))
         item = space.str_w(w_item)
         if item == 'external_loop':
+            raise OperationError(space.w_NotImplementedError, space.wrap(
+                'nditer external_loop not implemented yet'))
             nditer.external_loop = True
         elif item == 'buffered':
+            raise OperationError(space.w_NotImplementedError, space.wrap(
+                'nditer buffered not implemented yet'))
             # For numpy compatability
             nditer.buffered = True
         elif item == 'c_index':
@@ -307,7 +311,7 @@
                                                     get_readwrite_slice)
                     self.op_flags[i].allocate = True
                     continue
-                if self.op_flags[i] == 'w':
+                if self.op_flags[i].rw == 'w':
                     continue
                 out_dtype = ufuncs.find_binop_result_dtype(space,
                                                 self.seq[i].get_dtype(), 
out_dtype)
@@ -348,7 +352,7 @@
                     l = axis_len
                 elif axis_len != l:
                     raise OperationError(space.w_ValueError, space.wrap("Each 
entry of op_axes must have the same size"))
-                self.op_axes.append([space.int_w(x) if not space.is_none(x) 
else space.w_None for x in space.listview(w_axis)])
+                self.op_axes.append([space.int_w(x) if not space.is_none(x) 
else -1 for x in space.listview(w_axis)])
         if l == -1:
             raise OperationError(space.w_ValueError, space.wrap("If op_axes is 
provided, at least one list of axes must be contained within it"))
         raise Exception('xxx TODO')
@@ -441,7 +445,7 @@
         l_w = []
         for op in self.seq:
             l_w.append(op.descr_view(space))
-        return space.newlist(l_w)            
+        return space.newlist(l_w)
 
     def descr_get_dtypes(self, space):
         res = [None] * len(self.seq)
diff --git a/pypy/module/micronumpy/test/test_nditer.py 
b/pypy/module/micronumpy/test/test_nditer.py
--- a/pypy/module/micronumpy/test/test_nditer.py
+++ b/pypy/module/micronumpy/test/test_nditer.py
@@ -38,6 +38,10 @@
     def test_external_loop(self):
         from numpy import arange, nditer, array
         a = arange(24).reshape(2, 3, 4)
+        import sys
+        if '__pypy__' in sys.builtin_module_names:
+            raises(NotImplementedError, nditer, a, flags=['external_loop'])
+            skip('nditer external_loop not implmented')
         r = []
         n = 0
         for x in nditer(a, flags=['external_loop']):
@@ -115,13 +119,17 @@
             it[0] = it.multi_index[1] - it.multi_index[0]
             it.iternext()
         assert (a == [[0, 1, 2], [-1, 0, 1]]).all()
-        b = zeros((2, 3))
-        exc = raises(ValueError, nditer, b, flags=['c_index', 'external_loop'])
-        assert str(exc.value).startswith("Iterator flag EXTERNAL_LOOP cannot")
+        # b = zeros((2, 3))
+        # exc = raises(ValueError, nditer, b, flags=['c_index', 
'external_loop'])
+        # assert str(exc.value).startswith("Iterator flag EXTERNAL_LOOP 
cannot")
 
     def test_buffered(self):
         from numpy import arange, nditer, array
         a = arange(6).reshape(2,3)
+        import sys
+        if '__pypy__' in sys.builtin_module_names:
+            raises(NotImplementedError, nditer, a, flags=['buffered'])
+            skip('nditer buffered not implmented')
         r = []
         for x in nditer(a, flags=['external_loop', 'buffered'], order='F'):
             r.append(x)
@@ -189,6 +197,10 @@
 
     def test_outarg(self):
         from numpy import nditer, zeros, arange
+        import sys
+        if '__pypy__' in sys.builtin_module_names:
+            raises(NotImplementedError, nditer, [1, 2], 
flags=['external_loop'])
+            skip('nditer external_loop not implmented')
 
         def square1(a):
             it = nditer([a, None])
@@ -215,6 +227,10 @@
     def test_outer_product(self):
         from numpy import nditer, arange
         a = arange(3)
+        import sys
+        if '__pypy__' in sys.builtin_module_names:
+            raises(NotImplementedError, nditer, a, flags=['external_loop'])
+            skip('nditer external_loop not implmented')
         b = arange(8).reshape(2,4)
         it = nditer([a, b, None], flags=['external_loop'],
                     op_axes=[[0, -1, -1], [-1, 0, 1], None])
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to