diff options
author | Travis Oliphant <oliphant@enthought.com> | 2008-05-01 20:02:38 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2008-05-01 20:02:38 +0000 |
commit | 59bdc5fa4f2ae7425b13d9d33f6776c3d422014f (patch) | |
tree | aa254d0b66ac84def2240fb121c565a642728ff2 /numpy/core/src/arraymethods.c | |
parent | 3d336c3ee1143428172d1140925f31e7b9c8fc67 (diff) | |
download | numpy-59bdc5fa4f2ae7425b13d9d33f6776c3d422014f.tar.gz |
Remove dtype_or_type key word in favor of simpler interface.
Diffstat (limited to 'numpy/core/src/arraymethods.c')
-rw-r--r-- | numpy/core/src/arraymethods.c | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/numpy/core/src/arraymethods.c b/numpy/core/src/arraymethods.c index 1af6a02b7..e8fb3244e 100644 --- a/numpy/core/src/arraymethods.c +++ b/numpy/core/src/arraymethods.c @@ -103,44 +103,30 @@ array_squeeze(PyArrayObject *self, PyObject *args) static PyObject * array_view(PyArrayObject *self, PyObject *args, PyObject *kwds) { - PyObject *out_dtype_or_type=NULL; PyObject *out_dtype=NULL; PyObject *out_type=NULL; PyArray_Descr *dtype=NULL; - static char *kwlist[] = {"dtype_or_type", "dtype", "type", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", kwlist, - &out_dtype_or_type, + static char *kwlist[] = {"dtype", "type", NULL}; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", kwlist, &out_dtype, &out_type)) return NULL; /* If user specified a positional argument, guess whether it represents a type or a dtype for backward compatibility. */ - if (out_dtype_or_type) { - + if (out_dtype) { /* type specified? */ - if (PyType_Check(out_dtype_or_type) && - PyType_IsSubtype((PyTypeObject *)out_dtype_or_type, + if (PyType_Check(out_dtype) && + PyType_IsSubtype((PyTypeObject *)out_dtype, &PyArray_Type)) { - if (out_type) { + if (out_type) { PyErr_SetString(PyExc_ValueError, "Cannot specify output type twice."); return NULL; } - - out_type = out_dtype_or_type; - } - - /* dtype specified */ - else { - if (out_dtype) { - PyErr_SetString(PyExc_ValueError, - "Cannot specify output dtype twice."); - return NULL; - } - - out_dtype = out_dtype_or_type; + out_type = out_dtype; + out_dtype = NULL; } } @@ -148,7 +134,7 @@ array_view(PyArrayObject *self, PyObject *args, PyObject *kwds) !PyType_IsSubtype((PyTypeObject *)out_type, &PyArray_Type))) { PyErr_SetString(PyExc_ValueError, - "Type must be a Python type object"); + "Type must be a sub-type of ndarray type"); return NULL; } |