-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Open
Description
>>> np.arange(0, 10, 2)
array([0, 2, 4, 6, 8])
# as above, cast to complex
>>> np.arange(0 + 0j, 10 + 0j, 2 + 0j)
array([], dtype=complex128) #what?
# bizarre input needed to give expected output
>>> np.arange(0 + 0j, 10 + 10j, 2 + 0j)
# array([ 0.+0.j, 2.+0.j, 4.+0.j, 6.+0.j, 8.+0.j])
For some reason, it deliberately computes len as (c14792d)
c_len = (start - stop) / step
len = min(ceil(c_len.real), ceil(c_len.imag))
which for real-only values, gives 0
.
I think a better approach would be to use one of
-
ceil(abs(c_len))
- has semantics "use the circle centered atstart
and passing throughend
" as the end point -
ceil(c_len.real)
- has semantics "use the projection ofend
onto the linestart + k*step
as the endpoint" -
above with
assert c_len.imag == 0
- requires thatend
lies on that line, but prone to rounding error -
Project
step
onto the line betweenstart
andend
, and use that instead
I like the look of 2 and 4