[pypy-commit] pypy default: expose size attribute

fijal noreply at buildbot.pypy.org
Sun Nov 6 11:14:29 CET 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: 
Changeset: r48817:29573471a8fd
Date: 2011-11-06 11:13 +0100
http://bitbucket.org/pypy/pypy/changeset/29573471a8fd/

Log:	expose size attribute

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
@@ -201,6 +201,9 @@
     def descr_get_shape(self, space):
         return space.newtuple([self.descr_len(space)])
 
+    def descr_get_size(self, space):
+        return space.wrap(self.size)
+
     def descr_copy(self, space):
         return space.call_function(space.gettypefor(BaseArray), self, self.find_dtype())
 
@@ -607,6 +610,7 @@
 
     dtype = GetSetProperty(BaseArray.descr_get_dtype),
     shape = GetSetProperty(BaseArray.descr_get_shape),
+    size = GetSetProperty(BaseArray.descr_get_size),
 
     mean = interp2app(BaseArray.descr_mean),
     sum = interp2app(BaseArray.descr_sum),
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
@@ -17,6 +17,12 @@
         a[13] = 5.3
         assert a[13] == 5.3
 
+    def test_size(self):
+        from numpy import array
+        # XXX fixed on multidim branch
+        #assert array(3).size == 1
+        assert array([1, 2, 3]).size == 3
+
     def test_empty(self):
         """
         Test that empty() works.


More information about the pypy-commit mailing list