This line of code creates a 1000 element array of values, evenly spaced from 0 to 10:
x = range(0,10,length=1000)
The code above works perfectly. This line of code, however, throws an error:
x = range(0,10,length=1e3)
As I understand it, 1000
should be the same thing as 1e3
, and I’ve checked to make sure Julia knows they’re equal:
julia> 1000==1e3
true
Can anyone help me understand why length=1000
works, while length=1e3
throws an error? Here’s the error message it produces, which to me is 30 lines of cryptic nonsense:
TypeError: in keyword argument length, expected Union{Nothing, Integer}, got a value of type Float64
Stacktrace:
[1] top-level scope
@ ~/Documents/coursework/Untitled-1.ipynb:1
[2] eval
@ ./boot.jl:373 [inlined]
[3] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1196
[4] #invokelatest#2
@ ./essentials.jl:716 [inlined]
[5] invokelatest
@ ./essentials.jl:714 [inlined]
[6] (::VSCodeServer.var"#164#165"{VSCodeServer.NotebookRunCellArguments, String})()
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/VSCodeServer/src/serve_notebook.jl:19
[7] withpath(f::VSCodeServer.var"#164#165"{VSCodeServer.NotebookRunCellArguments, String}, path::String)
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/VSCodeServer/src/repl.jl:184
[8] notebook_runcell_request(conn::VSCodeServer.JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, params::VSCodeServer.NotebookRunCellArguments)
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/VSCodeServer/src/serve_notebook.jl:13
[9] dispatch_msg(x::VSCodeServer.JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, dispatcher::VSCodeServer.JSONRPC.MsgDispatcher, msg::Dict{String, Any})
@ VSCodeServer.JSONRPC ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/JSONRPC/src/typed.jl:67
[10] serve_notebook(pipename::String, outputchannel_logger::Base.CoreLogging.SimpleLogger; crashreporting_pipename::String)
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/VSCodeServer/src/serve_notebook.jl:136
[11] top-level scope
@ ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/notebook/notebook.jl:32
[12] include(mod::Module, _path::String)
@ Base ./Base.jl:418
[13] exec_options(opts::Base.JLOptions)
@ Base ./client.jl:292
[14] _start()
@ Base ./client.jl:495