[pypy-commit] pypy matrixmath-reshape-merge: allow empty shape for Scalars
mattip
noreply at buildbot.pypy.org
Sat Dec 3 19:41:13 CET 2011
Author: mattip
Branch: matrixmath-reshape-merge
Changeset: r50090:0c43b1d3d817
Date: 2011-12-02 15:08 +0200
http://bitbucket.org/pypy/pypy/changeset/0c43b1d3d817/
Log: allow empty shape for Scalars
diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -111,7 +111,11 @@
batch = space.listview(w_iterable)
new_size = 1
if len(batch) < 1:
- new_size = 0
+ if old_size ==1:
+ #Scalars can have an empty size.
+ new_size = 1
+ else:
+ new_size = 0
new_shape = []
i = 0
for elem in batch:
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
@@ -378,8 +378,8 @@
b = arange(20)[1:17:2]
b.shape = (4, 2)
assert (b == [[1, 3], [5, 7], [9, 11], [13, 15]]).all()
- b.reshape((2, 4))
- assert (b == [[1, 3, 5, 7], [9, 11, 13, 15]]).all()
+ c = b.reshape((2, 4))
+ assert (c == [[1, 3, 5, 7], [9, 11, 13, 15]]).all()
z=arange(96).reshape((12, -1))
assert z.shape == (12, 8)
More information about the pypy-commit
mailing list