[pypy-commit] pypy numpy-multidim-shards: provide some sort of descr_repr (a broken one) and a fix
fijal
noreply at buildbot.pypy.org
Mon Nov 14 19:26:37 CET 2011
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: numpy-multidim-shards
Changeset: r49411:8521a920ed05
Date: 2011-11-14 19:26 +0100
http://bitbucket.org/pypy/pypy/changeset/8521a920ed05/
Log: provide some sort of descr_repr (a broken one) and a fix
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
@@ -342,8 +342,19 @@
# Simple implementation so that we can see the array.
# Since what we want is to print a plethora of 2d views,
# use recursive calls to to_str() to do the work.
+ res = StringBuilder()
concrete = self.get_concrete()
- res = StringBuilder()
+ i = concrete.start_iter()
+ start = True
+ while not i.done():
+ if start:
+ start = False
+ else:
+ res.append(", ")
+ res.append(concrete.dtype.str_format(concrete.eval(i)))
+ i = i.next()
+ return space.wrap(res.build())
+
res.append("array(")
#This is for numpy compliance: an empty slice reports its shape
if not concrete.find_size():
@@ -651,7 +662,7 @@
def get_concrete(self):
self.force_if_needed()
- return self.forced_result
+ return self.forced_result
def eval(self, iter):
if self.forced_result is not None:
@@ -698,6 +709,8 @@
return call_sig.func(self.res_dtype, val)
def start_iter(self):
+ if self.forced_result is not None:
+ return self.forced_result.start_iter()
return Call1Iterator(self.values.start_iter())
class Call2(VirtualArray):
@@ -722,6 +735,8 @@
return self.right.find_size()
def start_iter(self):
+ if self.forced_result is not None:
+ return self.forced_result.start_iter()
return Call2Iterator(self.left.start_iter(), self.right.start_iter())
def _eval(self, iter):
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
@@ -764,8 +764,7 @@
from numpy import array, negative
a = array([[1, 2], [3, 4]])
b = negative(a + a)
- res = (b == [[-1, -2], [-3, -4]]).all()
- assert res
+ assert (b == [[-2, -4], [-6, -8]]).all()
def test_getitem_3(self):
from numpy import array
More information about the pypy-commit
mailing list