Author: Yichao Yu <yyc1...@gmail.com>
Branch: numpy-generic-item
Changeset: r74057:d4b9abbdfab6
Date: 2014-09-24 08:19 -0400
http://bitbucket.org/pypy/pypy/changeset/d4b9abbdfab6/

Log:    fix return type of generic.reshape

diff --git a/pypy/module/micronumpy/boxes.py b/pypy/module/micronumpy/boxes.py
--- a/pypy/module/micronumpy/boxes.py
+++ b/pypy/module/micronumpy/boxes.py
@@ -401,7 +401,10 @@
 
     def descr_reshape(self, space, __args__):
         w_meth = space.getattr(self.descr_ravel(space), space.wrap('reshape'))
-        return space.call_args(w_meth, __args__)
+        w_res = space.call_args(w_meth, __args__)
+        if isinstance(w_res, W_NDimArray) and len(w_res.get_shape()) == 0:
+            return w_res.get_scalar_value()
+        return w_res
 
     def descr_nd_nonzero(self, space, __args__):
         w_meth = space.getattr(self.descr_ravel(space), space.wrap('nonzero'))
diff --git a/pypy/module/micronumpy/test/test_scalar.py 
b/pypy/module/micronumpy/test/test_scalar.py
--- a/pypy/module/micronumpy/test/test_scalar.py
+++ b/pypy/module/micronumpy/test/test_scalar.py
@@ -254,6 +254,7 @@
         assert np.int64(123).reshape((1,)).shape == (1,)
         exc = raises(ValueError, "np.int64(123).reshape((2,))")
         assert exc.value[0] == 'total size of new array must be unchanged'
+        assert type(np.int64(123).reshape(())) == np.int64
 
     def test_complex_scalar_complex_cast(self):
         import numpy as np
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to