[pypy-commit] pypy default: tests and checks for sanity

fijal noreply at buildbot.pypy.org
Thu Sep 20 11:52:08 CEST 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: 
Changeset: r57400:9580af31450b
Date: 2012-09-20 11:51 +0200
http://bitbucket.org/pypy/pypy/changeset/9580af31450b/

Log:	tests and checks for sanity

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
@@ -63,6 +63,9 @@
         return space.wrap(loop.tostring(space, self))
 
     def getitem_filter(self, space, arr):
+        if len(arr.get_shape()) > 1:
+            raise OperationError(space.w_ValueError,
+                                 space.wrap("boolean index array should have 1 dimension"))
         if arr.get_size() > self.get_size():
             raise OperationError(space.w_ValueError,
                                  space.wrap("index out of range for array"))
@@ -71,6 +74,9 @@
         return loop.getitem_filter(res, self, arr)
 
     def setitem_filter(self, space, idx, val):
+        if len(idx.get_shape()) > 1:
+            raise OperationError(space.w_ValueError,
+                                 space.wrap("boolean index array should have 1 dimension"))
         if idx.get_size() > self.get_size():
             raise OperationError(space.w_ValueError,
                                  space.wrap("index out of range for array"))
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
@@ -1544,6 +1544,7 @@
         b = arange(10)
         assert (b[array([True, False, True])] == [0, 2]).all()
         raises(ValueError, "array([1, 2])[array([True, True, True])]")
+        raises(ValueError, "b[array([[True, False], [True, False]])]")
 
     def test_bool_array_index_setitem(self):
         from numpypy import arange, array


More information about the pypy-commit mailing list