summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Berg <sebastianb@nvidia.com>2023-05-16 19:54:11 +0200
committerGitHub <noreply@github.com>2023-05-16 19:54:11 +0200
commit08f8ade2d3aa2134ddbca8f39acab39bc1396f90 (patch)
tree97a811690a423660ebd5be089cc42b09bafc38cd
parent6a4abb065afa5cd9967b92476cd8a245edf3dfcd (diff)
parentd99683c065209549c5199e41fcd3efb7cd92f55b (diff)
downloadnumpy-08f8ade2d3aa2134ddbca8f39acab39bc1396f90.tar.gz
Merge pull request #23769 from ngoldbaum/resulttype-doc
DOC: clarify how inputs of PyArray_ResultType are used
-rw-r--r--doc/source/reference/c-api/array.rst30
1 files changed, 7 insertions, 23 deletions
diff --git a/doc/source/reference/c-api/array.rst b/doc/source/reference/c-api/array.rst
index baebfdb02..038702bcf 100644
--- a/doc/source/reference/c-api/array.rst
+++ b/doc/source/reference/c-api/array.rst
@@ -1149,29 +1149,13 @@ Converting data types
.. versionadded:: 1.6
- This applies type promotion to all the inputs,
- using the NumPy rules for combining scalars and arrays, to
- determine the output type of a set of operands. This is the
- same result type that ufuncs produce. The specific algorithm
- used is as follows.
-
- Categories are determined by first checking which of boolean,
- integer (int/uint), or floating point (float/complex) the maximum
- kind of all the arrays and the scalars are.
-
- If there are only scalars or the maximum category of the scalars
- is higher than the maximum category of the arrays,
- the data types are combined with :c:func:`PyArray_PromoteTypes`
- to produce the return value.
-
- Otherwise, PyArray_MinScalarType is called on each array, and
- the resulting data types are all combined with
- :c:func:`PyArray_PromoteTypes` to produce the return value.
-
- The set of int values is not a subset of the uint values for types
- with the same number of bits, something not reflected in
- :c:func:`PyArray_MinScalarType`, but handled as a special case in
- PyArray_ResultType.
+ This applies type promotion to all the input arrays and dtype
+ objects, using the NumPy rules for combining scalars and arrays, to
+ determine the output type for an operation with the given set of
+ operands. This is the same result type that ufuncs produce.
+
+ See the documentation of :func:`numpy.result_type` for more
+ detail about the type promotion algorithm.
.. c:function:: int PyArray_ObjectType(PyObject* op, int mintype)