diff options
-rw-r--r-- | doc/release/upcoming_changes/14942.compatibility.rst | 8 | ||||
-rw-r--r-- | doc/source/reference/c-api/types-and-structures.rst | 12 | ||||
-rw-r--r-- | numpy/core/src/multiarray/usertypes.c | 31 |
3 files changed, 45 insertions, 6 deletions
diff --git a/doc/release/upcoming_changes/14942.compatibility.rst b/doc/release/upcoming_changes/14942.compatibility.rst index 1f0159c2f..461758c95 100644 --- a/doc/release/upcoming_changes/14942.compatibility.rst +++ b/doc/release/upcoming_changes/14942.compatibility.rst @@ -1,6 +1,6 @@ Fasttake and fastputmask slots are deprecated and NULL'ed --------------------------------------------------------- -The fasttake and fastputmask slots are now never used internally. -They will always set to NULL for builtin dtypes. -No downstream project should be using these, so no compatibility -issue are expected. +The fasttake and fastputmask slots are now never used and +must always be set to NULL. This will result in no change in behaviour. +However, if a user dtype should set one of these a DeprecationWarning +will be given. diff --git a/doc/source/reference/c-api/types-and-structures.rst b/doc/source/reference/c-api/types-and-structures.rst index 336dff211..5d6c2f279 100644 --- a/doc/source/reference/c-api/types-and-structures.rst +++ b/doc/source/reference/c-api/types-and-structures.rst @@ -453,8 +453,8 @@ PyArrayDescr_Type and PyArray_Descr int **cancastscalarkindto; int *cancastto; PyArray_FastClipFunc *fastclip; - PyArray_FastPutmaskFunc *fastputmask; - PyArray_FastTakeFunc *fasttake; + PyArray_FastPutmaskFunc *fastputmask; /* deprecated */ + PyArray_FastTakeFunc *fasttake; /* deprecated */ PyArray_ArgFunc *argmin; } PyArray_ArrFuncs; @@ -650,6 +650,10 @@ PyArrayDescr_Type and PyArray_Descr .. c:member:: void fastputmask( \ void *in, void *mask, npy_intp n_in, void *values, npy_intp nv) + .. deprecated:: 1.19 + Setting this function is deprecated and should always be ``NULL``, + if set, it will be ignored. + A function that takes a pointer ``in`` to an array of ``n_in`` items, a pointer ``mask`` to an array of ``n_in`` boolean values, and a pointer ``vals`` to an array of ``nv`` items. @@ -662,6 +666,10 @@ PyArrayDescr_Type and PyArray_Descr npy_intp n_outer, npy_intp m_middle, npy_intp nelem, \ NPY_CLIPMODE clipmode) + .. deprecated:: 1.19 + Setting this function is deprecated and should always be ``NULL``, + if set, it will be ignored. + A function that takes a pointer ``src`` to a C contiguous, behaved segment, interpreted as a 3-dimensional array of shape ``(n_outer, nindarray, nelem)``, a pointer ``indarray`` to a diff --git a/numpy/core/src/multiarray/usertypes.c b/numpy/core/src/multiarray/usertypes.c index 2e8fb514f..9ab3a2a5e 100644 --- a/numpy/core/src/multiarray/usertypes.c +++ b/numpy/core/src/multiarray/usertypes.c @@ -128,6 +128,32 @@ PyArray_InitArrFuncs(PyArray_ArrFuncs *f) f->cancastto = NULL; } + +static int +test_deprecated_arrfuncs_members(PyArray_ArrFuncs *f) { + /* NumPy 1.19, 2020-01-15 */ + if (f->fastputmask != NULL) { + if (DEPRECATE( + "The ->f->fastputmask member of custom dtypes is ignored; " + "setting it may be an error in the future.\n" + "The custom dtype you are using must be revised, but " + "results will not be affected.") < 0) { + return -1; + } + } + /* NumPy 1.19, 2020-01-15 */ + if (f->fasttake != NULL) { + if (DEPRECATE( + "The ->f->fastputmask member of custom dtypes is ignored; " + "setting it may be an error in the future.\n" + "The custom dtype you are using must be revised, but " + "results will not be affected.") < 0) { + return -1; + } + } + return 0; +} + /* returns typenum to associate with this type >=NPY_USERDEF. needs the userdecrs table and PyArray_NUMUSER variables @@ -176,6 +202,11 @@ PyArray_RegisterDataType(PyArray_Descr *descr) PyErr_SetString(PyExc_ValueError, "missing typeobject"); return -1; } + + if (test_deprecated_arrfuncs_members(f) < 0) { + return -1; + } + userdescrs = realloc(userdescrs, (NPY_NUMUSERTYPES+1)*sizeof(void *)); if (userdescrs == NULL) { |