[pypy-commit] pypy default: flesh out ScalarIterator so no 'if arr.is_scalar()' everywhere
mattip
noreply at buildbot.pypy.org
Thu Feb 7 22:32:20 CET 2013
Author: mattip <matti.picus at gmail.com>
Branch:
Changeset: r60942:a0980f72c3fb
Date: 2013-02-07 18:26 +0200
http://bitbucket.org/pypy/pypy/changeset/a0980f72c3fb/
Log: flesh out ScalarIterator so no 'if arr.is_scalar()' everywhere
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
@@ -7,18 +7,19 @@
class ScalarIterator(base.BaseArrayIterator):
def __init__(self, v):
self.v = v
+ self.called_once = False
def next(self):
- pass
+ self.called_once = True
def getitem(self):
- return self.v
+ return self.v.get_scalar_value()
def setitem(self, v):
- raise Exception("Don't call setitem on scalar iterators")
+ self.v.set_scalar_value(v)
def done(self):
- raise Exception("should not call done on scalar")
+ return self.called_once
def reset(self):
pass
@@ -38,7 +39,7 @@
return []
def create_iter(self, shape=None):
- return ScalarIterator(self.value)
+ return ScalarIterator(self)
def get_scalar_value(self):
return self.value
More information about the pypy-commit
mailing list