Commit e8bbe71c authored by Javier's avatar Javier

Array{<:Real} bug

parent 564b17af
......@@ -95,7 +95,7 @@ function plat_av(obs::Vector{uwreal}, plat::Vector{Int64})
return av
end
function lin_fit(x::Vector{Real}, v::Vector{Float64}, e::Vector{Float64})
function lin_fit(x::Vector{<:Real}, v::Vector{Float64}, e::Vector{Float64})
sig2 = e .* e
S = sum(1 ./ sig2)
Sx = sum(x ./ sig2)
......@@ -108,7 +108,7 @@ function lin_fit(x::Vector{Real}, v::Vector{Float64}, e::Vector{Float64})
return par
end
@doc raw"""
lin_fit(x::Vector{Real}, y::Vector{uwreal})
lin_fit(x::Vector{<:Real}, y::Vector{uwreal})
Computes a linear fit of uwreal data points y. This method return uwreal fit parameters and chisqexpected.
......@@ -117,7 +117,7 @@ fitp, csqexp = lin_fit(phi2, m2)
m2_phys = fitp[1] + fitp[2] * phi2_phys
```
"""
function lin_fit(x::Vector{Real}, y::Vector{uwreal})
function lin_fit(x::Vector{<:Real}, y::Vector{uwreal})
uwerr.(y)
par = lin_fit(x, value.(y), err.(y))
......@@ -150,7 +150,7 @@ The method return an array upar with the best fit parameters with their errors.
@. model(x,p) = p[1] + p[2] * exp(-(p[3]-p[1])*x)
fit_routine(model, ydata, param=3)
"""
function fit_routine(model::Function, xdata::Array{Real}, ydata::Array{uwreal}, param::Int64=3; wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing )
function fit_routine(model::Function, xdata::Array{<:Real}, ydata::Array{uwreal}, param::Int64=3; wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing )
yval = value.(ydata)
yer = err.(ydata)
chisq = gen_chisq(model, xdata, yer)
......@@ -164,7 +164,7 @@ function fit_routine(model::Function, xdata::Array{Real}, ydata::Array{uwreal},
println("Chisq / chiexp: ", chisq(coef(fit), ydata), " / ", chi_exp, " (dof: ", dof(fit),")")
return upar
end
function gen_chisq(f::Function, x::Array{Real}, err::Vector{Float64})
function gen_chisq(f::Function, x::Array{<:Real}, err::Vector{Float64})
chisq(par, dat) = sum((dat .- f(x,par)).^2 ./err.^2)
return chisq
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment