Skip to content

Commit

Permalink
DOC: Add example assigning an array using fill and tweak release note
Browse files Browse the repository at this point in the history
  • Loading branch information
seberg committed Jun 12, 2022
1 parent 88b9fc3 commit 5d6d9a3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion doc/release/upcoming_changes/20924.compatibility.rst
Expand Up @@ -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.
18 changes: 18 additions & 0 deletions numpy/core/_add_newdocs.py
Expand Up @@ -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)
"""))


Expand Down

0 comments on commit 5d6d9a3

Please sign in to comment.