From 6510cce13410a9fff4d92f6390c16a7788b1a892 Mon Sep 17 00:00:00 2001 From: Mark Wiebe Date: Fri, 28 Jan 2011 10:41:59 -0800 Subject: ENH: core: Add PyArray_NewLikeArray function This function implements the numpy.empty_like semantics, but supports the new NPY_KEEPORDER enumeration value as well as switching to a different data type. --- doc/source/reference/c-api.array.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'doc/source/reference/c-api.array.rst') diff --git a/doc/source/reference/c-api.array.rst b/doc/source/reference/c-api.array.rst index 2b58c922e..2124cbcdf 100644 --- a/doc/source/reference/c-api.array.rst +++ b/doc/source/reference/c-api.array.rst @@ -158,6 +158,21 @@ From scratch *dims* and *strides* are copied into newly allocated dimension and strides arrays for the new array object. +.. cfunction:: PyObject* PyArray_NewLikeArray(PyArrayObject* prototype, NPY_ORDER order, PyArray_Descr* descr) + + This function steals a reference to *descr* if it is not NULL. + + This array creation routine allows for the convenient creation of + a new array matching an existing array's shapes and memory layout, + possibly changing the layout and/or data type. + + When *order* is NPY_ANYORDER, the result order is NPY_FORTRANORDER if + *prototype* is a fortran array, NPY_CORDER otherwise. When *order* is + NPY_KEEPORDER, the result order matches that of *prototype*, even + when the axes of *prototype* aren't in C or Fortran order. + + If *descr* is NULL, the data type of *prototype* is used. + .. cfunction:: PyObject* PyArray_New(PyTypeObject* subtype, int nd, npy_intp* dims, int type_num, npy_intp* strides, void* data, int itemsize, int flags, PyObject* obj) This is similar to :cfunc:`PyArray_DescrNew` (...) except you -- cgit v1.2.1