summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2020-01-15 21:32:56 -0600
committerSebastian Berg <sebastian@sipsolutions.net>2020-01-15 21:32:56 -0600
commit9e892cc22e28da9439c90e291ec2c67da810df65 (patch)
tree3e59fdd4223c5ec9f3b6a78227be061c9533a286
parentfeb0794bdb6709861b395818ddf0ea3548310e24 (diff)
downloadnumpy-9e892cc22e28da9439c90e291ec2c67da810df65.tar.gz
DEP: Deprecate `->f->fastclip` at registration time
This adds the additional deprecation of fastclip if it is set at registration time instead of only testing that it is never used.
-rw-r--r--doc/source/reference/c-api/types-and-structures.rst12
-rw-r--r--numpy/core/src/multiarray/usertypes.c12
2 files changed, 23 insertions, 1 deletions
diff --git a/doc/source/reference/c-api/types-and-structures.rst b/doc/source/reference/c-api/types-and-structures.rst
index 5d6c2f279..60d8e420b 100644
--- a/doc/source/reference/c-api/types-and-structures.rst
+++ b/doc/source/reference/c-api/types-and-structures.rst
@@ -452,7 +452,7 @@ PyArrayDescr_Type and PyArray_Descr
PyArray_ScalarKindFunc *scalarkind;
int **cancastscalarkindto;
int *cancastto;
- PyArray_FastClipFunc *fastclip;
+ PyArray_FastClipFunc *fastclip; /* deprecated */
PyArray_FastPutmaskFunc *fastputmask; /* deprecated */
PyArray_FastTakeFunc *fasttake; /* deprecated */
PyArray_ArgFunc *argmin;
@@ -641,6 +641,16 @@ PyArrayDescr_Type and PyArray_Descr
.. c:member:: void fastclip( \
void *in, npy_intp n_in, void *min, void *max, void *out)
+ .. deprecated:: 1.17
+ The use of this function will give a deprecation warning when
+ ``np.clip``. Instead of this function, the datatype must
+ instead use ``PyUFunc_RegisterLoopForDescr`` to attach a custom
+ loop to ``np.core.umath.clip``, ``np.minimum``, and ``np.maximum``.
+
+ .. deprecated:: 1.19
+ Setting this function is deprecated and should always be ``NULL``,
+ if set, it will be ignored.
+
A function that reads ``n_in`` items from ``in``, and writes to
``out`` the read value if it is within the limits pointed to by
``min`` and ``max``, or the corresponding limit if outside. The
diff --git a/numpy/core/src/multiarray/usertypes.c b/numpy/core/src/multiarray/usertypes.c
index 9ab3a2a5e..997467b4d 100644
--- a/numpy/core/src/multiarray/usertypes.c
+++ b/numpy/core/src/multiarray/usertypes.c
@@ -151,6 +151,18 @@ test_deprecated_arrfuncs_members(PyArray_ArrFuncs *f) {
return -1;
}
}
+ /* NumPy 1.19, 2020-01-15 */
+ if (f->fastclip != NULL) {
+ /* fastclip was already deprecated at execution time in 1.17. */
+ if (DEPRECATE(
+ "The ->f->fastclip member of custom dtypes is deprecated; "
+ "setting it will be an error in the future.\n"
+ "The custom dtype you are using must be changed to use "
+ "PyUFunc_RegisterLoopForDescr to attach a custom loop to "
+ "np.core.umath.clip, np.minimum, and np.maximum") < 0) {
+ return -1;
+ }
+ }
return 0;
}