-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
Conversation
* 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, :]``. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]
615e40a
to
0d31348
Compare
@seberg Putting this in as a start. Finish it up when you have the time. |
OK, thanks.
|
Small fixes to @seberg work in #4331.