Author: Brian Kearns <[email protected]>
Branch:
Changeset: r68518:b29074fcba99
Date: 2013-12-20 17:15 -0500
http://bitbucket.org/pypy/pypy/changeset/b29074fcba99/
Log: fix init of scalar w subarrays
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
@@ -3227,11 +3227,14 @@
def test_subarrays(self):
from numpypy import dtype, array, zeros
-
d = dtype([("x", "int", 3), ("y", "float", 5)])
+
+ a = zeros((), dtype=d)
+ #assert a['x'].shape == (3,)
+ #assert (a['x'] == [0, 0, 0]).all()
+
a = array([([1, 2, 3], [0.5, 1.5, 2.5, 3.5, 4.5]),
([4, 5, 6], [5.5, 6.5, 7.5, 8.5, 9.5])], dtype=d)
-
for v in ['x', u'x', 0, -2]:
assert (a[0][v] == [1, 2, 3]).all()
assert (a[1][v] == [4, 5, 6]).all()
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
@@ -1735,6 +1735,8 @@
def _coerce(self, space, arr, ofs, dtype, w_items, shape):
# TODO: Make sure the shape and the array match
from interp_dtype import W_Dtype
+ if w_items is None:
+ w_items = space.newtuple([None] * shape[0])
items_w = space.fixedview(w_items)
subdtype = dtype.subdtype
assert isinstance(subdtype, W_Dtype)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit