summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Salvatier <jsalvatier@gmail.com>2012-08-06 18:11:02 -0700
committerCharles Harris <charlesr.harris@gmail.com>2012-10-08 12:35:52 -0600
commit471dde9985d89cfa2442f80753dc639f4908134d (patch)
tree840f52cf6dd5ea2ddc38e52834a6abb2d1f2de23
parent3f10c36339c0fe40e72378a990e6b3c5423805fb (diff)
downloadnumpy-471dde9985d89cfa2442f80753dc639f4908134d.tar.gz
gave MapIter an API
-rw-r--r--numpy/core/code_generators/cversions.txt2
-rw-r--r--numpy/core/code_generators/genapi.py1
-rw-r--r--numpy/core/code_generators/numpy_api.py4
-rw-r--r--numpy/core/setup_common.py2
-rw-r--r--numpy/core/src/multiarray/mapping.c22
5 files changed, 28 insertions, 3 deletions
diff --git a/numpy/core/code_generators/cversions.txt b/numpy/core/code_generators/cversions.txt
index 5bdb33c94..15d94bd9a 100644
--- a/numpy/core/code_generators/cversions.txt
+++ b/numpy/core/code_generators/cversions.txt
@@ -11,3 +11,5 @@
0x00000006 = e61d5dc51fa1c6459328266e215d6987
# Version 7 (NumPy 1.7) improved datetime64, misc utilities.
0x00000007 = e396ba3912dcf052eaee1b0b203a7724
+# Version 8 Added interface to MapIterObject
+0x00000008 = 2bd7a9d514b554a38080ab75e8b8e2c4
diff --git a/numpy/core/code_generators/genapi.py b/numpy/core/code_generators/genapi.py
index 3860fe6d7..32b0972a7 100644
--- a/numpy/core/code_generators/genapi.py
+++ b/numpy/core/code_generators/genapi.py
@@ -41,6 +41,7 @@ API_FILES = [join('multiarray', 'array_assign_array.c'),
join('multiarray', 'getset.c'),
join('multiarray', 'item_selection.c'),
join('multiarray', 'iterators.c'),
+ join('multiarray', 'mapping.c'),
join('multiarray', 'methods.c'),
join('multiarray', 'multiarraymodule.c'),
join('multiarray', 'nditer_api.c'),
diff --git a/numpy/core/code_generators/numpy_api.py b/numpy/core/code_generators/numpy_api.py
index cb598880b..08c6c1ea1 100644
--- a/numpy/core/code_generators/numpy_api.py
+++ b/numpy/core/code_generators/numpy_api.py
@@ -71,6 +71,7 @@ multiarray_types_api = {
'PyHalfArrType_Type': 217,
'NpyIter_Type': 218,
# End 1.6 API
+ 'PyArrayMapIter_Type': 295,
}
#define NPY_NUMUSERTYPES (*(int *)PyArray_API[6])
@@ -330,6 +331,9 @@ multiarray_funcs_api = {
'PyDataMem_FREE': 289,
'PyDataMem_RENEW': 290,
'PyDataMem_SetEventHook': 291,
+ '_swap_axes': 292,
+ 'PyArray_MapIterArray': 293,
+ 'PyArray_MapIterNext': 294,
}
ufunc_types_api = {
diff --git a/numpy/core/setup_common.py b/numpy/core/setup_common.py
index 58876a8e4..83589695d 100644
--- a/numpy/core/setup_common.py
+++ b/numpy/core/setup_common.py
@@ -29,7 +29,7 @@ C_ABI_VERSION = 0x01000009
# without breaking binary compatibility. In this case, only the C_API_VERSION
# (*not* C_ABI_VERSION) would be increased. Whenever binary compatibility is
# broken, both C_API_VERSION and C_ABI_VERSION should be increased.
-C_API_VERSION = 0x00000007
+C_API_VERSION = 0x00000008
class MismatchCAPIWarning(Warning):
pass
diff --git a/numpy/core/src/multiarray/mapping.c b/numpy/core/src/multiarray/mapping.c
index d414a1fbb..7405bad8e 100644
--- a/numpy/core/src/multiarray/mapping.c
+++ b/numpy/core/src/multiarray/mapping.c
@@ -166,7 +166,10 @@ array_ass_big_item(PyArrayObject *self, npy_intp i, PyObject *v)
/* -------------------------------------------------------------- */
-static void
+/*NUMPY_API
+ *
+*/
+NPY_NO_EXPORT void
_swap_axes(PyArrayMapIterObject *mit, PyArrayObject **ret, int getmap)
{
PyObject *new;
@@ -1628,7 +1631,7 @@ PyArray_MapIterReset(PyArrayMapIterObject *mit)
return;
}
-/*
+/*NUMPY_API
* This function needs to update the state of the map iterator
* and point mit->dataptr to the memory-location of the next object
*/
@@ -2028,6 +2031,21 @@ PyArray_MapIterNew(PyObject *indexobj, int oned, int fancy)
return NULL;
}
+/*NUMPY_API
+*/
+NPY_NO_EXPORT PyObject *
+PyArray_MapIterArray(PyArrayObject * a, PyObject * index, int oned, int fancy)
+{
+ PyArrayMapIterObject * mit;
+ mit = (PyArrayMapIterObject *) PyArray_MapIterNew(index, oned, fancy);
+ if (mit != NULL) {
+ PyArray_MapIterBind(mit, a);
+ PyArray_MapIterReset(mit);
+ }
+ return mit;
+}
+
+
static void
arraymapiter_dealloc(PyArrayMapIterObject *mit)