I came across an example in the numpy docs where there is an example with a complex step size inside a slice (see the 2nd example).
From experiments, I can see what it is doing; it is similar to np.linspace
.
In [42]: np.r_[-1:1:1j]
Out[42]: array([-1.])
In [43]: np.r_[-1:1:2j]
Out[43]: array([-1., 1.])
In [44]: np.r_[-1:1:3j]
Out[44]: array([-1., 0., 1.])
In [45]: np.r_[-1:1:4j]
Out[45]: array([-1. , -0.33333333, 0.33333333, 1. ])
In [46]: np.r_[-1:1:5j]
Out[46]: array([-1. , -0.5, 0. , 0.5, 1. ])
In [47]: np.r_[-1:1:6j]
Out[47]: array([-1. , -0.6, -0.2, 0.2, 0.6, 1. ])
In [48]: np.all(np.r_[-1:1:6j] == np.linspace(-1, 1, 6))
Out[48]: True
But I can't understand why this is expected. If we consider mathematically, adding a complex number should not change the real part of a number, only it's magnitude, which would only grow with every step!
I tried looking at the indexing docs: in the user guide, as well as the API docs; neither mention complex step sizes in slices.
Any explanation is greatly appreciated.
EDIT: I didn't read the docs thoroughly, as pointed out by the accepted answer, the behaviour is as described in the docs.