diff options
| author | mattip <matti.picus@gmail.com> | 2018-05-30 21:51:40 -0700 |
|---|---|---|
| committer | Marten van Kerkwijk <mhvk@astro.utoronto.ca> | 2018-07-17 17:04:59 -0400 |
| commit | 8788119ff2a239621f2ad8bc0a3986c1dde542ea (patch) | |
| tree | 160c944c55edf089118faa7afa5a7beff0ec51a8 /doc/source/reference | |
| parent | e77fff85fbe2ebb5757acd737e591b9acdf8e034 (diff) | |
| download | numpy-8788119ff2a239621f2ad8bc0a3986c1dde542ea.tar.gz | |
DOC: updates and fixes for gufunc descriptions.
Diffstat (limited to 'doc/source/reference')
| -rw-r--r-- | doc/source/reference/c-api.types-and-structures.rst | 88 |
1 files changed, 84 insertions, 4 deletions
diff --git a/doc/source/reference/c-api.types-and-structures.rst b/doc/source/reference/c-api.types-and-structures.rst index dcebd1ede..9d1aca345 100644 --- a/doc/source/reference/c-api.types-and-structures.rst +++ b/doc/source/reference/c-api.types-and-structures.rst @@ -133,9 +133,9 @@ PyArray_Type is related to this array. There are two use cases: 1) If this array does not own its own memory, then base points to the Python object that owns it (perhaps another array object), 2) If this array has - the (deprecated) :c:data:`NPY_ARRAY_UPDATEIFCOPY` or + the (deprecated) :c:data:`NPY_ARRAY_UPDATEIFCOPY` or :c:data:NPY_ARRAY_WRITEBACKIFCOPY`: flag set, then this array is - a working copy of a "misbehaved" array. When + a working copy of a "misbehaved" array. When ``PyArray_ResolveWritebackIfCopy`` is called, the array pointed to by base will be updated with the contents of this array. @@ -683,7 +683,9 @@ PyUFunc_Type The core of the ufunc is the :c:type:`PyUFuncObject` which contains all the information needed to call the underlying C-code loops that - perform the actual work. It has the following structure: + perform the actual work. While it is described here for completeness, it + should be considered internal to NumPy and manipulated via ``PyUFunc_*`` + functions. It has the following structure: .. code-block:: c @@ -696,15 +698,29 @@ PyUFunc_Type PyUFuncGenericFunction *functions; void **data; int ntypes; - int reserved1; + int version; const char *name; char *types; const char *doc; void *ptr; PyObject *obj; PyObject *userloops; + int core_enabled; + int core_num_dim_ix; + int *core_num_dims; + int *core_dim_ixs; + int *core_offsets; + char *core_signature; + PyUFunc_TypeResolutionFunc *type_resolver; + PyUFunc_LegacyInnerLoopSelectionFunc *legacy_inner_loop_selector; + void *reserved2; + PyUFunc_MaskedInnerLoopSelectionFunc *masked_inner_loop_selector; npy_uint32 *op_flags; npy_uint32 *iter_flags; + /* new in version 1 */ + npy_intp *core_dim_sizes; + npy_uint32 *core_dim_flags; + } PyUFuncObject; .. c:macro: PyUFuncObject.PyObject_HEAD @@ -764,6 +780,10 @@ PyUFunc_Type specifies how many different 1-d loops (of the builtin data types) are available. + .. c:member:: int PyUFuncObject.version + + The version of this struct, currently set to 1 + .. c:member:: char *PyUFuncObject.name A string name for the ufunc. This is used dynamically to build @@ -804,6 +824,51 @@ PyUFunc_Type User defined type numbers are always larger than :c:data:`NPY_USERDEF`. + .. c:member:: int PyUFuncObject.core_enabled + + 0 for scalar ufuncs; 1 for generalized ufuncs + + .. c:member:: int PyUFuncObject.core_num_dim_ix + + Number of distinct core dimension names in the signature + + .. c:member:: int *PyUFuncObject.core_num_dims + + Number of core dimensions of each argument + + .. c:member:: int *PyUFuncObject.core_dim_ixs + + Dimension indices in a flattened form; indices of argument ``k`` are + stored in ``core_dim_ixs[core_offsets[k] : core_offsets[k] + + core_numdims[k]]`` + + .. c:member:: int *PyUFuncObject.core_offsets + + Position of 1st core dimension of each argument in ``core_dim_ixs``, + equivalent to cumsum(``core_num_dims``) + + .. c:member:: char *PyUFuncObject.core_signature + + Core signature string + + .. c:member:: PyUFunc_TypeResolutionFunc *PyUFuncObject.type_resolver + + A function which resolves the types and fills an array with the dtypes + for the inputs and outputs + + .. c:member:: PyUFunc_LegacyInnerLoopSelectionFunc *PyUFuncObject.legacy_inner_loop_selector + + A function which returns an inner loop. The ``legacy`` in the name arises + because for NumPy 1.6 a better variant had been planned. This variant + has not yet come about. + + .. c:member:: void *PyUFuncObject.reserved2 + + For a possible future loop selector with a different signature. + + .. c:member:: PyUFunc_MaskedInnerLoopSelectionFunc *PyUFuncObject.masked_inner_loop_selector + + Function which returns a masked inner loop for the ufunc .. c:member:: npy_uint32 PyUFuncObject.op_flags @@ -813,6 +878,21 @@ PyUFunc_Type Override the default nditer flags for the ufunc. + Added in version 1 + + .. c:member:: npy_intp *PyUFuncObject.core_dim_sizes + + For each distinct core dimension, the possible + "frozen" size (``-1`` if not frozen) + + .. c:member:: npy_uint32 *PyUFuncObject.core_dim_flags + + For each distinct core dimension, a set of flags ``OR`` ed together: + + - :c:data:`UFUNC_CORE_CAN_IGNORE` if the dim name ends in ``?`` + - :c:data:`UFUNC_CORE_DIM_SIZE_UNSET` if the dim size will be + determined by the operands (not frozen) + PyArrayIter_Type ---------------- |
