diff options
author | David Cournapeau <cournape@gmail.com> | 2008-10-05 07:00:33 +0000 |
---|---|---|
committer | David Cournapeau <cournape@gmail.com> | 2008-10-05 07:00:33 +0000 |
commit | 50d1e8edc57b51a42cd82c9ef74a8e799ed36801 (patch) | |
tree | ccaba8c6f96b3ac715d5ad56ef3b34093778d9a5 /numpy/core/src/arrayobject.c | |
parent | 0273ac8609ab82eaa4240c437083bfeb5b707e29 (diff) | |
parent | a0e082a087e9667e3805d3be859958a292e8f336 (diff) | |
download | numpy-50d1e8edc57b51a42cd82c9ef74a8e799ed36801.tar.gz |
Merged revisions 5882-5911 via svnmerge from
http://svn.scipy.org/svn/numpy/trunk
........
r5886 | charris | 2008-10-02 03:05:29 +0900 (Thu, 02 Oct 2008) | 4 lines
Make some error messages more informative.
Improve error handling.
Make continuation lines work.
........
r5887 | charris | 2008-10-02 03:06:04 +0900 (Thu, 02 Oct 2008) | 2 lines
Small cleanup to clarify repeated string.
........
r5888 | charris | 2008-10-02 03:08:41 +0900 (Thu, 02 Oct 2008) | 6 lines
Cleanup ufunc loops.
At this point loops are separated into variable kinds, so there is a fair amount
of duplication. I will probably merge loops that look the same in a later
commit. There are no changes to current behavior of loops, this will also be
changed in later work to deal with nans and such.
........
r5889 | oliphant | 2008-10-03 05:27:17 +0900 (Fri, 03 Oct 2008) | 1 line
Fix problem with subclasses of object arrays.
........
r5896 | cdavid | 2008-10-03 15:50:32 +0900 (Fri, 03 Oct 2008) | 1 line
Update the minimum version for numscons: had to change to cope with Chuck changes to conv_template.py.
........
r5897 | cdavid | 2008-10-03 15:51:03 +0900 (Fri, 03 Oct 2008) | 1 line
Update doall script: take the python version to build binaries from the command line instead of global variable.
........
r5906 | oliphant | 2008-10-04 00:55:52 +0900 (Sat, 04 Oct 2008) | 1 line
Fix ticket #925
........
Diffstat (limited to 'numpy/core/src/arrayobject.c')
-rw-r--r-- | numpy/core/src/arrayobject.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index ad3cbc4f2..f944a499d 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -10790,6 +10790,75 @@ static PyTypeObject PyArrayMapIter_Type = { /** END of Subscript Iterator **/ +/* + NUMPY_API + Get MultiIterator from array of Python objects and any additional + + PyObject **mps -- array of PyObjects + int n - number of PyObjects in the array + int nadd - number of additional arrays to include in the + iterator. + + Returns a multi-iterator object. + */ +static PyObject * +PyArray_MultiIterFromObjects(PyObject **mps, int n, int nadd, ...) +{ + va_list va; + PyArrayMultiIterObject *multi; + PyObject *current; + PyObject *arr; + + int i, ntot, err=0; + + ntot = n + nadd; + if (ntot < 2 || ntot > NPY_MAXARGS) { + PyErr_Format(PyExc_ValueError, + "Need between 2 and (%d) " \ + "array objects (inclusive).", NPY_MAXARGS); + return NULL; + } + + multi = _pya_malloc(sizeof(PyArrayMultiIterObject)); + if (multi == NULL) return PyErr_NoMemory(); + PyObject_Init((PyObject *)multi, &PyArrayMultiIter_Type); + + for(i=0; i<ntot; i++) multi->iters[i] = NULL; + multi->numiter = ntot; + multi->index = 0; + + va_start(va, nadd); + for(i=0; i<ntot; i++) { + if (i < n) { + current = mps[i]; + } + else { + current = va_arg(va, PyObject *); + } + arr = PyArray_FROM_O(current); + if (arr==NULL) { + err=1; break; + } + else { + multi->iters[i] = (PyArrayIterObject *)PyArray_IterNew(arr); + Py_DECREF(arr); + } + } + + va_end(va); + + if (!err && PyArray_Broadcast(multi) < 0) err=1; + + if (err) { + Py_DECREF(multi); + return NULL; + } + + PyArray_MultiIter_RESET(multi); + + return (PyObject *)multi; +} + /*NUMPY_API Get MultiIterator, */ |