summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/code_generators/array_api_order.txt1
-rw-r--r--numpy/core/code_generators/multiarray_api_order.txt2
-rw-r--r--numpy/core/include/numpy/arrayobject.h2
-rw-r--r--numpy/core/src/arrayobject.c25
4 files changed, 27 insertions, 3 deletions
diff --git a/numpy/core/code_generators/array_api_order.txt b/numpy/core/code_generators/array_api_order.txt
index d088b6022..258cb471c 100644
--- a/numpy/core/code_generators/array_api_order.txt
+++ b/numpy/core/code_generators/array_api_order.txt
@@ -25,7 +25,6 @@ PyArray_ScalarAsCtype
PyArray_CastScalarToCtype
PyArray_CastScalarDirect
PyArray_ScalarFromObject
-PyArray_RegisterDataType
PyArray_GetCastFunc
PyArray_FromDims
PyArray_FromDimsAndDataAndDescr
diff --git a/numpy/core/code_generators/multiarray_api_order.txt b/numpy/core/code_generators/multiarray_api_order.txt
index 4054e7a8a..2daf423c6 100644
--- a/numpy/core/code_generators/multiarray_api_order.txt
+++ b/numpy/core/code_generators/multiarray_api_order.txt
@@ -67,3 +67,5 @@ PyArray_SortkindConverter
PyArray_LexSort
PyArray_Round
PyArray_EquivTypenums
+PyArray_RegisterDataType
+PyArray_RegisterCastFunc
diff --git a/numpy/core/include/numpy/arrayobject.h b/numpy/core/include/numpy/arrayobject.h
index d713666b9..7ef892ad6 100644
--- a/numpy/core/include/numpy/arrayobject.h
+++ b/numpy/core/include/numpy/arrayobject.h
@@ -79,7 +79,7 @@ extern "C" CONFUSE_EMACS
#define PY_SUCCEED 1
/* Helpful to distinguish what is installed */
-#define NDARRAY_VERSION 0x00090901
+#define NDARRAY_VERSION 0x00090902
/* Some platforms don't define bool, long long, or long double.
Handle that here.
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index 5b51b5c15..9b08b6b35 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -1175,7 +1175,7 @@ PyArray_Return(PyArrayObject *mp)
needs the userdecrs table and PyArray_NUMUSER variables
defined in arratypes.inc
*/
-/*OBJECT_API
+/*MULTIARRAY_API
Register Data type
Does not change the reference count of descr
*/
@@ -1209,6 +1209,29 @@ PyArray_RegisterDataType(PyArray_Descr *descr)
return typenum;
}
+/*MULTIARRAY_API
+ Register Casting Function
+ Replaces any function currently stored.
+*/
+static int
+PyArray_RegisterCastFunc(PyArray_Descr *descr, int totype,
+ PyArray_VectorUnaryFunc *castfunc)
+{
+ PyObject *cobj;
+ int ret;
+ if (descr->f->castdict == NULL) {
+ descr->f->castdict = PyDict_New();
+ }
+ key = PyInt_FromLong(totype);
+ if (PyErr_Occurred()) return -1;
+ cobj = PyCObject_FromVoidPtr((void *)castfunc);
+ if (cobj == NULL) {Py_DECREF(key); return -1;}
+ ret = PyDict_SetItem(descr->f->castdict, key, cobj);
+ Py_DECREF(key);
+ Py_DECREF(cobj);
+ return ret;
+}
+
/*OBJECT_API
To File
*/