[pypy-commit] pypy dtypes-compatability: create dtype from nested lists

mattip noreply at buildbot.pypy.org
Fri Jul 10 09:10:12 CEST 2015


Author: mattip <matti.picus at gmail.com>
Branch: dtypes-compatability
Changeset: r78517:b207cd06e2b1
Date: 2015-07-08 06:50 +0300
http://bitbucket.org/pypy/pypy/changeset/b207cd06e2b1/

Log:	create dtype from nested lists

diff --git a/pypy/module/micronumpy/descriptor.py b/pypy/module/micronumpy/descriptor.py
--- a/pypy/module/micronumpy/descriptor.py
+++ b/pypy/module/micronumpy/descriptor.py
@@ -733,8 +733,12 @@
         return descr__new__(space, space.gettypefor(W_Dtype),
                             space.getitem(w_lst, space.wrap(0)), align=alignment>0)
     else:
-        return dtype_from_list(space, w_lst, True, alignment)
-
+        try:
+            return dtype_from_list(space, w_lst, True, alignment)
+        except OperationError as e:
+            if e.match(space, space.w_TypeError):
+                return dtype_from_list(space, w_lst, False, alignment)
+            raise
 
 def _check_for_commastring(s):
     if s[0] in string.digits or s[0] in '<>=|' and s[1] in string.digits:
diff --git a/pypy/module/micronumpy/test/test_dtypes.py b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -1325,7 +1325,6 @@
         assert dt.itemsize == 8
         assert dt.alignment == 4
         # Nesting should preserve that alignment
-        print '......'
         dt1 = np.dtype([('f0', 'i4'),
                        ('f1', [('f1', 'i1'), ('f2', 'i4'), ('f3', 'i1')]),
                        ('f2', 'i1')], align=True)
@@ -1343,6 +1342,7 @@
                        'f2': ('i1', 16)}, align=True)
         assert dt3.itemsize == 20
         assert dt1 == dt2
+        print '+++++++++++++++++'
         assert dt2 == dt3
         # Nesting should preserve packing
         dt1 = np.dtype([('f0', 'i4'),


More information about the pypy-commit mailing list