From 1cd5403e91c066910c85d1e326cffa701c7e5101 Mon Sep 17 00:00:00 2001 From: Travis Oliphant Date: Mon, 2 Apr 2007 20:21:57 +0000 Subject: Add interp to numpy.lib adapted from arrayfns. Add an unfinished arrayfns compatibility module to old_numeric. --- numpy/core/src/arraymethods.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'numpy/core/src/arraymethods.c') diff --git a/numpy/core/src/arraymethods.c b/numpy/core/src/arraymethods.c index e2dbaa717..3572633ef 100644 --- a/numpy/core/src/arraymethods.c +++ b/numpy/core/src/arraymethods.c @@ -479,7 +479,9 @@ array_toscalar(PyArrayObject *self, PyObject *args) { PyErr_SetString(PyExc_ValueError, "invalid integer"); return NULL; } - if (value >= PyArray_SIZE(self)) { + factor = PyArray_SIZE(self); + if (value < 0) value += factor; + if ((value >= factor) || (value < 0)) { PyErr_SetString(PyExc_ValueError, "index out of bounds"); return NULL; -- cgit v1.2.1