Originally created by: sroec...@gmail.com
What steps will reproduce the problem?
1. import numpy as np
2. dim2_array = np.array( [ [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]] )
3. print( dim2_array[1:2, 2:3] )
What is the expected output? What do you see instead?
Expected:
[[7 8]
[11 12]]
What I get:
[[7]]
It seems that for array slicing, this version treats the first number as base 0, 1, 2, etc for arrays, but the second as base 1, 2, 3, etc.
print( dim2_array[1:3, 2:4] ) gets the desired output, but this doesn't make much sense to me.
What version of the product are you using? On what operating system?
WinPython-64bit-3.3.2.3 on Windows 8
Please provide any additional information below.
View and moderate all "tickets Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Tickets"
Originally posted by: j...@passmore4.com
Actually, I think everything is working exactly as Python is designed. In NumPy array slices, like Python list slices, the second parameter in a🅱️c can be thought of as "up to but not including b." About halfway down this page
http://docs.python.org/2/tutorial/introduction.html#strings
there is an illustration I'll copy here...
"""
One way to remember how slices work is to think of the indices as pointing between characters, with the left edge of the first character numbered 0. Then the right edge of the last character of a string of n characters has index n, for example:
+---+---+---+---+---+
| H | e | l | p | A |
+---+---+---+---+---+
0 1 2 3 4 5
"""
You might want to spend some time on that Python doc page above, or at the following.
http://scipy-lectures.github.io/intro/numpy/array_object.html#indexing-and-slicing
Probably should be marked as non-issue.