a = np.ramdon.rand(10)
# We can index a numpy array by [start:stop(:step)]
a[::1] # returns [a[0], a[1], ..., a[9]]
a[::-1] # returns [a[9], a[8], ..., a[0]]
As shown in the above example, start
and stop
for both a[::1]
and a[::-1]
should be by default, since only the step
arguments are given. For a[::1]
, I suppose the default start
should be 0 and the default stop
should be -1 (i.e., a[::1]
is the same as a[0:-1:1]
), but apparently this is not true for a[::-1]
, since a[0:-1:-1]
returns an empty array. So what are the exact default setting for stop
and start
? I am so confused because all the documentations I ran into only mentioned that to reverse an array you can use ::-1
with no further explanation.