diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2020-08-21 17:04:41 -0500 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2020-09-02 12:53:32 -0500 |
commit | 76253895fbfbd2b6f5a5d4a5d2c6b96ff2dc5a0c (patch) | |
tree | 4484c6bb263123657280be8636c2aa78526db38b /numpy/lib/function_base.py | |
parent | d9075b77586e0c7b536d5ec684bfd93c5bcd9439 (diff) | |
download | numpy-76253895fbfbd2b6f5a5d4a5d2c6b96ff2dc5a0c.tar.gz |
API,MAINT: Rewrite promotion using common DType and common instance
This defines `common_dtype` and `common_instance` (only for parametric
DTypes), and uses them to implement the `PyArray_CommonDType` operation.
`PyArray_CommonDType()` together with the `common_instance` method
then define the existing PromoteTypes.
This does not (yet) affect "value based promotion" as defined by
`PyArray_ResultType()`. We also require the step of casting
to the common DType to define this type of example:
```
np.promote_types("S1", "i8") == np.dtype('S21')
```
This steps requires finding the string length corresponding to
the integer (21 characters). This is here handled by the
`PyArray_CastDescrToDType` function. However, that function
still relies on `PyArray_AdaptFlexibleDType` and thus does not
generalize to arbitrary DTypes.
See NEP 42 (currently "Common DType Operations" section):
https://numpy.org/neps/nep-0042-new-dtypes.html#common-dtype-operations
Diffstat (limited to 'numpy/lib/function_base.py')
0 files changed, 0 insertions, 0 deletions