Author: Maciej Fijalkowski <[email protected]>
Branch: numpy-multidim-shards
Changeset: r49412:f7cb08c0396d
Date: 2011-11-14 19:36 +0100
http://bitbucket.org/pypy/pypy/changeset/f7cb08c0396d/
Log: some partial fixes, will continue later
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
@@ -346,12 +346,13 @@
concrete = self.get_concrete()
i = concrete.start_iter()
start = True
+ dtype = concrete.find_dtype()
while not i.done():
if start:
start = False
else:
res.append(", ")
- res.append(concrete.dtype.str_format(concrete.eval(i)))
+ res.append(dtype.str_format(concrete.eval(i)))
i = i.next()
return space.wrap(res.build())
@@ -522,7 +523,7 @@
else:
shape = [lgt] + self.shape[1:]
shards = [self.shards[0] * step] + self.shards[1:]
- backshards = [lgt * self.shards[0] * step] +
self.backshards[1:]
+ backshards = [(lgt - 1) * self.shards[0] * step] +
self.backshards[1:]
start *= self.shards[0]
start += self.start
else:
@@ -537,7 +538,7 @@
if step != 0:
shape.append(lgt)
shards.append(self.shards[i] * step)
- backshards.append(self.shards[i] * lgt * step)
+ backshards.append(self.shards[i] * (lgt - 1) * step)
start += self.shards[i] * start_
# add a reminder
s = i + 1
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
@@ -36,13 +36,13 @@
s = a.create_slice(space, self.newslice(1, 9, 2))
assert s.start == 15
assert s.shards == [30, 3, 1]
- assert s.backshards == [120, 12, 2]
+ assert s.backshards == [90, 12, 2]
s = a.create_slice(space, space.newtuple([
self.newslice(1, 5, 3), self.newslice(1, 2, 1), space.wrap(1)]))
assert s.start == 19
assert s.shape == [2, 1]
assert s.shards == [45, 3]
- assert s.backshards == [90, 3]
+ assert s.backshards == [45, 3]
s = a.create_slice(space, self.newtuple(
self.newslice(None, None, None), space.wrap(2)))
assert s.start == 6
@@ -770,8 +770,9 @@
from numpy import array
a = array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13,
14]])
b = a[::2]
+ assert (b == [[1, 2], [5, 6], [9, 10], [13, 14]]).all()
c = b + b
- assert c[1][1] == 16
+ assert c[1][1] == 12
def test_broadcast(self):
skip("not working")
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit