At the first level of processing, the Python interpreter converts the :: notation to a slice object. In order to interpret these 3 numbers, the numpy.__getitem__ method is used.
[::-1] same as slice(None,None,-1) .
As you note, x[slice(None,None,-1)] does not match x[slice(None,-1,-1)] .
I suspect -1 in:
If j is not given it defaults to n for k > 0 and -1 for k < 0 .
not supposed that way. Rather, it has the usual meaning of -1, the number before 0 .
In [285]: np.arange (10) [slice (5,0, -1)] Out [285]: array ([5, 4, 3, 2, 1])
j interpreted as iterate upto, but not including, this value , and the iteration direction is determined by k . Therefore, the value 0 not included in this fragment.
So how do you turn on 0 ?
In [287]: np.arange(10)[slice(5,-1,-1)] Out[287]: array([], dtype=int32)
does not work, as -1 means n-1 , as in:
In [289]: np.arange(10)[slice(5,-7,-1)] Out[289]: array([5, 4])
None interpreted in a special way, which allows us to use:
In [286]: np.arange(10)[slice(5,None,-1)] Out[286]: array([5, 4, 3, 2, 1, 0])
This also works ( 10-11=-1 - real -1 )
In [291]: np.arange(10)[slice(5,-11,-1)] Out[291]: array([5, 4, 3, 2, 1, 0])
So, there is a difference between -1 , which means before 0 , and -1 , which means count from n . The documentation may be clear, but it is not (if you use the right -1).