[pypy-commit] pypy numpy-refactor: fix setslice on scalars

bdkearns noreply at buildbot.pypy.org
Thu Feb 27 01:59:55 CET 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: numpy-refactor
Changeset: r69481:f13a87f568d7
Date: 2014-02-26 18:31 -0500
http://bitbucket.org/pypy/pypy/changeset/f13a87f568d7/

Log:	fix setslice on scalars

diff --git a/pypy/module/micronumpy/concrete.py b/pypy/module/micronumpy/concrete.py
--- a/pypy/module/micronumpy/concrete.py
+++ b/pypy/module/micronumpy/concrete.py
@@ -44,8 +44,13 @@
         self.dtype.itemtype.store(self, index, 0, value)
 
     def setslice(self, space, arr):
+        if len(arr.get_shape()) > 0 and len(self.get_shape()) == 0:
+            raise oefmt(space.w_ValueError,
+                "could not broadcast input array from shape "
+                "(%s) into shape ()",
+                ','.join([str(x) for x in arr.get_shape()]))
+        shape = shape_agreement(space, self.get_shape(), arr)
         impl = arr.implementation
-        shape = shape_agreement(space, self.get_shape(), arr)
         if impl.storage == self.storage:
             impl = impl.copy(space)
         loop.setslice(space, shape, self, impl)


More information about the pypy-commit mailing list