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

Indexing nd arrays #13

Open
alexjaw opened this issue Feb 14, 2014 · 0 comments
Open

Indexing nd arrays #13

alexjaw opened this issue Feb 14, 2014 · 0 comments

Comments

@alexjaw
Copy link

alexjaw commented Feb 14, 2014

Great notes!
For those of us coming from Matlab trying to learn numpy, i.e. lecture 2.
Everything seems to be easy for vectors and 2D arrays. However, an example with 3D shows a big difference compared to Matlab, which maybe should be highlighted (as the normal 0-indexing).

Say we construct the following 3D array
m = np.arange(8).reshape(2,2,2)

Asking a Matlab person to get the first items (upper left) from the 2 dimensions would result in something like (knowing that indexing starts at 0...)
m[0,0,0] #first item in the first dimension
m[0,0,1] #first item in the second dimension

Expecting the numbers 0 and 4. But the result from the above is 0 and 1, respectively. Quite confusing for someone used to Matlab arrays.

Some clarification on accessing elements i higher dimensional arrays would be of great value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant