Reputation: 167
I have a personal package called VFitApproximation
and there is a function in there called vfitting
. I added a few more parameters to that function after updating my package. I have used Revise, I have removed and added the package to update the library. In fact when I follow the link to the file where the error is coming from, that file has all the reflected changes!
The error is:
ERROR: MethodError: no method matching vfitting(::DataFrame, ::Int64, ::Vector{ComplexF64}; tol=1.0e-10, weightvec=Float64[], force_conjugacy=true)
Closest candidates are:
vfitting(::DataFrame, ::Int64, ::AbstractVector{T} where T) at /home/shubhang/.julia/packages/VFitApproximation/gu1hv/src/VFitApproximation.jl:292 got unsupported keyword arguments "tol", "weightvec", "force_conjugacy"
vfitting(::DataFrame, ::Int64, ::AbstractVector{T} where T, ::Float64) at /home/shubhang/.julia/packages/VFitApproximation/gu1hv/src/VFitApproximation.jl:292 got unsupported keyword arguments "tol", "weightvec", "force_conjugacy"
vfitting(::DataFrame, ::Int64, ::AbstractVector{T} where T, ::Float64, ::AbstractVector{T} where T) at /home/shubhang/.julia/packages/VFitApproximation/gu1hv/src/VFitApproximation.jl:292 got unsupported keyword arguments "tol", "weightvec", "force_conjugacy"
...
The function in question is, in the file where the error is coming from
function vfitting(f_df::DataFrame, m::Int, ξ::AbstractVector, tol::Float64 =1e-10, weightvec::AbstractVector = Float64[], force_conjugacy::Bool=false)
The way I called the function is
approx, err = VFitApproximation.vfitting(spectra_df[:,[1,j]], 10, starting_ξ, tol=1.0e-10, weightvec=Float64[] ,force_conjugacy=true)
I don't know how to fix this, the file and function seem fine but the error continues!
Upvotes: 2
Views: 203
Reputation: 18217
As first detailed in a comment:
In function definition, replace comma ,
between ξ::AbstractVector
and tol::Float64 =1e-10
with semicolon ;
to signify beginning of keyword arguments.
In general, Julia needs to know how to differentiate between positional arguments and keyword arguments. In function definition this is done by separating them with a semicolon (;
), but in function invocation the semicolon is optional and both fun(a1, a2, kw1=v1)
and fun(a1, a2; kw1=v1)
are allowed. The latter (with the ;
) is recommended.
Upvotes: 1