diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2019-11-18 16:13:06 -0800 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2019-11-21 17:06:02 -0800 |
commit | c5da77d47309b6bf11f13f3b2e760f9b21423427 (patch) | |
tree | 621cf8e0f25bb362788683dbbba2b89fb3366611 /doc/release | |
parent | 9aeb7513019954718a3225fbab24bdbb98ca4fd5 (diff) | |
download | numpy-c5da77d47309b6bf11f13f3b2e760f9b21423427.tar.gz |
API: Use `ResultType` in `PyArray_ConvertToCommonType`
This slightly modifies the behaviour of `np.choose` (practically a
bug fix) and the public function itself. The function is not used within
e.g. SciPy, so the small performance hit of this implementation
is probably insignificant.
The change should help clean up dtypes a bit, since the whole "scalar
cast" logic is brittle and should be deprecated/removed, and this is
probably one of the few places actually using it.
The choose change means that:
```
np.choose([0], (1000, np.array([1], dtype=np.uint8)))
```
will actually return a value of 1000 (the dtype not being uint8).
Diffstat (limited to 'doc/release')
-rw-r--r-- | doc/release/upcoming_changes/14933.compatibility.rst | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/doc/release/upcoming_changes/14933.compatibility.rst b/doc/release/upcoming_changes/14933.compatibility.rst new file mode 100644 index 000000000..b939fec7f --- /dev/null +++ b/doc/release/upcoming_changes/14933.compatibility.rst @@ -0,0 +1,10 @@ +Scalar promotion in ``PyArray_ConvertToCommonType`` +--------------------------------------------------- + +The promotion of mixed scalars and arrays in ``PyArray_ConvertToCommonType`` +has been changed to adhere to those used by ``np.result_type``. +This means that input such as ``(1000, np.array([1], dtype=np.uint8)))`` +will now return ``uint16`` dtypes. In most cases the behaviour is unchanged. +Note that the use of this C-API function is generally discouarged. +This also fixes ``np.choose`` to behave the same way as the rest of NumPy +in this respect. |