[pypy-commit] pypy default: merge heads
antocuni
noreply at buildbot.pypy.org
Fri Mar 16 15:48:38 CET 2012
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch:
Changeset: r53725:875fb68d3265
Date: 2012-03-16 15:48 +0100
http://bitbucket.org/pypy/pypy/changeset/875fb68d3265/
Log: merge heads
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
@@ -256,6 +256,9 @@
self.size, w_iterable)
if isinstance(self, Scalar):
return
+ if self.size < 1:
+ self.shape = new_shape[:]
+ return
self.get_concrete().setshape(space, new_shape)
def descr_get_size(self, space):
@@ -473,6 +476,10 @@
else:
w_shape = space.newtuple(args_w)
new_shape = get_shape_from_iterable(space, self.size, w_shape)
+ if self.size < 1:
+ arr = self.get_concrete().copy(space)
+ arr.shape = new_shape[:]
+ return arr
return self.reshape(space, new_shape)
def reshape(self, space, new_shape):
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
@@ -434,6 +434,8 @@
a = zeros((4, 2, 3))
a.shape = (12, 2)
(a + a).reshape(2, 12) # assert did not explode
+ a = array([[[[]]]])
+ assert a.reshape((0,)).shape == (0,)
def test_slice_reshape(self):
from _numpypy import zeros, arange
More information about the pypy-commit
mailing list