diff options
author | Travis Oliphant <oliphant@enthought.com> | 2007-12-11 04:48:31 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2007-12-11 04:48:31 +0000 |
commit | 9405a8703f6df655c17cdefc02f9977f92d3b2d8 (patch) | |
tree | 1ab77e15b42da21716210bc5ef9e89f25031b9d1 /numpy/core/src/arraymethods.c | |
parent | 0a5bcc81689975874e358e3a7e8f401b8858b77f (diff) | |
download | numpy-9405a8703f6df655c17cdefc02f9977f92d3b2d8.tar.gz |
Allow clip method to have either min or max passed in.
Diffstat (limited to 'numpy/core/src/arraymethods.c')
-rw-r--r-- | numpy/core/src/arraymethods.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/numpy/core/src/arraymethods.c b/numpy/core/src/arraymethods.c index 9c56e6459..57c879426 100644 --- a/numpy/core/src/arraymethods.c +++ b/numpy/core/src/arraymethods.c @@ -1646,16 +1646,20 @@ array_trace(PyArrayObject *self, PyObject *args, PyObject *kwds) static PyObject * array_clip(PyArrayObject *self, PyObject *args, PyObject *kwds) { - PyObject *min, *max; + PyObject *min=NULL, *max=NULL; PyArrayObject *out=NULL; static char *kwlist[] = {"min", "max", "out", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO|O&", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO&", kwlist, &min, &max, PyArray_OutputConverter, &out)) return NULL; + if (max == NULL && min == NULL) { + PyErr_SetString(PyExc_ValueError, "One of max or min must be given."); + return NULL; + } return _ARET(PyArray_Clip(self, min, max, out)); } |