Open yuvalwas opened 6 months ago
You're right, extrapolate
is missing a second argument.
It should be
interp_linear = extrapolate(scale(interpolate(A, BSpline(Linear())), xs), Throw())
Notice that the linked PR only addresses the first of the two errors.
That line seems to work for me. What error do you encounter?
julia> itp = interpolate(A, BSpline(Linear()))
21-element interpolate(::Vector{Float64}, BSpline(Linear())) with element type Float64:
0.0
0.1823215567939546
0.3364722366212129
0.47000362924573563
0.5877866649021191
0.6931471805599453
0.7884573603642703
0.8754687373538999
0.9555114450274363
1.0296194171811581
1.0986122886681098
1.1631508098056809
1.2237754316221157
1.2809338454620642
1.33500106673234
1.3862943611198906
1.4350845252893227
1.4816045409242156
1.5260563034950492
1.5686159179138452
1.6094379124341003
Did you not do using Interpolations
before hand?
For me, running
using Interpolations
xs = 1:0.2:5
A = log.(xs)
itp = interpolate(A, BSpline(Linear()))
returns
21-element interpolate(::Vector{Float64}, BSpline(Linear())) with element type Float64:
Error showing value of type Interpolations.BSplineInterpolation{Float64, 1, Vector{Float64}, BSpline{Linear{Throw{OnGrid}}}, Tuple{Base.OneTo{Int64}}}:
ERROR: BoundsError: attempt to access Tuple{} at index [1]
Stacktrace:
[1] getindex(t::Tuple, i::Int64)
@ Base .\tuple.jl:31
[2] _checklubounds(tf::Bool, ls::Tuple{}, us::Tuple{}, xs::Tuple{Int64})
@ Interpolations C:\Users\yuvalw.WISMAIN\.julia\packages\Interpolations\nDwIa\src\Interpolations.jl:420
[3] _checklubounds(tf::Bool, ls::Tuple{Int64}, us::Tuple{Int64}, xs::Tuple{Int64, Int64})
@ Interpolations C:\Users\yuvalw.WISMAIN\.julia\packages\Interpolations\nDwIa\src\Interpolations.jl:420
[4] checklubounds(ls::Tuple{Int64}, us::Tuple{Int64}, xs::Tuple{Int64, Int64})
@ Interpolations C:\Users\yuvalw.WISMAIN\.julia\packages\Interpolations\nDwIa\src\Interpolations.jl:419
[5] _checkbounds(::Interpolations.NeedsCheck, itp::Interpolations.BSplineInterpolation{Float64, 1, Vector{Float64}, BSpline{Linear{Throw{OnGrid}}}, Tuple{Base.OneTo{Int64}}}, x::Tuple{Int64, Int64})
@ Interpolations C:\Users\yuvalw.WISMAIN\.julia\packages\Interpolations\nDwIa\src\Interpolations.jl:417
[6] checkbounds
@ Interpolations C:\Users\yuvalw.WISMAIN\.julia\packages\Interpolations\nDwIa\src\Interpolations.jl:407 [inlined]
[7] isassigned(::Interpolations.BSplineInterpolation{Float64, 1, Vector{Float64}, BSpline{Linear{Throw{OnGrid}}}, Tuple{Base.OneTo{Int64}}}, ::Int64, ::Int64)
@ Base .\multidimensional.jl:1569
[8] alignment(io::IOContext{Base.TTY}, X::AbstractVecOrMat, rows::Vector{Int64}, cols::Vector{Int64}, cols_if_complete::Int64, cols_otherwise::Int64, sep::Int64, ncols::Int64)
@ Base .\arrayshow.jl:68
[9] _print_matrix(io::IOContext{Base.TTY}, X::AbstractVecOrMat, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64, rowsA::UnitRange{Int64}, colsA::UnitRange{Int64})
@ Base .\arrayshow.jl:207
[10] print_matrix(io::IOContext{…}, X::Interpolations.BSplineInterpolation{…}, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64)
@ Base .\arrayshow.jl:171
[11] print_matrix(io::IO, X::AbstractVecOrMat, pre::AbstractString, sep::AbstractString, post::AbstractString, hdots::AbstractString, vdots::AbstractString, ddots::AbstractString, hmod::Integer, vmod::Integer)
@ Base .\arrayshow.jl:171 [inlined]
[12] print_array
@ .\arrayshow.jl:358 [inlined]
[13] show(io::IOContext{Base.TTY}, ::MIME{Symbol("text/plain")}, X::Interpolations.BSplineInterpolation{Float64, 1, Vector{Float64}, BSpline{Linear{Throw{OnGrid}}}, Tuple{Base.OneTo{Int64}}})
@ Base .\arrayshow.jl:399
[14] (::REPL.var"#55#56"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
@ REPL C:\Users\yuvalw.WISMAIN\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\REPL\src\REPL.jl:273
[15] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
@ REPL C:\Users\yuvalw.WISMAIN\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\REPL\src\REPL.jl:569
[16] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
@ REPL C:\Users\yuvalw.WISMAIN\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\REPL\src\REPL.jl:259
[17] display(d::REPL.REPLDisplay, x::Any)
@ REPL C:\Users\yuvalw.WISMAIN\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\REPL\src\REPL.jl:278
[18] display(x::Any)
@ Base.Multimedia .\multimedia.jl:340
[19] #invokelatest#2
@ .\essentials.jl:887 [inlined]
[20] invokelatest
@ .\essentials.jl:884 [inlined]
[21] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
@ REPL C:\Users\yuvalw.WISMAIN\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\REPL\src\REPL.jl:315
[22] (::REPL.var"#57#58"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
@ REPL C:\Users\yuvalw.WISMAIN\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\REPL\src\REPL.jl:284
[23] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
@ REPL C:\Users\yuvalw.WISMAIN\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\REPL\src\REPL.jl:569
[24] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
@ REPL C:\Users\yuvalw.WISMAIN\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\REPL\src\REPL.jl:282
[25] (::REPL.var"#do_respond#80"{Bool, Bool, REPL.var"#93#103"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
@ REPL C:\Users\yuvalw.WISMAIN\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\REPL\src\REPL.jl:911
[26] (::VSCodeServer.var"#101#104"{REPL.var"#do_respond#80"{Bool, Bool, REPL.var"#93#103"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt}})(mi::REPL.LineEdit.MIState, buf::IOBuffer, ok::Bool)
@ VSCodeServer c:\Users\yuvalw.WISMAIN\.vscode\extensions\julialang.language-julia-1.66.2\scripts\packages\VSCodeServer\src\repl.jl:122
[27] #invokelatest#2
@ Base .\essentials.jl:887 [inlined]
[28] invokelatest
@ Base .\essentials.jl:884 [inlined]
[29] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
@ REPL.LineEdit C:\Users\yuvalw.WISMAIN\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\REPL\src\LineEdit.jl:2656
[30] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
@ REPL C:\Users\yuvalw.WISMAIN\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\REPL\src\REPL.jl:1312
[31] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
@ REPL C:\Users\yuvalw.WISMAIN\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\REPL\src\REPL.jl:386
Some type information was truncated. Use `show(err)` to see complete types.
I'm running Interpolations v0.14.7 on Julia 1.10.0. I now see that this is not the newest version of Interpolations, but apparently I can't upgrade due to some compatibility constraint. Also I see now that running
itp = interpolate(A, BSpline(Linear()));
runs just fine, so indeed the problem is only with the displaying
I ran the code from docs homepage:
As a side note, this made me wonder, because the following example does not fail:
Although the first argument to
scale
is exactlyitp
from above which fails. Just for general knowledge, how is it possible that when I evaluate an expression it errors but when this expression is fed into another function it does not? Thanks