Author: Matti Picus <[email protected]>
Branch: numpypy-nditer
Changeset: r70713:66513118faad
Date: 2014-04-18 00:13 +0300
http://bitbucket.org/pypy/pypy/changeset/66513118faad/
Log: test, implement itersize
diff --git a/pypy/module/micronumpy/nditer.py b/pypy/module/micronumpy/nditer.py
--- a/pypy/module/micronumpy/nditer.py
+++ b/pypy/module/micronumpy/nditer.py
@@ -8,7 +8,7 @@
from pypy.module.micronumpy.iterators import ArrayIter, SliceIterator
from pypy.module.micronumpy.concrete import SliceArray
from pypy.module.micronumpy.descriptor import decode_w_dtype
-from pypy.module.micronumpy import ufuncs
+from pypy.module.micronumpy import ufuncs, support
class AbstractIterator(object):
@@ -528,8 +528,7 @@
'not implemented yet'))
def descr_get_itersize(self, space):
- raise OperationError(space.w_NotImplementedError, space.wrap(
- 'not implemented yet'))
+ return space.wrap(support.product(self.shape))
def descr_get_itviews(self, space):
raise OperationError(space.w_NotImplementedError, space.wrap(
diff --git a/pypy/module/micronumpy/test/test_nditer.py
b/pypy/module/micronumpy/test/test_nditer.py
--- a/pypy/module/micronumpy/test/test_nditer.py
+++ b/pypy/module/micronumpy/test/test_nditer.py
@@ -190,7 +190,9 @@
a = arange(3)
b = arange(6).reshape(2,3)
r = []
- for x,y in nditer([a, b]):
+ it = nditer([a, b])
+ assert it.itersize == 6
+ for x,y in it:
r.append((x, y))
assert r == [(0, 0), (1, 1), (2, 2), (0, 3), (1, 4), (2, 5)]
a = arange(2)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit