diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-10-17 23:29:31 -0700 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-10-17 23:41:31 -0700 |
commit | 1d67d8896de9242248cf2bcaea7ed8308756dff0 (patch) | |
tree | 2e68b0764ccfd11892bc9c57526f545d1ef61e24 /numpy | |
parent | 77f9540f277de3e727d696eb5987a0505ed8cdf9 (diff) | |
download | numpy-1d67d8896de9242248cf2bcaea7ed8308756dff0.tar.gz |
ENH: Improve unravel_index error message for out of bound values
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/src/multiarray/compiled_base.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/numpy/core/src/multiarray/compiled_base.c b/numpy/core/src/multiarray/compiled_base.c index 36ef1d1c4..cf0253b4a 100644 --- a/numpy/core/src/multiarray/compiled_base.c +++ b/numpy/core/src/multiarray/compiled_base.c @@ -1135,8 +1135,11 @@ unravel_index_loop_corder(int unravel_ndim, npy_intp *unravel_dims, } NPY_END_ALLOW_THREADS; if (invalid) { - PyErr_SetString(PyExc_ValueError, - "invalid entry in index array"); + PyErr_Format(PyExc_ValueError, + "index %" NPY_INTP_FMT " is out of bounds for array with size " + "%" NPY_INTP_FMT, + val, unravel_size + ); return NPY_FAIL; } return NPY_SUCCEED; @@ -1169,8 +1172,11 @@ unravel_index_loop_forder(int unravel_ndim, npy_intp *unravel_dims, } NPY_END_ALLOW_THREADS; if (invalid) { - PyErr_SetString(PyExc_ValueError, - "invalid entry in index array"); + PyErr_Format(PyExc_ValueError, + "index %" NPY_INTP_FMT " is out of bounds for array with size " + "%" NPY_INTP_FMT, + val, unravel_size + ); return NPY_FAIL; } return NPY_SUCCEED; |