Author: Matti Picus <[email protected]>
Branch: numpy-subarrays
Changeset: r63997:756280f0295a
Date: 2013-05-12 01:04 +0300
http://bitbucket.org/pypy/pypy/changeset/756280f0295a/

Log:    handle non-sequence shape specifiers

diff --git a/pypy/module/micronumpy/interp_dtype.py 
b/pypy/module/micronumpy/interp_dtype.py
--- a/pypy/module/micronumpy/interp_dtype.py
+++ b/pypy/module/micronumpy/interp_dtype.py
@@ -286,8 +286,10 @@
     for w_elem in lst_w:
         size = 1
         w_shape = space.newtuple([])
-        if space.len_w(w_elem) == 3:
+        if space.len_w(w_elem) >2:
             w_shape = space.getitem(w_elem, space.wrap(2))
+            if not base.issequence_w(space, w_shape):
+                w_shape = space.newtuple([w_shape,])
         w_fldname = space.getitem(w_elem, space.wrap(0))
         w_flddesc = space.getitem(w_elem, space.wrap(1))
         subdtype = descr__new__(space, space.gettypefor(W_Dtype), w_flddesc, 
w_shape=w_shape)
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
@@ -800,6 +800,9 @@
         assert "y" in keys
         assert d["x"].shape == (2,)
         assert d["x"].itemsize == 16
+        e = dtype([("x", "float", 2), ("y", "int", 2)])
+        assert e.fields.keys() == keys
+        assert e['x'].shape == (2,)
 
 
 class AppTestNotDirect(BaseNumpyAppTest):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to