[pypy-commit] pypy boolean-indexing-cleanup: add test, fix for 1d view iteration in special boolean indexing case
mattip
noreply at buildbot.pypy.org
Mon Sep 16 21:13:58 CEST 2013
Author: Matti Picus <matti.picus at gmail.com>
Branch: boolean-indexing-cleanup
Changeset: r66974:427a21150489
Date: 2013-09-16 21:28 +0300
http://bitbucket.org/pypy/pypy/changeset/427a21150489/
Log: add test, fix for 1d view iteration in special boolean indexing case
diff --git a/pypy/module/micronumpy/arrayimpl/concrete.py b/pypy/module/micronumpy/arrayimpl/concrete.py
--- a/pypy/module/micronumpy/arrayimpl/concrete.py
+++ b/pypy/module/micronumpy/arrayimpl/concrete.py
@@ -386,7 +386,8 @@
loop.fill(self, box.convert_to(self.dtype))
def create_iter(self, shape=None, backward_broadcast=False):
- if shape is not None and shape != self.get_shape():
+ if shape is not None and shape != self.get_shape() and \
+ support.product(shape) != support.product(self.get_shape()):
r = calculate_broadcast_strides(self.get_strides(),
self.get_backstrides(),
self.get_shape(), shape,
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
@@ -2360,6 +2360,11 @@
b = arange(4).reshape(2, 2) + 10
a[a < 4] = b
assert (a == [10, 11, 12, 13, 4, 5]).all()
+ b += 10
+ c = arange(8).reshape(2, 2, 2)
+ a[a > 9] = c[:, :, 1]
+ assert (c[:, :, 1] == [[1, 3], [5, 7]]).all()
+ assert (a == [1, 3, 5, 7, 4, 5]).all()
a = arange(6)
a[a > 3] = array([15])
assert (a == [0, 1, 2, 3, 15, 15]).all()
More information about the pypy-commit
mailing list