Skip to content

DOC: note on integers as advanced indices [skip actions] - #33092

Open
pereradrian wants to merge 1 commit into
numpy:mainfrom
pereradrian:doc-advanced-indexing-pitfall
Open

pereradrian wants to merge 1 commit into
numpy:mainfrom
pereradrian:doc-advanced-indexing-pitfall

Conversation

@pereradrian

Copy link
Copy Markdown
Contributor

PR summary

Closes #30022.

The "Integer array indexing" section does not mention that an integer combined
with an integer array also counts as an advanced index. As a result,
x[0, :, [1, 2]] returns shape (2, 5) instead of the (5, 2) many users
expect. The full explanation exists in "Combining advanced and basic indexing",
but readers of the integer-indexing section are unlikely to find it.

Following the minimal approach suggested in the issue, this PR adds a short
note at the end of "Integer array indexing" with the example from the issue
and a link to the section with the full rules. No content is reordered.

Documentation-only change.

First time contributor introduction

Hi! I’m Adrián. I use Python for work, for my studies and for personal projects, with NumPy as a constant part of that. This is my first open source contribution.

AI Disclosure

I used Claude (Anthropic) to help pick a beginner issue, to draft the note
added to basics.indexing.rst, and to draft this PR description. I reviewed
the change, checked the example outputs locally, and I take responsibility
for it. I'll handle all review discussion myself.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DOC: Confusing advanced indexing when mixing tuple, integer, and range

1 participant