Author: mattip
Branch: numppy-flatitter
Changeset: r51505:23731c70eb07
Date: 2012-01-19 22:44 +0200
http://bitbucket.org/pypy/pypy/changeset/23731c70eb07/

Log:    correct test for missing == operator, un-skip failing test

diff --git a/pypy/module/micronumpy/REVIEW b/pypy/module/micronumpy/REVIEW
--- a/pypy/module/micronumpy/REVIEW
+++ b/pypy/module/micronumpy/REVIEW
@@ -1,10 +1,9 @@
 * I think we should wait for indexing-by-arrays-2, since this would clean up
   the iterator interface
 
-* I commited a failing test, it seems the entire approach is pretty doomed.
-  Instead we should keep the parent iterator (and not create a OneDim one)
-
 * For getitem, we need to reuse parent getitem, but with some hook
   that recomputes indexes. That hook would be used for any sort of access,
   be it slices or be it integers, but in general I would like to avoid code
-  duplication, since the indexing is getting slowly fairly complex.
\ No newline at end of file
+  duplication, since the indexing is getting slowly fairly complex.
+
+* iterating over a transposed array still fails.
diff --git a/pypy/module/micronumpy/interp_numarray.py 
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -1325,11 +1325,15 @@
     def descr_iter(self):
         return self
 
+    def descr_index(self, space):
+        return space.wrap(self.iter.offset)
+
 W_FlatIterator.typedef = TypeDef(
     'flatiter',
     next = interp2app(W_FlatIterator.descr_next),
     __iter__ = interp2app(W_FlatIterator.descr_iter),
     __getitem__ = interp2app(BaseArray.descr_getitem),
     __setitem__ = interp2app(BaseArray.descr_setitem),
+    index = GetSetProperty(W_FlatIterator.descr_index),
 )
 W_FlatIterator.acceptable_as_base_class = False
diff --git a/pypy/module/micronumpy/test/test_numarray.py 
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -1308,16 +1308,22 @@
         assert b[-2] == 8
         raises(IndexError, "b[11]")
         raises(IndexError, "b[-11]")
+        assert b.index == 3
 
     def test_flatiter_view(self):
         from _numpypy import arange
         a = arange(10).reshape(5, 2)
-        assert (a[::2].flat == [0, 1, 4, 5, 8, 9])
+        #no == yet.
+        # a[::2].flat == [0, 1, 4, 5, 8, 9]
+        isequal = True
+        for y,z in zip(a[::2].flat, [0, 1, 4, 5, 8, 9]):
+            if y != z:
+                isequal = False
+        assert isequal == True
 
     def test_flatiter_transpose(self):
         from _numpypy import arange
         a = arange(10)
-        skip('out-of-order transformations do not work yet')
         assert a.reshape(2,5).T.flat[3] == 6
 
     def test_slice_copy(self):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to