Author: Maciej Fijalkowski <[email protected]>
Branch: numpy-refactor
Changeset: r57118:a4231c4f66f8
Date: 2012-09-04 12:34 +0200
http://bitbucket.org/pypy/pypy/changeset/a4231c4f66f8/
Log: some reshape fixes
diff --git a/pypy/module/micronumpy/arrayimpl/concrete.py
b/pypy/module/micronumpy/arrayimpl/concrete.py
--- a/pypy/module/micronumpy/arrayimpl/concrete.py
+++ b/pypy/module/micronumpy/arrayimpl/concrete.py
@@ -1,7 +1,7 @@
from pypy.module.micronumpy.arrayimpl import base
from pypy.module.micronumpy import support, loop
-from pypy.module.micronumpy.base import convert_to_array, W_NDimArray
+from pypy.module.micronumpy.base import convert_to_array
from pypy.module.micronumpy.strides import calc_new_strides, shape_agreement,\
calculate_broadcast_strides
from pypy.module.micronumpy.iter import Chunk, Chunks, NewAxisChunk,
RecordChunk
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
@@ -127,12 +127,14 @@
new_shape = get_shape_from_iterable(space, self.get_size(), w_shape)
new_impl = self.implementation.reshape(space, new_shape)
if new_impl is not None:
- self.implementation = new_impl
- return self
+ return W_NDimArray(new_impl)
+ # Create copy with contiguous data
+ arr = self.descr_copy(space)
+ if arr.get_size() > 0:
+ arr.implementation = arr.implementation.reshape(space, new_shape)
+ assert arr.implementation
else:
- # Create copy with contiguous data
- arr = self.descr_copy(space)
- arr.implementation = arr.implementation.reshape(space, new_shape)
+ arr.implementation.shape = new_shape
return arr
def descr_get_transpose(self, space):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit