summaryrefslogtreecommitdiff
path: root/doc/release/upcoming_changes/22539.change.rst
diff options
context:
space:
mode:
Diffstat (limited to 'doc/release/upcoming_changes/22539.change.rst')
-rw-r--r--doc/release/upcoming_changes/22539.change.rst19
1 files changed, 19 insertions, 0 deletions
diff --git a/doc/release/upcoming_changes/22539.change.rst b/doc/release/upcoming_changes/22539.change.rst
new file mode 100644
index 000000000..9df62be30
--- /dev/null
+++ b/doc/release/upcoming_changes/22539.change.rst
@@ -0,0 +1,19 @@
+``np.r_[]`` and ``np.c_[]`` with certain scalar values
+------------------------------------------------------
+In rare cases, using mainly ``np.r_`` with scalars can lead to different
+results. The main potential changes are highlighted by the following::
+
+ >>> np.r_[np.arange(5, dtype=np.uint8), -1].dtype
+ int16 # rather than the default integer (int64 or int32)
+ >>> np.r_[np.arange(5, dtype=np.int8), 255]
+ array([ 0, 1, 2, 3, 4, 255], dtype=int16)
+
+Where the second example returned::
+
+ array([ 0, 1, 2, 3, 4, -1], dtype=int8)
+
+The first one is due to a signed integer scalar with an unsigned integer
+array, while the second is due to ``255`` not fitting into ``int8`` and
+NumPy currently inspecting values to make this work.
+(Note that the second example is expected to change in the future due to
+:ref:`NEP 50 <NEP50>`; it will then raise an error.)