diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2010-04-26 01:02:07 +0000 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2010-04-26 01:02:07 +0000 |
commit | cbe9b87ef42c0a7111ddd7f528393a0cb243c7d8 (patch) | |
tree | b776f721090180371c60164630f39bbc32407116 | |
parent | 22ee215bf2c34d7ec66901083cd94dc67fe26e4f (diff) | |
download | numpy-cbe9b87ef42c0a7111ddd7f528393a0cb243c7d8.tar.gz |
ENH: Simplify some functions using NpyArg_ParseKeywords.
-rw-r--r-- | numpy/core/src/multiarray/methods.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/numpy/core/src/multiarray/methods.c b/numpy/core/src/multiarray/methods.c index f09856c55..f0ab41f7c 100644 --- a/numpy/core/src/multiarray/methods.c +++ b/numpy/core/src/multiarray/methods.c @@ -100,22 +100,15 @@ array_put(PyArrayObject *self, PyObject *args, PyObject *kwds) static PyObject * array_reshape(PyArrayObject *self, PyObject *args, PyObject *kwds) { + static char *keywords[] = {"order", NULL}; PyArray_Dims newshape; PyObject *ret; PyArray_ORDER order = PyArray_CORDER; int n; - if (kwds != NULL) { - PyObject *ref; - ref = PyDict_GetItemString(kwds, "order"); - if (ref == NULL) { - PyErr_SetString(PyExc_TypeError, - "invalid keyword argument"); - return NULL; - } - if ((PyArray_OrderConverter(ref, &order) == PY_FAIL)) { - return NULL; - } + if (!NpyArg_ParseKeywords(kwds, "|O&", keywords, + PyArray_OrderConverter, &order)) { + return NULL; } n = PyTuple_Size(args); @@ -942,13 +935,8 @@ array_resize(PyArrayObject *self, PyObject *args, PyObject *kwds) PyObject *ret, *obj; - if (kwds != NULL) { - PyObject *tmp = PyTuple_New(0); - if (!PyArg_ParseTupleAndKeywords(tmp, kwds, "|i", kwlist, &refcheck)) { - Py_XDECREF(tmp); - return NULL; - } - Py_DECREF(tmp); + if (!NpyArg_ParseKeywords(kwds, "|i", kwlist, &refcheck)) { + return NULL; } if (size == 0) { |