Author: mattip <[email protected]>
Branch: numpy-fixes
Changeset: r76958:d7e26a6bffd3
Date: 2015-04-30 22:09 +0300
http://bitbucket.org/pypy/pypy/changeset/d7e26a6bffd3/

Log:    test, fix creation of record array with ndarray data

diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/micronumpy/loop.py
--- a/pypy/module/micronumpy/loop.py
+++ b/pypy/module/micronumpy/loop.py
@@ -209,7 +209,7 @@
     while not target_iter.done(target_state):
         setslice_driver.jit_merge_point(shapelen=shapelen, dtype=dtype)
         val = source_iter.getitem(source_state)
-        if dtype.is_str_or_unicode():
+        if dtype.is_str_or_unicode() or dtype.is_record():
             val = dtype.coerce(space, val)
         else:
             val = val.convert_to(space, dtype)
diff --git a/pypy/module/micronumpy/test/test_ndarray.py 
b/pypy/module/micronumpy/test/test_ndarray.py
--- a/pypy/module/micronumpy/test/test_ndarray.py
+++ b/pypy/module/micronumpy/test/test_ndarray.py
@@ -3838,6 +3838,14 @@
                    ([4, 5, 6], [5.5, 6.5, 7.5, 8.5, 9.5])], dtype=d)
 
         assert len(list(a[0])) == 2
+        
+        mdtype = dtype([('a', bool), ('b', bool), ('c', bool)])
+        a = array([0, 0, 0, 1, 1])
+        # this creates a value of (x, x, x) in b for each x in a
+        b = array(a, dtype=mdtype)
+        assert b.shape == a.shape
+        c = array([(x, x, x) for x in [0, 0, 0, 1, 1]], dtype=mdtype)
+        assert (b == c).all()
 
     def test_3d_record(self):
         from numpy import dtype, array
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to