8000 Indexing explanations cleanup by charris · Pull Request #5791 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Indexing explanations cleanup #5791

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

Merged
merged 2 commits into from
Apr 29, 2015

Conversation

charris
Copy link
Member
@charris charris commented Apr 23, 2015

Small fixes to @seberg work in #4331.

@charris charris added this to the 1.10.0 release milestone Apr 23, 2015
* There are only integer array indices so that no subspace exists.
* View based and advanced indexing is mixed. In this case there is a "subspace"
defined by the view based indexing and having the same functionality. For
example for ``arr[[1, 2, 3], :]`` the subspace is defined by ``arr[0, :]``.
Copy link
Member Author

Choose a reason for hiding this comment

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

@seberg I still don't understand the arr[0, :] subspace bit.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, you worked on this. Thanks, though I hate to pass it on.

Well, it was supposed to say that you iterate the advanced indices and what is left is the "subspace" which moves around:

arr = np.ones((3, 4, 5))
arr[indx1, :, indx2]

Then this is much like:

res[0, :] = arr[indx1[0], :, indx2[0]]
res[1, :] = arr[indx1[1], :, indx2[1]]
res[2, :] = arr[indx1[2], :, indx2[2]]
…

If you look at the strides, you get that each of that is:

arr[0, :, 0] + pointer_offset_according_to_arrays

so that arr[0, :, 0] is the "subspace" (might be invalid, but ignore that) and the offset to where we are right now is defined by the current advamced index. Not sure if this all helps, but maybe the long example where you just unravel the advanced indexing helps a lot.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to get something in for 1.10 and figured you could take it up again. Feel free to pull this and close it if you get inspired.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, I've rewritten that bit and replaced "subspace" by "subarray".

Basic cleanup of the new indexing documentation. Also replace
"subspace" by "subarray" and try to clarify mixed advanced and view
indexing.

[skip ci]
@charris charris force-pushed the indexing-explanations-cleanup branch from 615e40a to 0d31348 Compare April 28, 2015 18:25
@charris
Copy link
Member Author
charris commented Apr 29, 2015

@seberg Putting this in as a start. Finish it up when you have the time.

@seberg
Copy link
Member
seberg commented Apr 29, 2015 via email

charris added a commit that referenced this pull request Apr 29, 2015
@charris charris merged commit b282d2a into numpy:master Apr 29, 2015
@charris charris deleted the indexing-explanations-cleanup branch May 25, 2015 18:21
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.

2 participants
0