[pypy-commit] pypy numpy-subarrays: Add a test for multidimensional subarrays

rguillebert noreply at buildbot.pypy.org
Fri May 17 17:02:49 CEST 2013


Author: Romain Guillebert <romain.py at gmail.com>
Branch: numpy-subarrays
Changeset: r64265:b2014e32f383
Date: 2013-05-17 17:02 +0200
http://bitbucket.org/pypy/pypy/changeset/b2014e32f383/

Log:	Add a test for multidimensional subarrays

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
@@ -2715,7 +2715,11 @@
         a[0]["x"][0] = 200
         assert a[0]["x"][0] == 200
 
-        assert len(list(a[0])) == 2
+        d = dtype([("x", "int", (2, 3))])
+        a = array([([[1, 2, 3], [4, 5, 6]],)], dtype=d)
+
+        assert (a[0]["x"] == [[1, 2, 3], [4, 5, 6]]).all()
+        assert (a[0]["x"][0] == [1, 2, 3]).all()
 
         d = dtype((float, (10, 10)))
         a = zeros((3,3), dtype=d)
@@ -2725,6 +2729,14 @@
         assert (a[0, 0, 0] == 500).all()
         assert a[0, 0, 0].shape == (10,)
 
+    def test_list_record(self):
+        from numpypy import dtype, array
+
+        d = dtype([("x", "int", 3), ("y", "float", 5)])
+        a = array([([1, 2, 3], [0.5, 1.5, 2.5, 3.5, 4.5]), ([4, 5, 6], [5.5, 6.5, 7.5, 8.5, 9.5])], dtype=d)
+
+        assert len(list(a[0])) == 2
+
 class AppTestPyPy(BaseNumpyAppTest):
     def setup_class(cls):
         if option.runappdirect and '__pypy__' not in sys.builtin_module_names:


More information about the pypy-commit mailing list