Matti Picus avatar Matti Picus committed 3dbf1e7

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

Comments (0)

Files changed (2)

pypy/module/micronumpy/arrayimpl/concrete.py

 
     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(),
 
     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,

pypy/module/micronumpy/interp_numarray.py

                                  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)))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.