[pypy-commit] pypy numpy-multidim: shape

fijal noreply at buildbot.pypy.org
Thu Oct 27 10:25:09 CEST 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: numpy-multidim
Changeset: r48491:cc8b141031c6
Date: 2011-10-26 22:34 +0200
http://bitbucket.org/pypy/pypy/changeset/cc8b141031c6/

Log:	shape

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
@@ -199,7 +199,7 @@
         return space.wrap(self.find_dtype())
 
     def descr_get_shape(self, space):
-        return space.newtuple([self.descr_len(space)])
+        return space.newtuple([space.wrap(i) for i in self.shape])
 
     def descr_copy(self, space):
         return space.call_function(space.gettypefor(BaseArray), self, self.find_dtype())
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
@@ -605,6 +605,14 @@
         a = numpy.zeros((2, 2))
         assert len(a) == 2
 
+    def test_shape(self):
+        import numpy
+        assert numpy.zeros(1).shape == (1,)
+        assert numpy.zeros((2, 2)).shape == (2,2)
+        assert numpy.zeros((3, 1, 2)).shape == (3, 1, 2)
+        assert len(numpy.zeros((3, 1, 2))) == 3
+        
+
 class AppTestSupport(object):
     def setup_class(cls):
         import struct


More information about the pypy-commit mailing list