diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2021-01-04 22:57:06 -0600 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2021-01-25 13:20:57 -0600 |
commit | 38bda3ce9e6dc075548f378806488ad152c2e46c (patch) | |
tree | e4cf981d93b7ce5f58224a1fb7dfd8a1ebd13ce3 /doc | |
parent | 09416c2934a5f592970e1d97c0298924eed009f6 (diff) | |
download | numpy-38bda3ce9e6dc075548f378806488ad152c2e46c.tar.gz |
DEP: Deprecate promotion of numbers and bool to string
Diffstat (limited to 'doc')
-rw-r--r-- | doc/release/upcoming_changes/18116.future.rst | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/doc/release/upcoming_changes/18116.future.rst b/doc/release/upcoming_changes/18116.future.rst new file mode 100644 index 000000000..1341d022f --- /dev/null +++ b/doc/release/upcoming_changes/18116.future.rst @@ -0,0 +1,29 @@ +Promotion of strings with numbers and bools is deprecated +--------------------------------------------------------- +Any promotion of numbers and strings is deprecated and will +give a ``FutureWarning`` the main affected functionalities +are: + +* `numpy.promote_types` and `numpy.result_type` which will raise + an error in this case in the future. +* `numpy.concatenate` will raise an error when concatenating a string + and numeric array. You can use ``dtype="S"`` to explicitly request + a string result. +* `numpy.array` and related functions will start returning ``object`` + arrays because these functions use ``object`` as a fallback when + no common dtype can be found. (In this case setting the + ``FutureWarning`` to be raised will unfortunately lead to the new + behaviour) + +This will mainly affect code such as:: + + np.asarray(['string', 0]) + +and:: + + np.concatenate((['string'], [0])) + +in both cases adding ``dtype="U"`` or ``dtype="S"`` will give the +previous (string) result. + +Comparisons, universal functions, and casting are not affected by this. |