summaryrefslogtreecommitdiff
path: root/doc/release/upcoming_changes/22539.change.rst
blob: 9df62be30d68d8c51aca5b204e4a8d85808fcff7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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.)