Author: mattip <matti.pi...@gmail.com>
Branch: 
Changeset: r77793:d7275799e550
Date: 2015-06-03 00:43 +0300
http://bitbucket.org/pypy/pypy/changeset/d7275799e550/

Log:    test, fix record array creation with int value broadcast to internal
        array

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
@@ -1138,6 +1138,10 @@
         assert b.base is None
         assert b.dtype.fields['a'][1] == 0
         assert b['a'] == -999
+        a = np.array(('N/A', 1e+20, 1e+20, 999999),
+                     dtype=[('name', '|S4'), ('x', '<f8'), 
+                            ('y', '<f8'), ('block', '<i8', (2, 3))])
+        assert (a['block'] == 999999).all()
 
     def test_create_from_dict(self):
         import numpy as np
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
@@ -20,7 +20,7 @@
      cast_gcref_to_instance
 from rpython.rtyper.lltypesystem import lltype, rffi, llmemory
 from rpython.tool.sourcetools import func_with_new_name
-from pypy.module.micronumpy import boxes
+from pypy.module.micronumpy import boxes, support
 from pypy.module.micronumpy.concrete import SliceArray, VoidBoxStorage, 
V_OBJECTSTORE
 from pypy.module.micronumpy.strides import calc_strides
 from . import constants as NPY
@@ -2265,10 +2265,12 @@
     def _coerce(self, space, arr, ofs, dtype, w_items, shape):
         # TODO: Make sure the shape and the array match
         from pypy.module.micronumpy.descriptor import W_Dtype
-        if w_items is not None:
+        if w_items is None:
+            items_w = [None] * shape[0]
+        elif support.issequence_w(space, w_items):
             items_w = space.fixedview(w_items)
         else:
-            items_w = [None] * shape[0]
+            items_w = [w_items] * shape[0]
         subdtype = dtype.subdtype
         assert isinstance(subdtype, W_Dtype)
         itemtype = subdtype.itemtype
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to