[pypy-commit] pypy numpy-1.10: prototype raising a warning, there must be a better way to subclass UserWarning

mattip noreply at buildbot.pypy.org
Sun Nov 15 12:52:21 EST 2015


Author: mattip <matti.picus at gmail.com>
Branch: numpy-1.10
Changeset: r80691:65856c15caca
Date: 2015-11-15 19:44 +0200
http://bitbucket.org/pypy/pypy/changeset/65856c15caca/

Log:	prototype raising a warning, there must be a better way to subclass
	UserWarning

diff --git a/pypy/module/micronumpy/ndarray.py b/pypy/module/micronumpy/ndarray.py
--- a/pypy/module/micronumpy/ndarray.py
+++ b/pypy/module/micronumpy/ndarray.py
@@ -116,6 +116,13 @@
                 "index out of range for array"))
         size = loop.count_all_true(arr)
         if arr.ndims() == 1:
+            if self.ndims() > 1 and arr.get_shape()[0] != self.get_shape()[0]:
+                msg = ("boolean index did not match indexed array along"
+                      " dimension 0; dimension is %d but corresponding"
+                      " boolean dimension is %d" % (self.get_shape()[0],
+                      arr.get_shape()[0]))
+                warning = space.gettypefor(support.W_VisibleDeprecationWarning)
+                space.warn(space.wrap(msg), warning)
             res_shape = [size] + self.get_shape()[1:]
         else:
             res_shape = [size]


More information about the pypy-commit mailing list