Author: Matti Picus <[email protected]>
Branch: indexing-by-array
Changeset: r62405:2688a8fd8e04
Date: 2013-03-18 13:21 -0700
http://bitbucket.org/pypy/pypy/changeset/2688a8fd8e04/

Log:    tests segfault

diff --git a/pypy/module/micronumpy/arrayimpl/scalar.py 
b/pypy/module/micronumpy/arrayimpl/scalar.py
--- a/pypy/module/micronumpy/arrayimpl/scalar.py
+++ b/pypy/module/micronumpy/arrayimpl/scalar.py
@@ -38,7 +38,7 @@
     def get_strides(self):
         return []
 
-    def create_iter(self, shape=None):
+    def create_iter(self, shape=None, backward_broadcast=False):
         return ScalarIterator(self)
 
     def get_scalar_value(self):
diff --git a/pypy/module/micronumpy/interp_flatiter.py 
b/pypy/module/micronumpy/interp_flatiter.py
--- a/pypy/module/micronumpy/interp_flatiter.py
+++ b/pypy/module/micronumpy/interp_flatiter.py
@@ -19,7 +19,7 @@
     def get_shape(self):
         return self.shape
 
-    def create_iter(self, shape=None):
+    def create_iter(self, shape=None, backward_broadcast=False):
         assert isinstance(self.base(), W_NDimArray)
         return self.base().create_iter()
 
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
@@ -79,7 +79,12 @@
             raise OperationError(space.w_ValueError,
                                  space.wrap("index out of range for array"))
         size = loop.count_all_true(arr)
-        res_shape = [size] + self.get_shape()[1:]
+        print 'size',size
+        if len(arr.get_shape()) == 1:
+            res_shape = [size] + self.get_shape()[1:]
+        else:
+            res_shape = [size]
+        print 'res_shape',res_shape
         res = W_NDimArray.from_shape(res_shape, self.get_dtype())
         return loop.getitem_filter(res, self, arr)
 
diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/micronumpy/loop.py
--- a/pypy/module/micronumpy/loop.py
+++ b/pypy/module/micronumpy/loop.py
@@ -300,7 +300,9 @@
 
 def getitem_filter(res, arr, index):
     res_iter = res.create_iter()
-    index_iter = index.create_iter(arr.get_shape(), backward_broadcast=True)
+    print 'xxx'
+    index_iter = index.create_iter(arr.get_shape(), backward_broadcast=False)
+    print 'yyy'
     arr_iter = arr.create_iter()
     shapelen = len(arr.get_shape())
     arr_dtype = arr.get_dtype()
@@ -311,6 +313,7 @@
                                               index_dtype=index_dtype,
                                               arr_dtype=arr_dtype,
                                               )
+        print 'res,arr,index', res_iter.offset, arr_iter.offset, 
index_iter.offset, index_iter.getitem_bool()
         if index_iter.getitem_bool():
             res_iter.setitem(arr_iter.getitem())
             res_iter.next()
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
@@ -1595,7 +1595,7 @@
         assert (zeros(1)[[]] == []).all()
 
     def test_int_array_index_setitem(self):
-        from numpypy import arange, zeros
+        from numpypy import arange, zeros, array
         a = arange(10)
         a[[3, 2, 1, 5]] = zeros(4, dtype=int)
         assert (a == [0, 0, 0, 0, 4, 0, 6, 7, 8, 9]).all()
@@ -2155,15 +2155,26 @@
     def test_compress(self):
         from numpypy import arange, array
         a = arange(10)
+        print 0
         assert (a.compress([True, False, True]) == [0, 2]).all()
+        print 1
         assert (a.compress([1, 0, 13]) == [0, 2]).all()
+        print 2
+        assert (a.compress([1, 0, 13]) == [0, 2]).all()
+        print '2a'
         assert (a.compress([1, 0, 13.5]) == [0, 2]).all()
+        print 3
         assert (a.compress(array([1, 0, 13.5], dtype='>f4')) == [0, 2]).all()
+        print 4
         assert (a.compress(array([1, 0, 13.5], dtype='<f4')) == [0, 2]).all()
+        print 5
         assert (a.compress([1, -0-0j, 1.3+13.5j]) == [0, 2]).all()
+        print 6
         a = arange(10).reshape(2, 5)
         assert (a.compress([True, False, True]) == [0, 2]).all()
+        print 7
         raises((IndexError, ValueError), "a.compress([1] * 100)")
+        print 8
 
     def test_item(self):
         from numpypy import array
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to