Author: Brian Kearns <[email protected]>
Branch: 
Changeset: r69237:fa985109fcb9
Date: 2014-02-21 04:08 -0500
http://bitbucket.org/pypy/pypy/changeset/fa985109fcb9/

Log:    handle another record coerce case

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
@@ -3497,6 +3497,11 @@
         for i in a.flat:
             assert tuple(i) == (True, False)
 
+        dt = np.dtype([('A', '<i8'), ('B', '<f8'), ('C', '<c16')])
+        b = np.array((999999, 1e+20, 1e+20+0j), dtype=dt)
+        a = np.array(b, copy=False, dtype=dt.descr)
+        assert tuple(a[()]) == (999999, 1e+20, 1e+20+0j)
+
 
 class AppTestPyPy(BaseNumpyAppTest):
     def setup_class(cls):
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -1870,6 +1870,7 @@
 
     @jit.unroll_safe
     def coerce(self, space, dtype, w_item):
+        from pypy.module.micronumpy.base import W_NDimArray
         if isinstance(w_item, interp_boxes.W_VoidBox):
             return w_item
         if w_item is not None:
@@ -1878,6 +1879,8 @@
                     raise OperationError(space.w_ValueError, space.wrap(
                         "size of tuple must match number of fields."))
                 items_w = space.fixedview(w_item)
+            elif isinstance(w_item, W_NDimArray) and w_item.is_scalar():
+                items_w = space.fixedview(w_item.get_scalar_value())
             else:
                 # XXX support initializing from readable buffers
                 items_w = [w_item]
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to