Start, step, length for `range`

I am getting an error when trying to create a range with a start, step, length:

julia> range(start=0, step=fs, length=2^10)
ERROR: MethodError: no method matching range(; start=0, step=0.01, length=1024)

Is there any good reason why this is not a method? It is useful in my context, which is when I know a sampling-frequency, and want to have a length that is a power of 2 for FFT-purposes.

I quickly realized that I can create the wanted range by 0:fs:fs*(2^10-1), but it would be nice to have the more explicit method using range() available - it is useful, as demonstrated by the fact that I initially forgot to include the -1 necessary to get the desired length.

start is a positional argument, so this works

julia> range(0, step=0.01, length=2^10)
0.0:0.01:10.23

There has been this issue recently which discussed the design of the range API in detail:

4 Likes

It was fixed in 1.7. You just need to wait when it will be announced as release candidate. Till that time you should use your workaround or use start as a positional argument as it was said in previous comment.

julia> range(start=0, step=0.01, length=2^10)
0.0:0.01:10.23

julia> versioninfo()
Julia Version 1.7.0-DEV.538
5 Likes

Amazing, good to hear.