Skip to content

Commit

Permalink
Merge pull request numpy#14100 from kritisingh1/dep3
Browse files Browse the repository at this point in the history
DEP: Deprecate PyArray_FromDimsAndDataAndDescr, PyArray_FromDims
  • Loading branch information
mattip authored Aug 8, 2019
2 parents 68626ac + 9d9183c commit 24bc2da
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 41 deletions.
1 change: 1 addition & 0 deletions changelog/14036.expired.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* PyArray_As1D, PyArray_As2D have been removed in favor of PyArray_AsCArray
2 changes: 2 additions & 0 deletions changelog/14100.expired.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* PyArray_FromDimsAndDataAndDescr has been removed, use PyArray_NewFromDescr instead
* PyArray_FromDims has been removed, use PyArray_SimpleNew instead
51 changes: 10 additions & 41 deletions numpy/core/src/multiarray/ctors.c
Original file line number Diff line number Diff line change
Expand Up @@ -2772,61 +2772,30 @@ PyArray_DescrFromObject(PyObject *op, PyArray_Descr *mintype)
/* They all zero-out the memory as previously done */

/* steals reference to descr -- and enforces native byteorder on it.*/

/*NUMPY_API
Like FromDimsAndData but uses the Descr structure instead of typecode
as input.
Deprecated, use PyArray_NewFromDescr instead.
*/
NPY_NO_EXPORT PyObject *
PyArray_FromDimsAndDataAndDescr(int nd, int *d,
PyArray_Descr *descr,
char *data)
{
PyObject *ret;
int i;
npy_intp newd[NPY_MAXDIMS];
char msg[] = "PyArray_FromDimsAndDataAndDescr: use PyArray_NewFromDescr.";

if (DEPRECATE(msg) < 0) {
/* 2009-04-30, 1.5 */
return NULL;
}
if (!PyArray_ISNBO(descr->byteorder))
descr->byteorder = '=';
for (i = 0; i < nd; i++) {
newd[i] = (npy_intp) d[i];
}
ret = PyArray_NewFromDescr(&PyArray_Type, descr,
nd, newd,
NULL, data,
(data ? NPY_ARRAY_CARRAY : 0), NULL);
return ret;
PyErr_SetString(PyExc_NotImplementedError,
"PyArray_FromDimsAndDataAndDescr: use PyArray_NewFromDescr.");
Py_DECREF(descr);
return NULL;
}

/*NUMPY_API
Construct an empty array from dimensions and typenum
Deprecated, use PyArray_SimpleNew instead.
*/
NPY_NO_EXPORT PyObject *
PyArray_FromDims(int nd, int *d, int type)
{
PyArrayObject *ret;
char msg[] = "PyArray_FromDims: use PyArray_SimpleNew.";

if (DEPRECATE(msg) < 0) {
/* 2009-04-30, 1.5 */
return NULL;
}
ret = (PyArrayObject *)PyArray_FromDimsAndDataAndDescr(nd, d,
PyArray_DescrFromType(type),
NULL);
/*
* Old FromDims set memory to zero --- some algorithms
* relied on that. Better keep it the same. If
* Object type, then it's already been set to zero, though.
*/
if (ret && (PyArray_DESCR(ret)->type_num != NPY_OBJECT)) {
memset(PyArray_DATA(ret), 0, PyArray_NBYTES(ret));
}
return (PyObject *)ret;
PyErr_SetString(PyExc_NotImplementedError,
"PyArray_FromDims: use PyArray_SimpleNew.");
return NULL;
}

/* end old calls */
Expand Down

0 comments on commit 24bc2da

Please sign in to comment.