Author: Matti Picus <[email protected]>
Branch: boolean-indexing-cleanup
Changeset: r66975:3dbf1e79be28
Date: 2013-09-16 22:12 +0300
http://bitbucket.org/pypy/pypy/changeset/3dbf1e79be28/

Log:    numpy allows boolean assignment mismatch, as long as there are more
        values on the rhs

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
@@ -317,7 +317,7 @@
 
     def create_iter(self, shape=None, backward_broadcast=False):
         if shape is None or \
-           support.product(shape) == support.product(self.get_shape()):
+           support.product(shape) <= support.product(self.get_shape()):
             return iter.ConcreteArrayIterator(self)
         r = calculate_broadcast_strides(self.get_strides(),
                                         self.get_backstrides(),
@@ -387,7 +387,7 @@
 
     def create_iter(self, shape=None, backward_broadcast=False):
         if shape is not None and shape != self.get_shape() and \
-           support.product(shape) != support.product(self.get_shape()):
+           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/interp_numarray.py 
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -97,7 +97,7 @@
                                  space.wrap("index out of range for array"))
         idx_iter = idx.create_iter(self.get_shape())
         size = loop.count_all_true_iter(idx_iter, self.get_shape(), 
idx.get_dtype())
-        if size != val.get_size() and val.get_size() > 1:
+        if size > val.get_size() and val.get_size() > 1:
             raise OperationError(space.w_ValueError, space.wrap("NumPy boolean 
array indexing assignment "
                                                                 "cannot assign 
%d input values to "
                                                                 "the %d output 
values where the mask is true" % (val.get_size(), size)))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to