[pypy-commit] pypy fix-1674: Add test case: dual indexing integer array+selection

Vincent Legoll pypy.commits at gmail.com
Tue Dec 29 08:06:58 EST 2015


Author: Vincent Legoll <vincent.legoll at idgrilles.fr>
Branch: fix-1674
Changeset: r81476:13b371329caa
Date: 2015-12-20 23:11 +0100
http://bitbucket.org/pypy/pypy/changeset/13b371329caa/

Log:	Add test case: dual indexing integer array+selection

diff --git a/pypy/module/micronumpy/test/test_ndarray.py b/pypy/module/micronumpy/test/test_ndarray.py
--- a/pypy/module/micronumpy/test/test_ndarray.py
+++ b/pypy/module/micronumpy/test/test_ndarray.py
@@ -3264,6 +3264,21 @@
         # Assume False for missing elements of the bool index array
         assert data[0, m] == array([ 0.,  2.])
 
+    def test_dual_indexing_selecting(self):
+        from numpy import arange, array
+        data = arange(15).reshape(5, 3) * 1.0
+        assert (data == array([[  0.,   1.,   2.],
+                               [  3.,   4.,   5.],
+                               [  6.,   7.,   8.],
+                               [  9.,  10.,  11.],
+                               [ 12.,  13.,  14.]])).all()
+        m = array([3, 4, 1])
+        assert (data[m] == array([[  9.,  10.,  11.],
+                                  [ 12.,  13.,  14.],
+                                  [  3.,   4.,   5.]])).all()
+        assert data[m, 0] == array([ 9., 12., 3.])
+        assert data[array([1,3,4,1]), 1] == array([4., 10., 13., 4.])
+
     def test_ravel(self):
         from numpy import arange
         assert (arange(3).ravel() == arange(3)).all()


More information about the pypy-commit mailing list