[pypy-commit] pypy default: better error for ndarray.take with unsupported mode

bdkearns noreply at buildbot.pypy.org
Mon Feb 24 02:04:08 CET 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: 
Changeset: r69320:036b96efb852
Date: 2014-02-23 19:59 -0500
http://bitbucket.org/pypy/pypy/changeset/036b96efb852/

Log:	better error for ndarray.take with unsupported mode

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
@@ -1234,7 +1234,8 @@
 
 app_take = applevel(r"""
     def take(a, indices, axis, out, mode):
-        assert mode == 'raise'
+        if mode != 'raise':
+            raise NotImplementedError("mode != raise not implemented")
         if axis is None:
             from numpy import array
             indices = array(indices)
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
@@ -2822,6 +2822,10 @@
         assert ((a + a).take([3]) == [6]).all()
         a = arange(12).reshape(2, 6)
         assert (a[:,::2].take([3, 2, 1]) == [6, 4, 2]).all()
+        import sys
+        if '__pypy__' in sys.builtin_module_names:
+            exc = raises(NotImplementedError, "a.take([3, 2, 1], mode='clip')")
+            assert exc.value[0] == "mode != raise not implemented"
 
     def test_ptp(self):
         import numpypy as np


More information about the pypy-commit mailing list