diff --git a/doc/release/upcoming_changes/20924.compatibility.rst b/doc/release/upcoming_changes/20924.compatibility.rst index 0446b714fe9..02f3e9fdbac 100644 --- a/doc/release/upcoming_changes/20924.compatibility.rst +++ b/doc/release/upcoming_changes/20924.compatibility.rst @@ -8,4 +8,6 @@ now due to the fact that the logic is aligned with item assignment:: # is now identical to: arr[0] = scalar -Previously casting may have produced slightly different answers when using values that could not be represented in the target `dtype` or when using `object`s. +Previously casting may have produced slightly different answers when using +values that could not be represented in the target ``dtype`` or when the +target had ``object`` dtype. diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py index fb9c30d9308..8ee48d24645 100644 --- a/numpy/core/_add_newdocs.py +++ b/numpy/core/_add_newdocs.py @@ -3437,6 +3437,24 @@ >>> a array([1., 1.]) + Fill expects a scalar value and always behaves the same as assigning + to a single array element. The following is a rare example where this + distinction is important: + + >>> a = np.array([None, None], dtype=object) + >>> a[0] = np.array(3) + >>> a + array([array(3), None], dtype=object) + >>> a.fill(np.array(3)) + >>> a + array([array(3), array(3)], dtype=object) + + Where other forms of assignments will array being assigned: + + >>> a[...] = np.array(3) + >>> a + array([3, 3], dtype=object) + """))