Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated the note for "insert" so that it points to the explanation of why ...0... and ...[0]... are wildly different. #25895 #26114

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion numpy/lib/_function_base_impl.py
Expand Up @@ -5553,7 +5553,9 @@ def insert(arr, obj, values, axis=None):
-----
Note that for higher dimensional inserts ``obj=0`` behaves very different
from ``obj=[0]`` just like ``arr[:,0,:] = values`` is different from
``arr[:,[0],:] = values``.
``arr[:,[0],:] = values``. This is due to the way NumPy handles broadcasting and
axis manipulation. For a detailed explanation, refer to the documentation on
[Broadcasting](https://numpy.org/doc/stable/user/basics.broadcasting.html).
Comment on lines +5556 to +5558

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
``arr[:,[0],:] = values``. This is due to the way NumPy handles broadcasting and
axis manipulation. For a detailed explanation, refer to the documentation on
[Broadcasting](https://numpy.org/doc/stable/user/basics.broadcasting.html).
``arr[:,[0],:] = values``. This is due to the way NumPy handles
:ref:`broadcasting <basics.broadcasting>` and axis manipulation.

Thank you for contributing to Numpy. I noticed the line length was too long and I updated your example to use the internal link structure.


Examples
--------
Expand Down