[pypy-commit] pypy numpy-refactor: size
fijal
noreply at buildbot.pypy.org
Thu Aug 30 15:43:55 CEST 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: numpy-refactor
Changeset: r56936:1fbf219a5113
Date: 2012-08-30 15:30 +0200
http://bitbucket.org/pypy/pypy/changeset/1fbf219a5113/
Log: size
diff --git a/pypy/module/micronumpy/arrayimpl/base.py b/pypy/module/micronumpy/arrayimpl/base.py
--- a/pypy/module/micronumpy/arrayimpl/base.py
+++ b/pypy/module/micronumpy/arrayimpl/base.py
@@ -1,6 +1,7 @@
class BaseArrayImplementation(object):
- is_scalar = False
+ def is_scalar(self):
+ return False
class BaseArrayIterator(object):
def next(self):
diff --git a/pypy/module/micronumpy/arrayimpl/scalar.py b/pypy/module/micronumpy/arrayimpl/scalar.py
--- a/pypy/module/micronumpy/arrayimpl/scalar.py
+++ b/pypy/module/micronumpy/arrayimpl/scalar.py
@@ -2,12 +2,13 @@
from pypy.module.micronumpy.arrayimpl import base
class Scalar(base.BaseArrayImplementation):
- is_scalar = True
-
def __init__(self, dtype):
self.value = None
self.dtype = dtype
+ def is_scalar(self):
+ return True
+
def get_shape(self):
return []
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
@@ -67,7 +67,10 @@
return self.implementation.create_iter()
def is_scalar(self):
- return self.implementation.is_scalar
+ return self.implementation.is_scalar()
+
+ def descr_get_size(self, space):
+ return space.wrap(support.product(self.implementation.get_shape()))
def get_scalar_value(self):
return self.implementation.get_scalar_value()
@@ -101,6 +104,7 @@
shape = GetSetProperty(W_NDimArray.descr_get_shape,
W_NDimArray.descr_set_shape),
ndim = GetSetProperty(W_NDimArray.descr_get_ndim),
+ size = GetSetProperty(W_NDimArray.descr_get_size),
)
def decode_w_dtype(space, w_dtype):
More information about the pypy-commit
mailing list