[pypy-commit] pypy default: fix record array scalar creation

bdkearns noreply at buildbot.pypy.org
Sat Dec 21 09:18:45 CET 2013


Author: Brian Kearns <bdkearns at gmail.com>
Branch: 
Changeset: r68527:fed3e23427f5
Date: 2013-12-21 02:14 -0500
http://bitbucket.org/pypy/pypy/changeset/fed3e23427f5/

Log:	fix record array scalar creation

diff --git a/pypy/module/micronumpy/strides.py b/pypy/module/micronumpy/strides.py
--- a/pypy/module/micronumpy/strides.py
+++ b/pypy/module/micronumpy/strides.py
@@ -69,9 +69,11 @@
     return True
 
 def find_shape_and_elems(space, w_iterable, dtype):
+    is_rec_type = dtype is not None and dtype.is_record_type()
+    if is_rec_type and is_single_elem(space, w_iterable, is_rec_type):
+        return [], [w_iterable]
     shape = [space.len_w(w_iterable)]
     batch = space.listview(w_iterable)
-    is_rec_type = dtype is not None and dtype.is_record_type()
     while True:
         if not batch:
             return shape[:], []
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
@@ -3100,6 +3100,9 @@
 
     def test_creation_and_repr(self):
         from numpypy import array
+        a = array((1, 2), dtype=[('x', int), ('y', float)])
+        assert a.shape == ()
+        assert repr(a[()]) == '(1, 2.0)'
         a = array([(1, 2), (3, 4)], dtype=[('x', int), ('y', float)])
         assert repr(a[0]) == '(1, 2.0)'
 


More information about the pypy-commit mailing list