diff --git a/scripts/stipple_cards.jl b/scripts/stipple_cards.jl index 25e80864..0909c3c1 100644 --- a/scripts/stipple_cards.jl +++ b/scripts/stipple_cards.jl @@ -1,7 +1,7 @@ import Stipple import StippleUI -Stipple.@vars Inverter begin +@Stipple.vars Inverter begin process::Bool = false input::String = "" output::String diff --git a/scripts/stipple_checkbox.jl b/scripts/stipple_checkbox.jl index a238db80..54d66985 100644 --- a/scripts/stipple_checkbox.jl +++ b/scripts/stipple_checkbox.jl @@ -7,7 +7,7 @@ mutable struct Test Test() = new(0, "") end -Stipple.@reactive! mutable struct UIModelCheckBox <: Stipple.ReactiveModel +@Stipple.reactive! mutable struct UIModelCheckBox <: Stipple.ReactiveModel click::Stipple.R{Int64} = 0 test::Test = Test() test2::Stipple.R{Test} = Test() @@ -17,25 +17,25 @@ end function ui(ui_model_check_box) Stipple.page(ui_model_check_box, class="container", [ Stipple.cell(class="st-module", [ - Stipple.button("Click", StippleUI.@click("click += 1")) + Stipple.button("Click", @StippleUI.click("click += 1")) ]), StippleUI.separator(), Stipple.h5("Clicks: {{this.checks.length}}"), Stipple.p([ "Clicks: " - Stipple.span(ui_model_check_box.click, Stipple.@text(:click)) + Stipple.span(ui_model_check_box.click, @Stipple.text(:click)) ]), Stipple.h5("Test: $(ui_model_check_box.test)"), Stipple.h5("Test: $(ui_model_check_box.test2[])"), Stipple.p([ "Value: " - Stipple.span(ui_model_check_box.test2.a, Stipple.@text(:(test2.a))) + Stipple.span(ui_model_check_box.test2.a, @Stipple.text(:(test2.a))) ]), Stipple.h5("Test: {{this.test.a}}"), Stipple.h5("Test2: {{this.test2.a}}"), Stipple.Html.div( StippleUI.quasar(:checkbox, label = Stipple.R"'checkbox ' + index", fieldname = Stipple.R"checks[index]"), - Stipple.@recur("(item, index) in checks") + @Stipple.recur("(item, index) in checks") ) ]) end diff --git a/scripts/stipple_hello.jl b/scripts/stipple_hello.jl index e5d214fe..716f7eb0 100644 --- a/scripts/stipple_hello.jl +++ b/scripts/stipple_hello.jl @@ -1,6 +1,6 @@ import Stipple -Stipple.@vars Name begin +@Stipple.vars Name begin name::String = "World!" end @@ -8,11 +8,11 @@ function ui() [ Stipple.h1([ "Hello " - Stipple.span("", Stipple.@text(:name)) + Stipple.span("", @Stipple.text(:name)) ]) Stipple.p([ "What is your name? " - Stipple.input("", placeholder="Type your name", Stipple.@bind(:name)) + Stipple.input("", placeholder="Type your name", @Stipple.bind(:name)) ]) ] end diff --git a/scripts/stipple_mapbox.jl b/scripts/stipple_mapbox.jl index 084efb31..2d6cacbf 100644 --- a/scripts/stipple_mapbox.jl +++ b/scripts/stipple_mapbox.jl @@ -1,7 +1,7 @@ import Stipple import StipplePlotly -Stipple.@vars UIMapBox begin +@Stipple.vars UIMapBox begin data::Vector{StipplePlotly.PlotData} = [ StipplePlotly.PlotData( plot = StipplePlotly.Charts.PLOT_TYPE_SCATTERMAPBOX, diff --git a/scripts/stipple_row_cell.jl b/scripts/stipple_row_cell.jl index 797457b0..c5ed79e9 100644 --- a/scripts/stipple_row_cell.jl +++ b/scripts/stipple_row_cell.jl @@ -1,7 +1,7 @@ import Stipple import StippleUI -Stipple.@vars Name begin +@Stipple.vars Name begin name::String = "World!" end diff --git a/scripts/stipple_row_cell_simple.jl b/scripts/stipple_row_cell_simple.jl index fcd776ab..803c12fa 100644 --- a/scripts/stipple_row_cell_simple.jl +++ b/scripts/stipple_row_cell_simple.jl @@ -1,7 +1,7 @@ import Stipple import StippleUI -Stipple.@vars Name begin +@Stipple.vars Name begin name::String = "World!" names::Vector{String} = ["World!", "Stipple!"] end diff --git a/scripts/test-parallel-mads-servers.jl b/scripts/test-parallel-mads-servers.jl index f49f4ef6..fcf483a6 100644 --- a/scripts/test-parallel-mads-servers.jl +++ b/scripts/test-parallel-mads-servers.jl @@ -3,11 +3,11 @@ import Distributed include(joinpath(Mads.dir, "src", "MadsParallel.jl")) @info("Set processors ...") setprocs(mads_servers=true, ntasks_per_node=2) -Distributed.@everywhere display(ENV["PATH"]) +@Distributed.everywhere display(ENV["PATH"]) @info("Import MADS ...") import Mads -Distributed.@everywhere Mads.quietoff() +@Distributed.everywhere Mads.quietoff() @info("Test MADS ... ") Mads.test() diff --git a/scripts/test-parallel-model-coupling.jl b/scripts/test-parallel-model-coupling.jl index 96dc6328..89ebf7e7 100644 --- a/scripts/test-parallel-model-coupling.jl +++ b/scripts/test-parallel-model-coupling.jl @@ -3,11 +3,11 @@ import Distributed include(joinpath(Mads.dir, "src", "MadsParallel.jl")) @info("Set processors ...") setprocs(ntasks_per_node=1) -Distributed.@everywhere display(ENV["PATH"]) +@Distributed.everywhere display(ENV["PATH"]) @info("Import MADS ...") import Mads -Distributed.@everywhere Mads.quietoff() +@Distributed.everywhere Mads.quietoff() @info("Test MADS ... ") Mads.test("model_coupling") diff --git a/scripts/test-parallel.jl b/scripts/test-parallel.jl index b4b4488c..8bd1462b 100644 --- a/scripts/test-parallel.jl +++ b/scripts/test-parallel.jl @@ -6,7 +6,7 @@ setprocs(ntasks_per_node=1) @info("Import MADS ...") import Mads -Distributed.@everywhere Mads.quietoff() +@Distributed.everywhere Mads.quietoff() @info("Test MADS ... ") Mads.test() diff --git a/src-old/MadsEmcee.jl b/src-old/MadsEmcee.jl index 8e71392b..81261ce1 100644 --- a/src-old/MadsEmcee.jl +++ b/src-old/MadsEmcee.jl @@ -36,7 +36,7 @@ function sample(llhood::Function, numwalkers::Integer, x0::AbstractMatrix, numsa batch1 = 1:div(numwalkers, 2) batch2 = div(numwalkers, 2) + 1:numwalkers divisions = [(batch1, batch2), (batch2, batch1)] - ProgressMeter.@showprogress 1 for i = 1:numsamples_perwalker + @ProgressMeter.showprogress 1 for i = 1:numsamples_perwalker for ensembles in divisions active, inactive = ensembles zs = map(u->((a - 1) * u + 1)^2 / a, rand(rng, length(active))) diff --git a/src/Mads.jl b/src/Mads.jl index 773b37c9..ad5cf4e8 100644 --- a/src/Mads.jl +++ b/src/Mads.jl @@ -137,7 +137,7 @@ end if !haskey(ENV, "MADS_NO_PLOT") if !haskey(ENV, "MADS_NO_GADFLY") - Mads.@tryimport Gadfly + @Mads.tryimport Gadfly if !isdefined(Mads, :Gadfly) ENV["MADS_NO_GADFLY"] = "" end diff --git a/src/MadsAnasol.jl b/src/MadsAnasol.jl index e3ec1d18..20117f83 100644 --- a/src/MadsAnasol.jl +++ b/src/MadsAnasol.jl @@ -494,7 +494,7 @@ function computemass(madsfiles::Union{Regex,String}; time::Number=0, path::Abstr lambda = Array{Float64}(undef, nf) mass_injected = Array{Float64}(undef, nf) mass_reduced = Array{Float64}(undef, nf) - ProgressMeter.@showprogress 1 "Computing reduced mass ..." for i = 1:nf + @ProgressMeter.showprogress 1 "Computing reduced mass ..." for i = 1:nf md = Mads.loadmadsfile(joinpath(path, mf[i])) l = md["Parameters"]["lambda"]["init"] lambda[i] = l < eps(Float64) ? 1e-32 : l diff --git a/src/MadsBlindSourceSeparation.jl b/src/MadsBlindSourceSeparation.jl index 8c5f3cdd..31aca341 100644 --- a/src/MadsBlindSourceSeparation.jl +++ b/src/MadsBlindSourceSeparation.jl @@ -73,21 +73,21 @@ function NMFipopt(X::AbstractMatrix, nk::Integer, retries::Integer=1; random::Bo JuMP.set_optimizer_attributes(m, "max_iter" => maxiter, "print_level" => verbosity) # IMPORTANT the order at which parameters are defined is very important if r == 1 && sizeof(initW) != 0 - JuMP.@variable(m, W[i=1:nP, k=1:nk] >= 0., start=initW[i, k]) + @JuMP.variable(m, W[i=1:nP, k=1:nk] >= 0., start=initW[i, k]) elseif r > 1 || random - JuMP.@variable(m, W[1:nP, 1:nk] >= 0., start=rand(Mads.rng)) + @JuMP.variable(m, W[1:nP, 1:nk] >= 0., start=rand(Mads.rng)) else - JuMP.@variable(m, W[1:nP, 1:nk] >= 0., start=0.5) + @JuMP.variable(m, W[1:nP, 1:nk] >= 0., start=0.5) end if r == 1 && sizeof(initH) != 0 - JuMP.@variable(m, H[k=1:nk, j=1:nC] >= 0., start=initH[k, j]) + @JuMP.variable(m, H[k=1:nk, j=1:nC] >= 0., start=initH[k, j]) elseif r > 1 || random - JuMP.@variable(m, H[1:nk, 1:nC] >= 0., start=maxguess * rand(Mads.rng)) + @JuMP.variable(m, H[1:nk, 1:nC] >= 0., start=maxguess * rand(Mads.rng)) else - JuMP.@variable(m, H[1:nk, 1:nC] >= 0., start=maxguess / 2) + @JuMP.variable(m, H[1:nk, 1:nC] >= 0., start=maxguess / 2) end - JuMP.@constraint(m, W .<= 1) # this is very important constraint to make optimization faster - JuMP.@NLobjective(m, Min, sum(sum(weights[i, j] * (sum(W[i, k] * H[k, j] for k=1:nk) - Xc[i, j])^2 for i=1:nP) for j=1:nC)) + @JuMP.constraint(m, W .<= 1) # this is very important constraint to make optimization faster + @JuMP.NLobjective(m, Min, sum(sum(weights[i, j] * (sum(W[i, k] * H[k, j] for k=1:nk) - Xc[i, j])^2 for i=1:nP) for j=1:nC)) JuMP.optimize!(m) phi = JuMP.objective_value(m) !quiet && println("OF = $(phi)") @@ -242,6 +242,6 @@ function MFlm(X::AbstractMatrix{T}, nk::Integer; method::Symbol=:mads, log_W::Bo Wbest, Hbest = mf_reshape(x_best) end end - println("Signals: $(Printf.@sprintf("%2d", nk)) Fit: $(Printf.@sprintf("%12.7g", phi_best))") + println("Signals: $(@Printf.sprintf("%2d", nk)) Fit: $(@Printf.sprintf("%12.7g", phi_best))") return Wbest, Hbest, phi_best end diff --git a/src/MadsCalibrate.jl b/src/MadsCalibrate.jl index 4500832d..073c86cd 100644 --- a/src/MadsCalibrate.jl +++ b/src/MadsCalibrate.jl @@ -56,7 +56,7 @@ function calibraterandom(madsdata::AbstractDict, numberofsamples::Integer=1; tol allparameters = Matrix{Float64}(undef, numberofsamples, length(keys(paramoptvalues))) local bestparameters bestphi = Inf - ProgressMeter.@showprogress 5 "Calibrating ..." for i in 1:numberofsamples + @ProgressMeter.showprogress 5 "Calibrating ..." for i in 1:numberofsamples if i == 1 && first_init !quiet && @info("Using initial values for the first run!") else @@ -130,7 +130,7 @@ function calibraterandom_parallel(madsdata::AbstractDict, numberofsamples::Integ allphi = SharedArrays.SharedArray{Float64}(numberofsamples) allconverged = SharedArrays.SharedArray{Bool}(numberofsamples) allparameters = SharedArrays.SharedArray{Float64}(numberofsamples, length(keys(paramoptvalues))) - @sync Distributed.@distributed for i in 1:numberofsamples + @sync @Distributed.distributed for i in 1:numberofsamples if i == 1 && first_init !quiet && @info("Using initial values for the first run!") else diff --git a/src/MadsDisplay.jl b/src/MadsDisplay.jl index c7106e57..afd288fe 100644 --- a/src/MadsDisplay.jl +++ b/src/MadsDisplay.jl @@ -1,8 +1,8 @@ if !haskey(ENV, "MADS_NO_GADFLY") - Mads.@tryimport Gadfly - Mads.@tryimport Compose + @Mads.tryimport Gadfly + @Mads.tryimport Compose end -Mads.@tryimport Images +@Mads.tryimport Images function display(filename::AbstractString, open::Bool=false) if !graphoutput diff --git a/src/MadsForward.jl b/src/MadsForward.jl index f598b6cf..f693b4d3 100644 --- a/src/MadsForward.jl +++ b/src/MadsForward.jl @@ -117,8 +117,8 @@ function forward(madsdata::AbstractDict, paramarray::AbstractArray; parallel::Bo end r = SharedArrays.SharedArray{Float64}(length(rv1), ncases) r[:, 1] = rv1 - Distributed.@everywhere madsdata_c = $madsdata_c - @sync Distributed.@distributed for i = 2:ncases + @Distributed.everywhere madsdata_c = $madsdata_c + @sync @Distributed.distributed for i = 2:ncases func_forward = Mads.makearrayfunction(madsdata_c) # this is needed to avoid issues with the closure r[:, i] = collect(values(func_forward(vec(psa[i, :])))) end @@ -135,11 +135,11 @@ function forward(madsdata::AbstractDict, paramarray::AbstractArray; parallel::Bo @info("Serial execution of forward runs ...") rv = Array{Array{Float64}}(undef, ncases) if s[2] == np - ProgressMeter.@showprogress 4 for i = 1:ncases + @ProgressMeter.showprogress 4 for i = 1:ncases rv[i] = collect(values(func_forward(vec(paramarray[i, :])))) end else - ProgressMeter.@showprogress 4 for i = 1:ncases + @ProgressMeter.showprogress 4 for i = 1:ncases rv[i] = collect(values(func_forward(vec(paramarray[:, i])))) end end diff --git a/src/MadsFunc.jl b/src/MadsFunc.jl index 2e186460..da0f665d 100644 --- a/src/MadsFunc.jl +++ b/src/MadsFunc.jl @@ -443,7 +443,7 @@ function importeverywhere(filename::AbstractString) end functionname = strip(split(split(code, "function")[2],"(")[1]) extracode = quiet ? "" : "else Mads.madswarn(\"$functionname already defined\")" - fullcode = "import Distributed; Distributed.@everywhere begin if !isdefined(Mads, :$functionname) $code $extracode end end" + fullcode = "import Distributed; @Distributed.everywhere begin if !isdefined(Mads, :$functionname) $code $extracode end end" q = Meta.parse(fullcode) Core.eval(Main, q) functionsymbol = Symbol(functionname) diff --git a/src/MadsInfoGap.jl b/src/MadsInfoGap.jl index 08343624..d984cc7a 100644 --- a/src/MadsInfoGap.jl +++ b/src/MadsInfoGap.jl @@ -3,9 +3,9 @@ import JuMP import MathOptInterface import Colors -Mads.@tryimport Ipopt +@Mads.tryimport Ipopt if !haskey(ENV, "MADS_NO_GADFLY") - Mads.@tryimport Gadfly + @Mads.tryimport Gadfly end """ @@ -43,20 +43,20 @@ function infogap_jump(madsdata::AbstractDict=Dict(); horizons::AbstractVector=[0 pinit[i] = rand(Mads.rng) * (pmax[i] - pmin[i]) + pmin[i] end end - JuMP.@variable(m, p[i=1:np], start=pinit[i]) - JuMP.@variable(m, o[1:no]) - JuMP.@NLconstraint(m, o[1] == p[1] * (ti[1]^p[4]) + p[2] * ti[1] + p[3]) - JuMP.@NLconstraint(m, o[2] == p[1] * (ti[2]^p[4]) + p[2] * ti[2] + p[3]) - JuMP.@NLconstraint(m, o[3] == p[1] * (ti[3]^p[4]) + p[2] * ti[3] + p[3]) - JuMP.@NLconstraint(m, o[4] == p[1] * (ti[4]^p[4]) + p[2] * ti[4] + p[3]) - JuMP.@constraint(m, p[1:np] .>= pmin[1:np]) - JuMP.@constraint(m, p[1:np] .<= pmax[1:np]) - # JuMP.@constraint(m, o[1:no] .>= omin[1:no]) - # JuMP.@constraint(m, o[1:no] .<= omax[1:no]) - JuMP.@constraint(m, o[1:no] .>= t[1:no]-h) - JuMP.@constraint(m, o[1:no] .<= t[1:no]+h) - # JuMP.@NLobjective(m, Min, sum(w[i] * ((p[1] * (ti[i]^p[2]) + p[3] * ti[i] + p[4]) - t[i])^2 for i=1:no)) - JuMP.@NLobjective(m, Max, p[1] * (ti[5]^p[4]) + p[2] * ti[5] + p[3]) + @JuMP.variable(m, p[i=1:np], start=pinit[i]) + @JuMP.variable(m, o[1:no]) + @JuMP.NLconstraint(m, o[1] == p[1] * (ti[1]^p[4]) + p[2] * ti[1] + p[3]) + @JuMP.NLconstraint(m, o[2] == p[1] * (ti[2]^p[4]) + p[2] * ti[2] + p[3]) + @JuMP.NLconstraint(m, o[3] == p[1] * (ti[3]^p[4]) + p[2] * ti[3] + p[3]) + @JuMP.NLconstraint(m, o[4] == p[1] * (ti[4]^p[4]) + p[2] * ti[4] + p[3]) + @JuMP.constraint(m, p[1:np] .>= pmin[1:np]) + @JuMP.constraint(m, p[1:np] .<= pmax[1:np]) + # @JuMP.constraint(m, o[1:no] .>= omin[1:no]) + # @JuMP.constraint(m, o[1:no] .<= omax[1:no]) + @JuMP.constraint(m, o[1:no] .>= t[1:no]-h) + @JuMP.constraint(m, o[1:no] .<= t[1:no]+h) + # @JuMP.NLobjective(m, Min, sum(w[i] * ((p[1] * (ti[i]^p[2]) + p[3] * ti[i] + p[4]) - t[i])^2 for i=1:no)) + @JuMP.NLobjective(m, Max, p[1] * (ti[5]^p[4]) + p[2] * ti[5] + p[3]) JuMP.optimize!(m) phi = JuMP.objective_value(m) println("OF = $(phi)") @@ -78,20 +78,20 @@ function infogap_jump(madsdata::AbstractDict=Dict(); horizons::AbstractVector=[0 end end @show pinit - JuMP.@variable(m, p[i=1:np], start=pinit[i]) - JuMP.@variable(m, o[1:no]) - JuMP.@NLconstraint(m, o[1] == p[1] * (ti[1]^p[4]) + p[2] * ti[1] + p[3]) - JuMP.@NLconstraint(m, o[2] == p[1] * (ti[2]^p[4]) + p[2] * ti[2] + p[3]) - JuMP.@NLconstraint(m, o[3] == p[1] * (ti[3]^p[4]) + p[2] * ti[3] + p[3]) - JuMP.@NLconstraint(m, o[4] == p[1] * (ti[4]^p[4]) + p[2] * ti[4] + p[3]) - JuMP.@constraint(m, p[i=1:np] .>= pmin[i=1:np]) - JuMP.@constraint(m, p[i=1:np] .<= pmax[i=1:np]) - #JuMP.@constraint(m, o[i=1:no] .>= omin[i=1:no]) - #JuMP.@constraint(m, o[i=1:no] .<= omax[i=1:no]) - JuMP.@constraint(m, o[i=1:no] .>= t[i=1:no]-h) - JuMP.@constraint(m, o[i=1:no] .<= t[i=1:no]+h) - #JuMP.@NLobjective(m, Min, sum(w[i] * ((p[1] * (ti[i]^p[2]) + p[3] * ti[i] + p[4]) - t[i])^2 for i=1:no)) - JuMP.@NLobjective(m, Min, p[1] * (ti[5]^p[4]) + p[2] * ti[5] + p[3]) + @JuMP.variable(m, p[i=1:np], start=pinit[i]) + @JuMP.variable(m, o[1:no]) + @JuMP.NLconstraint(m, o[1] == p[1] * (ti[1]^p[4]) + p[2] * ti[1] + p[3]) + @JuMP.NLconstraint(m, o[2] == p[1] * (ti[2]^p[4]) + p[2] * ti[2] + p[3]) + @JuMP.NLconstraint(m, o[3] == p[1] * (ti[3]^p[4]) + p[2] * ti[3] + p[3]) + @JuMP.NLconstraint(m, o[4] == p[1] * (ti[4]^p[4]) + p[2] * ti[4] + p[3]) + @JuMP.constraint(m, p[i=1:np] .>= pmin[i=1:np]) + @JuMP.constraint(m, p[i=1:np] .<= pmax[i=1:np]) + #@JuMP.constraint(m, o[i=1:no] .>= omin[i=1:no]) + #@JuMP.constraint(m, o[i=1:no] .<= omax[i=1:no]) + @JuMP.constraint(m, o[i=1:no] .>= t[i=1:no]-h) + @JuMP.constraint(m, o[i=1:no] .<= t[i=1:no]+h) + #@JuMP.NLobjective(m, Min, sum(w[i] * ((p[1] * (ti[i]^p[2]) + p[3] * ti[i] + p[4]) - t[i])^2 for i=1:no)) + @JuMP.NLobjective(m, Min, p[1] * (ti[5]^p[4]) + p[2] * ti[5] + p[3]) JuMP.optimize!(m) phi = JuMP.objective_value(m) println("OF = $(phi)") @@ -198,52 +198,52 @@ function infogap_jump_polynomial(madsdata::AbstractDict=Dict(); horizons::Abstra end end # @show pi - JuMP.@variable(m, p[i = 1:np], start = pi[i]) - JuMP.@variable(m, o[1:no]) - JuMP.@constraint(m, p[1:np] .>= pmin[1:np]) - JuMP.@constraint(m, p[1:np] .<= pmax[1:np]) - JuMP.@constraint(m, o[1:no] .>= time[1:no] .- h) - JuMP.@constraint(m, o[1:no] .<= time[1:no] .+ h) + @JuMP.variable(m, p[i = 1:np], start = pi[i]) + @JuMP.variable(m, o[1:no]) + @JuMP.constraint(m, p[1:np] .>= pmin[1:np]) + @JuMP.constraint(m, p[1:np] .<= pmax[1:np]) + @JuMP.constraint(m, o[1:no] .>= time[1:no] .- h) + @JuMP.constraint(m, o[1:no] .<= time[1:no] .+ h) if model == 1 if mm == "Max" - JuMP.@NLobjective(m, Max, p[1] * ti[5] + p[2]) + @JuMP.NLobjective(m, Max, p[1] * ti[5] + p[2]) else - JuMP.@NLobjective(m, Min, p[1] * ti[5] + p[2]) + @JuMP.NLobjective(m, Min, p[1] * ti[5] + p[2]) end - JuMP.@NLconstraint(m, o[1] == p[1] * ti[1] + p[2]) - JuMP.@NLconstraint(m, o[2] == p[1] * ti[2] + p[2]) - JuMP.@NLconstraint(m, o[3] == p[1] * ti[3] + p[2]) - JuMP.@NLconstraint(m, o[4] == p[1] * ti[4] + p[2]) + @JuMP.NLconstraint(m, o[1] == p[1] * ti[1] + p[2]) + @JuMP.NLconstraint(m, o[2] == p[1] * ti[2] + p[2]) + @JuMP.NLconstraint(m, o[3] == p[1] * ti[3] + p[2]) + @JuMP.NLconstraint(m, o[4] == p[1] * ti[4] + p[2]) elseif model == 2 if mm == "Max" - JuMP.@NLobjective(m, Max, p[1] * (ti[5]^(1.1)) + p[2] * ti[5] + p[3]) + @JuMP.NLobjective(m, Max, p[1] * (ti[5]^(1.1)) + p[2] * ti[5] + p[3]) else - JuMP.@NLobjective(m, Min, p[1] * (ti[5]^(1.1)) + p[2] * ti[5] + p[3]) + @JuMP.NLobjective(m, Min, p[1] * (ti[5]^(1.1)) + p[2] * ti[5] + p[3]) end - JuMP.@NLconstraint(m, o[1] == p[1] * (ti[1]^(1.1)) + p[2] * ti[1] + p[3]) - JuMP.@NLconstraint(m, o[2] == p[1] * (ti[2]^(1.1)) + p[2] * ti[2] + p[3]) - JuMP.@NLconstraint(m, o[3] == p[1] * (ti[3]^(1.1)) + p[2] * ti[3] + p[3]) - JuMP.@NLconstraint(m, o[4] == p[1] * (ti[4]^(1.1)) + p[2] * ti[4] + p[3]) + @JuMP.NLconstraint(m, o[1] == p[1] * (ti[1]^(1.1)) + p[2] * ti[1] + p[3]) + @JuMP.NLconstraint(m, o[2] == p[1] * (ti[2]^(1.1)) + p[2] * ti[2] + p[3]) + @JuMP.NLconstraint(m, o[3] == p[1] * (ti[3]^(1.1)) + p[2] * ti[3] + p[3]) + @JuMP.NLconstraint(m, o[4] == p[1] * (ti[4]^(1.1)) + p[2] * ti[4] + p[3]) elseif model == 3 if mm == "Max" - JuMP.@NLobjective(m, Max, p[1] * (ti[5]^p[4]) + p[2] * ti[5] + p[3]) + @JuMP.NLobjective(m, Max, p[1] * (ti[5]^p[4]) + p[2] * ti[5] + p[3]) else - JuMP.@NLobjective(m, Min, p[1] * (ti[5]^p[4]) + p[2] * ti[5] + p[3]) + @JuMP.NLobjective(m, Min, p[1] * (ti[5]^p[4]) + p[2] * ti[5] + p[3]) end - JuMP.@NLconstraint(m, o[1] == p[1] * (ti[1]^p[4]) + p[2] * ti[1] + p[3]) - JuMP.@NLconstraint(m, o[2] == p[1] * (ti[2]^p[4]) + p[2] * ti[2] + p[3]) - JuMP.@NLconstraint(m, o[3] == p[1] * (ti[3]^p[4]) + p[2] * ti[3] + p[3]) - JuMP.@NLconstraint(m, o[4] == p[1] * (ti[4]^p[4]) + p[2] * ti[4] + p[3]) + @JuMP.NLconstraint(m, o[1] == p[1] * (ti[1]^p[4]) + p[2] * ti[1] + p[3]) + @JuMP.NLconstraint(m, o[2] == p[1] * (ti[2]^p[4]) + p[2] * ti[2] + p[3]) + @JuMP.NLconstraint(m, o[3] == p[1] * (ti[3]^p[4]) + p[2] * ti[3] + p[3]) + @JuMP.NLconstraint(m, o[4] == p[1] * (ti[4]^p[4]) + p[2] * ti[4] + p[3]) elseif model == 4 if mm == "Max" - JuMP.@NLobjective(m, Max, p[1] * exp(ti[5] * p[4]) + p[2] * ti[5] + p[3]) + @JuMP.NLobjective(m, Max, p[1] * exp(ti[5] * p[4]) + p[2] * ti[5] + p[3]) else - JuMP.@NLobjective(m, Min, p[1] * exp(ti[5] * p[4]) + p[2] * ti[5] + p[3]) + @JuMP.NLobjective(m, Min, p[1] * exp(ti[5] * p[4]) + p[2] * ti[5] + p[3]) end - JuMP.@NLconstraint(m, o[1] == p[1] * exp(ti[1] * p[4]) + p[2] * ti[1] + p[3]) - JuMP.@NLconstraint(m, o[2] == p[1] * exp(ti[2] * p[4]) + p[2] * ti[2] + p[3]) - JuMP.@NLconstraint(m, o[3] == p[1] * exp(ti[3] * p[4]) + p[2] * ti[3] + p[3]) - JuMP.@NLconstraint(m, o[4] == p[1] * exp(ti[4] * p[4]) + p[2] * ti[4] + p[3]) + @JuMP.NLconstraint(m, o[1] == p[1] * exp(ti[1] * p[4]) + p[2] * ti[1] + p[3]) + @JuMP.NLconstraint(m, o[2] == p[1] * exp(ti[2] * p[4]) + p[2] * ti[2] + p[3]) + @JuMP.NLconstraint(m, o[3] == p[1] * exp(ti[3] * p[4]) + p[2] * ti[3] + p[3]) + @JuMP.NLconstraint(m, o[4] == p[1] * exp(ti[4] * p[4]) + p[2] * ti[4] + p[3]) end JuMP.optimize!(m) phi = JuMP.objective_value(m) diff --git a/src/MadsLevenbergMarquardt.jl b/src/MadsLevenbergMarquardt.jl index 94aa72ac..24a51c7e 100644 --- a/src/MadsLevenbergMarquardt.jl +++ b/src/MadsLevenbergMarquardt.jl @@ -385,14 +385,14 @@ function levenberg_marquardt(f::Function, g::Function, x0, o::Function=x->(x'*x) f_calls = 0 g_calls = 0 if np_lambda > 1 - Mads.madsoutput("Parallel lambda search; number of parallel lambdas = $(np_lambda)\n"); + madsoutput("Parallel lambda search; number of parallel lambdas = $(np_lambda)\n"); end fcur = f(x) # TODO execute the initial estimate in parallel with the first_lambda jacobian f_calls += 1 best_residuals = fcur best_of = current_of = o(fcur) - Mads.madsoutput("Initial OF: $(current_of)\n"); + madsoutput("Initial OF: $(current_of)\n"); callbackinitial(x, current_of, NaN) tr = LsqFit.LMTrace{LsqFit.LevenbergMarquardt}() @@ -430,11 +430,11 @@ function levenberg_marquardt(f::Function, g::Function, x0, o::Function=x->(x'*x) end f_calls += length(x) g_calls += 1 - Mads.madsoutput("Jacobian #$(g_calls)\n") + madsoutput("Jacobian #$(g_calls)\n") callbackjacobian(x, J) compute_jacobian = false end - Mads.madsoutput("Current Best OF: $(best_of)\n"); + madsoutput("Current Best OF: $(best_of)\n"); # Solve for: # argmin 0.5*||J(x)*delta_x + f(x)||^2 + lambda*||diagm(J'*J)*delta_x||^2 # Solving for the minimum gives: @@ -452,7 +452,7 @@ function levenberg_marquardt(f::Function, g::Function, x0, o::Function=x->(x'*x) first_lambda = false end lambda_current = lambda_down = lambda_up = lambda - Mads.madsinfo(Printf.@sprintf "Iteration %02d: Starting lambda: %e" g_calls lambda_current) + Mads.madsinfo(@Printf.sprintf "Iteration %02d: Starting lambda: %e" g_calls lambda_current) for npl = 1:np_lambda if npl == 1 # first lambda lambda_current = lambda_p[npl] = lambda @@ -469,7 +469,7 @@ function levenberg_marquardt(f::Function, g::Function, x0, o::Function=x->(x'*x) lambda = lambda_p[npl] predicted_of = [] delta_x = [] - Mads.madsinfo(Printf.@sprintf "#%02d lambda: %e" npl lambda) + Mads.madsinfo(@Printf.sprintf "#%02d lambda: %e" npl lambda) u, s, v = LinearAlgebra.svd(JpJ + lambda * DtDidentity) is = similar(s) for i = eachindex(s) @@ -488,14 +488,14 @@ function levenberg_marquardt(f::Function, g::Function, x0, o::Function=x->(x'*x) # delta_x = (JpJ + lambda * DtDidentity) \ -J' * fcur # TODO replace with SVD predicted_of = o(J * delta_x + fcur) # check for numerical problems in solving for delta_x by ensuring that the predicted residual is smaller than the current residual - Mads.madsoutput("$(Printf.@sprintf "#%02d OF (est): %f" npl predicted_of)", 3); + madsoutput("$(@Printf.sprintf "#%02d OF (est): %f" npl predicted_of)", 3); if predicted_of > current_of + 2max(eps(predicted_of), eps(current_of)) - Mads.madsoutput(" -> not good", 1); + madsoutput(" -> not good", 1); if npl == 1 - Mads.madsoutput("Problem solving for delta_x: predicted residual increase. $(predicted_of) (predicted_of) > $(current_of) (current_of) + $(eps(predicted_of)) (eps)", 2); + madsoutput("Problem solving for delta_x: predicted residual increase. $(predicted_of) (predicted_of) > $(current_of) (current_of) + $(eps(predicted_of)) (eps)", 2); end else - Mads.madsoutput(" -> ok", 1); + madsoutput(" -> ok", 1); end return predicted_of, delta_x end @@ -548,8 +548,8 @@ function levenberg_marquardt(f::Function, g::Function, x0, o::Function=x->(x'*x) npl_best = argmin(trial_ofs) npl_worst = argmax(trial_ofs) - Mads.madsoutput(Printf.@sprintf "OF range in the parallel lambda search: min %e max %e\n" trial_ofs[npl_best] trial_ofs[npl_worst]); - Mads.madsoutput(Printf.@sprintf "Lambda range in the parallel lambda search: best %e worst %e\n" lambda_p[npl_best] lambda_p[npl_worst]); + madsoutput(@Printf.sprintf "OF range in the parallel lambda search: min %e max %e\n" trial_ofs[npl_best] trial_ofs[npl_worst]); + madsoutput(@Printf.sprintf "Lambda range in the parallel lambda search: best %e worst %e\n" lambda_p[npl_best] lambda_p[npl_worst]); lambda = lambda_p[npl_best] # Set lambda to the best value delta_x = vec(delta_xs[npl_best]) trial_f = vec(trial_residuals[npl_best]) diff --git a/src/MadsLog.jl b/src/MadsLog.jl index 2347a76d..f0e09e25 100644 --- a/src/MadsLog.jl +++ b/src/MadsLog.jl @@ -6,7 +6,7 @@ argtext=Dict("message"=>"output message", "level"=>"output verbosity level [default=`0`]"))) """ function madsoutput(message::AbstractString, level::Integer=0) - if !quiet && level < verbositylevel + if !veryquiet && level < verbositylevel print(stderr, message) flush(stdout) flush(stderr) @@ -36,7 +36,7 @@ argtext=Dict("message"=>"information/status message", "level"=>"output verbosity level [default=`0`]"))) """ function madsinfo(message::AbstractString, level::Integer=0) - if !quiet && level < verbositylevel + if !veryquiet && level < verbositylevel println("$(Base.text_colors[:cyan])$(Base.text_colors[:bold])[ Info: $(Base.text_colors[:normal])" * Libc.strftime("%Y-%m-%d %H:%M:%S", time()) * " " * message); flush(stdout); flush(stderr) end end diff --git a/src/MadsMisc.jl b/src/MadsMisc.jl index c0fc2a8d..92f90cbe 100644 --- a/src/MadsMisc.jl +++ b/src/MadsMisc.jl @@ -194,7 +194,7 @@ function evaluatemadsexpressions(madsdata::AbstractDict, parameters::AbstractDic return parameters end -"Convert `Printf.@sprintf` macro into `sprintf` function" +"Convert `@Printf.sprintf` macro into `sprintf` function" sprintf(args...) = Core.eval(Mads, :@Printf.sprintf($(args...))) """ diff --git a/src/MadsMonteCarlo.jl b/src/MadsMonteCarlo.jl index 7b632abd..0d6896da 100644 --- a/src/MadsMonteCarlo.jl +++ b/src/MadsMonteCarlo.jl @@ -152,7 +152,7 @@ function emceesampling(madsdata::AbstractDict, p0::AbstractMatrix; filename::Abs arrayloglikelihood = Mads.makearrayloglikelihood(madsdata, madsloglikelihood) sleep(1) # rest to avoid a "method too new" error if distributed_function - Distributed.@everywhere arrayloglikelihood_distributed = Mads.makearrayloglikelihood($madsdata, $madsloglikelihood) + @Distributed.everywhere arrayloglikelihood_distributed = Mads.makearrayloglikelihood($madsdata, $madsloglikelihood) arrayloglikelihood = (x)->Core.eval(Main, :arrayloglikelihood_distributed)(x) end numsamples_perwalker_burnin = div(burnin, numwalkers) diff --git a/src/MadsObservations.jl b/src/MadsObservations.jl index 49542388..6563b42e 100644 --- a/src/MadsObservations.jl +++ b/src/MadsObservations.jl @@ -418,25 +418,25 @@ function showobservations(madsdata::AbstractDict, obskeys::AbstractVector=getobs bmax = obsdict[obskey]["maxorig"] t = t * (bmax - bmin) + bmin end - s = Printf.@sprintf "%-10s target = %15g" obskey t + s = @Printf.sprintf "%-10s target = %15g" obskey t if !isnan(w) - s *= Printf.@sprintf " weight = %15g" w + s *= @Printf.sprintf " weight = %15g" w end if !isnan(o) - s *= Printf.@sprintf " time = %15g" o + s *= @Printf.sprintf " time = %15g" o end if haskey(obsdict[obskey], "dist") - s *= Printf.@sprintf " dist = %25s" dist[i] + s *= @Printf.sprintf " dist = %25s" dist[i] elseif haskey(obsdict[obskey], "min") && haskey(obsdict[obskey], "max") - s *= Printf.@sprintf " min = %15g" min[i] - s *= Printf.@sprintf " max = %15g" max[i] + s *= @Printf.sprintf " min = %15g" min[i] + s *= @Printf.sprintf " max = %15g" max[i] end if haskey(obsdict[obskey], "minorig") && haskey(obsdict[obskey], "maxorig") if rescale s *= "$(Base.text_colors[:magenta]) <- rescaled $(Base.text_colors[:normal])" else - s *= Printf.@sprintf " minorig = %15g" obsdict[obskey]["minorig"] - s *= Printf.@sprintf " maxorig = %15g" obsdict[obskey]["maxorig"] + s *= @Printf.sprintf " minorig = %15g" obsdict[obskey]["minorig"] + s *= @Printf.sprintf " maxorig = %15g" obsdict[obskey]["maxorig"] end end s *= "\n" diff --git a/src/MadsParallel.jl b/src/MadsParallel.jl index ce168b54..212c678c 100644 --- a/src/MadsParallel.jl +++ b/src/MadsParallel.jl @@ -3,15 +3,15 @@ import LinearAlgebra import Printf if isdefined(Core, :Mads) && !isdefined(Mads, :sprintf) - "Convert `Printf.@sprintf` macro into `sprintf` function" + "Convert `@Printf.sprintf` macro into `sprintf` function" sprintf(args...) = Base.eval(:@Printf.sprintf($(args...))) end quietdefault = true nprocs_per_task_default = 1 madsservers = ["madsmax", "madsmen", "madszem", "madskil", "madsart", "madsend"] # madsdam is out -madsservers2 = vec(["madsmin"; map(i->(Printf.@sprintf "mads%02d" i), 1:18)]) -madsserversall = vec(["madsmax"; "madsmen"; "madszem"; "madskil"; "madsart"; "madsend"; "madsmin"; map(i->(Printf.@sprintf "mads%02d" i), 1:18)]) # madsdam is out +madsservers2 = vec(["madsmin"; map(i->(@Printf.sprintf "mads%02d" i), 1:18)]) +madsserversall = vec(["madsmax"; "madsmen"; "madszem"; "madskil"; "madsart"; "madsend"; "madsmin"; map(i->(@Printf.sprintf "mads%02d" i), 1:18)]) # madsdam is out if isdefined(Main, :Mads) quietdefault = Mads.quiet nprocs_per_task_default = Mads.nprocs_per_task_default @@ -239,9 +239,9 @@ $(DocumentFunction.documentfunction(noplot)) function noplot() if Distributed.myid() == 1 for i in Distributed.workers() - Distributed.@spawnat i ENV["MADS_NO_PLOT"]="" - Distributed.@spawnat i ENV["MADS_NO_PYPLOT"]="" - Distributed.@spawnat i ENV["MADS_NO_GADFLY"]="" + @Distributed.spawnat i ENV["MADS_NO_PLOT"]="" + @Distributed.spawnat i ENV["MADS_NO_PYPLOT"]="" + @Distributed.spawnat i ENV["MADS_NO_GADFLY"]="" end end end @@ -265,8 +265,8 @@ argtext=Dict("dir"=>"directory"))) Example: ```julia -Distributed.@everywhere Mads.setdir() -Distributed.@everywhere Mads.setdir("/home/monty") +@Distributed.everywhere Mads.setdir() +@Distributed.everywhere Mads.setdir("/home/monty") ``` """ setdir @@ -337,7 +337,7 @@ Returns - array string of mads servers """ function setmadsservers(first::Integer=0, last::Integer=18) - map(i->(Printf.@sprintf "mads%02d" i), first:last) + map(i->(@Printf.sprintf "mads%02d" i), first:last) end :loaded \ No newline at end of file diff --git a/src/MadsParameters.jl b/src/MadsParameters.jl index fa31086d..3f59307a 100644 --- a/src/MadsParameters.jl +++ b/src/MadsParameters.jl @@ -766,20 +766,20 @@ function printparameters(madsdata::AbstractDict, parkeys::AbstractVector=Mads.ge end end if haskey(pardict[parkey], "min") - s *= Printf.@sprintf "min = %15g " vmin + s *= @Printf.sprintf "min = %15g " vmin end if haskey(pardict[parkey], "max") - s *= Printf.@sprintf "max = %15g " vmax + s *= @Printf.sprintf "max = %15g " vmax end if haskey(pardict[parkey], "dist") - s *= Printf.@sprintf "distribution = %s " pardict[parkey]["dist"] + s *= @Printf.sprintf "distribution = %s " pardict[parkey]["dist"] end if haskey(pardict[parkey], "minorig") && haskey(pardict[parkey], "maxorig") if rescale s *= "$(Base.text_colors[:magenta]) <- rescaled $(Base.text_colors[:normal])" else - s *= Printf.@sprintf "minorig = %15g " pardict[parkey]["minorig"] - s *= Printf.@sprintf "maxorig = %15g " pardict[parkey]["maxorig"] + s *= @Printf.sprintf "minorig = %15g " pardict[parkey]["minorig"] + s *= @Printf.sprintf "maxorig = %15g " pardict[parkey]["maxorig"] end end if haskey(pardict[parkey], "log" ) && pardict[parkey]["log"] == true diff --git a/src/MadsParsers.jl b/src/MadsParsers.jl index 9a9159eb..87b69e15 100644 --- a/src/MadsParsers.jl +++ b/src/MadsParsers.jl @@ -35,7 +35,7 @@ function amanzi_output_parser(filename::AbstractString="observations.out") flag[cr_index] = 'c' obs_name = Array{String}(undef, no) for i = 1:no - obs_name[i] = w[i] * "$(flag[i])" * "_" * "$(Printf.@sprintf("%.1f", time[i]))" + obs_name[i] = w[i] * "$(flag[i])" * "_" * "$(@Printf.sprintf("%.1f", time[i]))" end dict = OrderedCollections.OrderedDict{Union{String,Symbol},Float64}(zip(obs_name, obs)) return dict diff --git a/src/MadsPlot.jl b/src/MadsPlot.jl index f27fcc03..8e104926 100644 --- a/src/MadsPlot.jl +++ b/src/MadsPlot.jl @@ -173,8 +173,8 @@ function plotmadsproblem(madsdata::AbstractDict; format::AbstractString="", file gadfly_source, Gadfly.Scale.color_discrete_manual("red", "blue"), Gadfly.Coord.Cartesian(ymin=ymin, ymax=ymax, xmin=xmin, xmax=xmax, fixed=true), - Gadfly.Scale.x_continuous(minvalue=xmin, maxvalue=xmax, labels=x->Printf.@sprintf("%.0f", x)), - Gadfly.Scale.y_continuous(minvalue=ymin, maxvalue=ymax, labels=y->Printf.@sprintf("%.0f", y)), gm..., + Gadfly.Scale.x_continuous(minvalue=xmin, maxvalue=xmax, labels=x->@Printf.sprintf("%.0f", x)), + Gadfly.Scale.y_continuous(minvalue=ymin, maxvalue=ymax, labels=y->@Printf.sprintf("%.0f", y)), gm..., Gadfly.Theme(highlight_width=0Gadfly.pt, key_position=:none)) if filename == "" rootname = getmadsrootname(madsdata) @@ -453,7 +453,7 @@ function scatterplotsamples(madsdata::AbstractDict, samples::AbstractMatrix, fil plottypes = [:histogram, :scatter] end nz = convert(Int64, ceil(log10(np))) + 1 - ProgressMeter.@showprogress 1 "Ploting histogram and scatter plots ..." for i in 1:np + @ProgressMeter.showprogress 1 "Ploting histogram and scatter plots ..." for i in 1:np for j in 1:np if i == j && :histogram in plottypes p = Gadfly.plot(x=samples[:, i], Gadfly.Geom.histogram, @@ -756,11 +756,11 @@ function spaghettiplots(madsdata::AbstractDict, paramdictarray::OrderedCollectio end end vsize = 0Gadfly.inch - Mads.madsoutput("Spaghetti plots for each selected model parameter (type != null) ...\n") + madsoutput("Spaghetti plots for each selected model parameter (type != null) ...\n") for paramkey in paramoptkeys - Mads.madsoutput("Parameter: $(paramkey) ...\n") + madsoutput("Parameter: $(paramkey) ...\n") Y = Array{Float64}(undef, nT, numberofsamples) - ProgressMeter.@showprogress 4 "Computing predictions ..." for i in 1:numberofsamples + @ProgressMeter.showprogress 4 "Computing predictions ..." for i in 1:numberofsamples original = paramdict[paramkey] paramdict[paramkey] = paramdictarray[paramkey][i] result = func(paramdict) @@ -888,7 +888,7 @@ function spaghettiplot(madsdata::AbstractDict, dictarray::AbstractDict; seed::In if flag_params numberofsamples = length(dictarray[paramoptkeys[1]]) Y = Array{Float64}(undef, nT, numberofsamples) - ProgressMeter.@showprogress 4 "Computing predictions ..." for i in 1:numberofsamples + @ProgressMeter.showprogress 4 "Computing predictions ..." for i in 1:numberofsamples for paramkey in paramoptkeys paramdict[paramkey] = dictarray[paramkey][i] end diff --git a/src/MadsPublish.jl b/src/MadsPublish.jl index b57bbbf6..b25f34d1 100644 --- a/src/MadsPublish.jl +++ b/src/MadsPublish.jl @@ -7,7 +7,7 @@ $(DocumentFunction.documentfunction(documentation_create)) """ function documentation_create(modules_doc=madsmodulesdoc, modules_load=string.(madsmodules)) for i in modules_load - Core.eval(Main, :(Mads.@tryimportmain $(Symbol(i)))) + Core.eval(Main, :(@Mads.tryimportmain $(Symbol(i)))) end pages=[ "MADS" => "index.md", diff --git a/src/MadsSensitivityAnalysis.jl b/src/MadsSensitivityAnalysis.jl index a5d65414..9f217b34 100644 --- a/src/MadsSensitivityAnalysis.jl +++ b/src/MadsSensitivityAnalysis.jl @@ -74,7 +74,7 @@ function makelocalsafunction(madsdata::AbstractDict; multiplycenterbyweights::Bo fevals = RobustPmap.rpmap(f_sa, p) catch errmsg printerrormsg(errmsg) - Mads.madswarn("RobustPmap executions for localsa fails!") + Mads.madswarn("RobustPmap executions for local sensitivity analysis fails!") return nothing end if !center_computed @@ -507,7 +507,7 @@ function saltellibrute(madsdata::AbstractDict; N::Integer=1000, seed::Integer=-1 for i = eachindex(paramkeys) madsinfo("Parameter : $(string(paramkeys[i]))") cond_means = Array{OrderedCollections.OrderedDict}(undef, numoneparamsamples) - ProgressMeter.@showprogress 1 "Computing ... " for j = 1:numoneparamsamples + @ProgressMeter.showprogress 1 "Computing ... " for j = 1:numoneparamsamples cond_means[j] = OrderedCollections.OrderedDict() for k = eachindex(obskeys) cond_means[j][obskeys[k]] = 0. @@ -547,7 +547,7 @@ function saltellibrute(madsdata::AbstractDict; N::Integer=1000, seed::Integer=-1 madsinfo("Parameter : $(string(paramkeys[i]))") cond_vars = Array{OrderedCollections.OrderedDict}(undef, nummanyparamsamples) cond_means = Array{OrderedCollections.OrderedDict}(undef, nummanyparamsamples) - ProgressMeter.@showprogress 1 "Computing ... " for j = 1:nummanyparamsamples + @ProgressMeter.showprogress 1 "Computing ... " for j = 1:nummanyparamsamples cond_vars[j] = OrderedCollections.OrderedDict{Union{String,Symbol},Float64}() cond_means[j] = OrderedCollections.OrderedDict{Union{String,Symbol},Float64}() for m = eachindex(obskeys) @@ -655,13 +655,13 @@ function saltelli(madsdata::AbstractDict; N::Integer=100, seed::Integer=-1, rng: end end Mads.setseed(seed; rng=rng) - Mads.madsoutput("Number of samples: $N\n"); + madsoutput("Number of samples: $N\n"); paramallkeys = Mads.getparamkeys(madsdata) paramalldict = OrderedCollections.OrderedDict{Union{String,Symbol},Float64}(zip(paramallkeys, Mads.getparamsinit(madsdata))) paramoptkeys = Mads.getoptparamkeys(madsdata) nP = length(paramoptkeys) - Mads.madsoutput("Number of model paramters to be analyzed: $(nP) \n"); - Mads.madsoutput("Number of model evaluations to be perforemed: $(N * 2 + N * nP) \n"); + madsoutput("Number of model paramters to be analyzed: $(nP) \n"); + madsoutput("Number of model evaluations to be perforemed: $(N * 2 + N * nP) \n"); obskeys = Mads.getobskeys(madsdata) nO = length(obskeys) distributions = Mads.getparamdistributions(madsdata) @@ -686,7 +686,7 @@ function saltelli(madsdata::AbstractDict; N::Integer=100, seed::Integer=-1, rng: A = [A s1] B = [B s2] end - Mads.madsoutput( "Computing model outputs to calculate total output mean and variance ... Sample A ...\n" ); + madsoutput( "Computing model outputs to calculate total output mean and variance ... Sample A ...\n" ); function farray(Ai) feval = f(merge(paramalldict, OrderedCollections.OrderedDict{Union{String,Symbol},Float64}(zip(paramoptkeys, Ai)))) result = Array{Float64}(undef, length(obskeys)) @@ -717,7 +717,7 @@ function saltelli(madsdata::AbstractDict; N::Integer=100, seed::Integer=-1, rng: end else if !loadsaltellirestart!(yA, "yA", restartdir) - for i = 1:N + @ProgressMeter.showprogress 1 "Executing Saltelli Sensitivity Analysis ... Sample A ..." for i = 1:N feval = f(merge(paramalldict, OrderedCollections.OrderedDict{Union{String,Symbol},Float64}(zip(paramoptkeys, A[i, :])))) for j = eachindex(obskeys) yA[i, j] = feval[obskeys[j]] @@ -726,7 +726,7 @@ function saltelli(madsdata::AbstractDict; N::Integer=100, seed::Integer=-1, rng: savesaltellirestart(yA, "yA", restartdir) end end - Mads.madsoutput( "Computing model outputs to calculate total output mean and variance ... Sample B ...\n" ); + madsoutput( "Computing model outputs to calculate total output mean and variance ... Sample B ...\n" ); yB = Array{Float64}(undef, N, length(obskeys)) if parallel Bvecs = Array{Vector{Float64}}(undef, size(B, 1)) @@ -745,7 +745,7 @@ function saltelli(madsdata::AbstractDict; N::Integer=100, seed::Integer=-1, rng: end else if !loadsaltellirestart!(yB, "yB", restartdir) - for i = 1:N + @ProgressMeter.showprogress 1 "Executing Saltelli Sensitivity Analysis ... " for i = 1:N feval = f(merge(paramalldict, OrderedCollections.OrderedDict{Union{String,Symbol},Float64}(zip(paramoptkeys, B[i, :])))) for j = eachindex(obskeys) yB[i, j] = feval[obskeys[j]] @@ -764,7 +764,7 @@ function saltelli(madsdata::AbstractDict; N::Integer=100, seed::Integer=-1, rng: end end end - Mads.madsoutput( "Computing model outputs to calculate total output mean and variance ... Sample C ... Parameter $(string(paramoptkeys[i]))\n" ); + madsoutput( "Computing model outputs to calculate total output mean and variance ... Sample C ... Parameter $(string(paramoptkeys[i]))\n" ); yC = Array{Float64}(undef, N, length(obskeys)) if parallel Cvecs = Array{Vector{Float64}}(undef, size(C, 1)) @@ -783,7 +783,7 @@ function saltelli(madsdata::AbstractDict; N::Integer=100, seed::Integer=-1, rng: end else if !loadsaltellirestart!(yC, "yC$(i)", restartdir) - for j = 1:N + @ProgressMeter.showprogress 1 "Executing Saltelli Sensitivity Analysis ... " for j = 1:N feval = f(merge(paramalldict, OrderedCollections.OrderedDict{Union{String,Symbol},Float64}(zip(paramoptkeys, C[j, :])))) for k = eachindex(obskeys) yC[j, k] = feval[obskeys[k]] @@ -998,7 +998,7 @@ function printSAresults(madsdata::AbstractDict, results::AbstractDict) sum = 0 for paramkey in paramkeys sum += mes[obskey][paramkey] - print("\t$(Printf.@sprintf("%f",mes[obskey][paramkey]))") + print("\t$(@Printf.sprintf("%f",mes[obskey][paramkey]))") end print("\t$(sum)") print("\n") @@ -1015,7 +1015,7 @@ function printSAresults(madsdata::AbstractDict, results::AbstractDict) sum = 0 for paramkey in paramkeys sum += tes[obskey][paramkey] - print("\t$(Printf.@sprintf("%f",tes[obskey][paramkey]))") + print("\t$(@Printf.sprintf("%f",tes[obskey][paramkey]))") end print("\t$(sum)") print("\n") @@ -1247,8 +1247,8 @@ function efast(md::AbstractDict; N::Integer=100, M::Integer=6, gamma::Number=4, Ns += 1 Ns_total = Ns * Nr end - Mads.madsoutput("Ns_total has been adjusted (upwards) to obtain optimal Nr/Wi pairing!\n"); - Mads.madsoutput("Ns_total = $(Ns_total) ... Nr = $Nr ... Wi = $Wi ... Ns = $Ns\n"); + madsoutput("Ns_total has been adjusted (upwards) to obtain optimal Nr/Wi pairing!\n"); + madsoutput("Ns_total = $(Ns_total) ... Nr = $Nr ... Wi = $Wi ... Ns = $Ns\n"); return Nr, Wi, Ns, Ns_total end end @@ -1355,15 +1355,15 @@ function efast(md::AbstractDict; N::Integer=100, M::Integer=6, gamma::Number=4, #println("x_svr reshaped test") # If # of processors is <= Nr*nprime+(Nr+1) compute model output in serial - Mads.madsoutput("""Compute model output in serial ... $(P) <= $(Nr*nprime+(Nr+1)) ...\n""") + madsoutput("""Compute model output in serial ... $(P) <= $(Nr*nprime+(Nr+1)) ...\n""") @showprogress 1 "Computing models in serial - Parameter k = $k ($(string(paramkeys[k]))) ... " for i = 1:Ns Y[i, :] = collect(values(f(merge(paramalldict, OrderedCollections.OrderedDict{Union{String,Symbol},Float64}(zip(paramkeys, X[i, :])))))) end else =# # If # of processors is > Nr*nprime+(Nr+1) compute model output in parallel - Mads.madsoutput("Compute model outputs ... $(P) > $(Nr*nprime+(Nr+1)) ...\n") - Mads.madsoutput("Computing model for Parameter k = $k ($(string(paramkeys[k]))) ...\n") + madsoutput("Compute model outputs ... $(P) > $(Nr*nprime+(Nr+1)) ...\n") + madsoutput("Computing model for Parameter k = $k ($(string(paramkeys[k]))) ...\n") if robustpmap if restart @info("RobustPmap for parallel execution of forward runs with restart ...") @@ -1379,8 +1379,8 @@ function efast(md::AbstractDict; N::Integer=100, M::Integer=6, gamma::Number=4, psa = collect(X) # collect to avoid issues if paramarray is a SharedArray r = SharedArrays.SharedArray{Float64}(length(rv1), size(X, 1)) r[:, 1] = rv1 - Distributed.@everywhere md = $md - @sync Distributed.@distributed for i = 2:size(X, 1) + @Distributed.everywhere md = $md + @sync @Distributed.distributed for i = 2:size(X, 1) func_forward = Mads.makemadscommandfunction(md) # this is needed to avoid issues with the closure r[:, i] = collect(values(func_forward(merge(paramalldict, OrderedCollections.OrderedDict{Union{String,Symbol},Float64}(zip(paramkeys, X[i, :])))))) end @@ -1397,7 +1397,7 @@ function efast(md::AbstractDict; N::Integer=100, M::Integer=6, gamma::Number=4, # These will be the sums of variances over all resamplings (Nr loops) AVi = AVci = AV = 0 # Initializing Variances to 0 - Mads.madsoutput("Calculating Fourier coefficients for observations ...\n") + madsoutput("Calculating Fourier coefficients for observations ...\n") ## Calculating Si and Sti (main and total sensitivity indices) # Subtract the average value from Y Y = permutedims(Y .- Statistics.mean(Y)) @@ -1429,7 +1429,7 @@ function efast(md::AbstractDict; N::Integer=100, M::Integer=6, gamma::Number=4, AVci = zeros(ny,1) ## Calculating Si and Sti (main and total sensitivity indices) # Looping over each point in time - ProgressMeter.@showprogress 1 "Calculating Fourier coefficients for observations ... " for i = 1:ny + @ProgressMeter.showprogress 1 "Calculating Fourier coefficients for observations ... " for i = 1:ny # Subtract the average value from Y Y[:,i] = permutedims((Y[:,i] .- Statistics.mean(Y[:,i]))) ## Calculating Fourier coefficients associated with MAIN INDICES @@ -1642,7 +1642,7 @@ function efast(md::AbstractDict; N::Integer=100, M::Integer=6, gamma::Number=4, function sendto(p; args...) for i in p for (nm, val) in args - Distributed.@spawnat(i, Core.eval(Main, Expr(:(=), nm, val))) + @Distributed.spawnat(i, Core.eval(Main, Expr(:(=), nm, val))) end end end diff --git a/src/MadsTest.jl b/src/MadsTest.jl index 210e82cf..4cefc37e 100644 --- a/src/MadsTest.jl +++ b/src/MadsTest.jl @@ -113,7 +113,7 @@ function test_vector(result::AbstractVector, gold::AbstractVector; param=Abstrac fail_diff = d end else - Test.@test it + @Test.test it end end if any(fail_i .== true) diff --git a/src/MadsTryImport.jl b/src/MadsTryImport.jl index 31d1bf80..cdbcbd74 100644 --- a/src/MadsTryImport.jl +++ b/src/MadsTryImport.jl @@ -27,6 +27,6 @@ end "Try to import a module in Main" macro tryimportmain(s::Symbol) quote - Mads.@tryimport $(s) Main + @Mads.tryimport $(s) Main end end \ No newline at end of file diff --git a/src/madsjl.jl b/src/madsjl.jl index 5a698f7a..481aef41 100755 --- a/src/madsjl.jl +++ b/src/madsjl.jl @@ -43,15 +43,15 @@ elseif isfile(string(madscommand, ".jl")) quit() end -Distributed.@everywhere import Mads -Distributed.@everywhere import JLD2 +@Distributed.everywhere import Mads +@Distributed.everywhere import JLD2 madsfile = ARGS[1] if isfile(madsfile) @info("Reading $madsfile ...") - Distributed.@everywhere md = Mads.loadmadsfile(madsfile) - Distributed.@everywhere dir = Mads.getmadsproblemdir(md) - Distributed.@everywhere root = Mads.getmadsrootname(md) + @Distributed.everywhere md = Mads.loadmadsfile(madsfile) + @Distributed.everywhere dir = Mads.getmadsproblemdir(md) + @Distributed.everywhere root = Mads.getmadsrootname(md) elseif ARGS[1] == "help" madsjl_help() quit() diff --git a/test/filename.jl b/test/filename.jl index 575b35cc..4ecaca29 100644 --- a/test/filename.jl +++ b/test/filename.jl @@ -3,7 +3,7 @@ import Test using Printf workdir = "filename_testing" -Mads.@stderrcapture function jpath(file::AbstractString) +@Mads.stderrcapture function jpath(file::AbstractString) joinpath(workdir, file) end @@ -17,17 +17,17 @@ touch(jpath("a-v01.mads")) touch(jpath("a-v02.mads")) touch(jpath("a-v03.mads")) -Test.@testset "Filename" begin +@Test.testset "Filename" begin # Verify that getnextmadsfilename returns the most recently modified file - Test.@test Mads.getnextmadsfilename(jpath("a-v01.mads")) == jpath("a-v03.mads") + @Test.test Mads.getnextmadsfilename(jpath("a-v01.mads")) == jpath("a-v03.mads") sleep(1) touch(jpath("a-v02.mads")) - Test.@test Mads.getnextmadsfilename(jpath("a-v01.mads")) == jpath("a-v02.mads") + @Test.test Mads.getnextmadsfilename(jpath("a-v01.mads")) == jpath("a-v02.mads") # Verify that Mads parses filename prefixes and extensions touch(jpath("test.file.name.txt")) - Test.@test Mads.getrootname(jpath("test.file.name.txt")) == jpath("test") - Test.@test Mads.getextension(jpath("a-v01.mads")) == "mads" + @Test.test Mads.getrootname(jpath("test.file.name.txt")) == jpath("test") + @Test.test Mads.getextension(jpath("a-v01.mads")) == "mads" end Mads.rmdir(workdir) diff --git a/test/io.jl b/test/io.jl index 06282300..dc9baab0 100644 --- a/test/io.jl +++ b/test/io.jl @@ -7,14 +7,14 @@ import Random # If madsdir = '.' then joinpath, else madsdir workdir = (Mads.getproblemdir() == ".") ? joinpath(Mads.dir, "test") : Mads.getproblemdir() -Mads.@stderrcapture function jpath(file::AbstractString) +@Mads.stderrcapture function jpath(file::AbstractString) joinpath(workdir, file) end arr = Dict{String,Float64}("a"=>1, "b"=>1.6) # Define an arbitrary dictionary # Parse extensions and dump/load data accordingly -Mads.@stderrcapture function test_IO(file, data) +@Mads.stderrcapture function test_IO(file, data) ext = Mads.getextension(jpath(file)) if ext == "dat" @@ -41,51 +41,51 @@ df = DataFrames.DataFrame() df[!, :Values] = Random.rand(10) .* floatmax(Float64) Mads.maxtofloatmax!(df) -Suppressor.@suppress Mads.gettime(Dict("o1"=>Dict("c"=>1))) -Suppressor.@suppress global resultshouldbenan = Mads.getweight(Dict("ww"=>10)) +@Suppressor.suppress Mads.gettime(Dict("o1"=>Dict("c"=>1))) +@Suppressor.suppress global resultshouldbenan = Mads.getweight(Dict("ww"=>10)) # Begin the main test block -Test.@testset "IO" begin - Test.@test test_IO("a.dat", arr) - Test.@test test_IO("a.json", arr) - Test.@test test_IO("a.yaml", arr) +@Test.testset "IO" begin + @Test.test test_IO("a.dat", arr) + @Test.test test_IO("a.json", arr) + @Test.test test_IO("a.yaml", arr) # Test removal of files based on root/extension file = "root_testing.extension_testing" Mads.dumpasciifile(jpath(file), arr) - Test.@test isfile(jpath(file)) == true + @Test.test isfile(jpath(file)) == true Mads.rmfiles_ext(String(Mads.getextension(file)); path=workdir) - Test.@test isfile(jpath(file)) == false + @Test.test isfile(jpath(file)) == false Mads.dumpasciifile(jpath(file), arr) Mads.rmfiles(Regex(file); path=workdir) - Test.@test isfile(jpath(file)) == false + @Test.test isfile(jpath(file)) == false Mads.dumpasciifile(jpath(file), arr) - Test.@test isfile(jpath(file)) == true + @Test.test isfile(jpath(file)) == true Mads.rmfiles_root(String(Mads.getrootname(file)); path=workdir) - Test.@test isfile(jpath(file)) == false + @Test.test isfile(jpath(file)) == false - Test.@test Mads.getrestartdir(Dict("Restart"=>"dummy_restart_directory")) == joinpath("dummy_restart_directory", "") - Test.@test Mads.getrestartdir(Dict("RestartDir"=>"dummy_restart_directory")) == joinpath("dummy_restart_directory", "") + @Test.test Mads.getrestartdir(Dict("Restart"=>"dummy_restart_directory")) == joinpath("dummy_restart_directory", "") + @Test.test Mads.getrestartdir(Dict("RestartDir"=>"dummy_restart_directory")) == joinpath("dummy_restart_directory", "") Mads.rmdir("dummy_restart_directory") - Test.@test Mads.getparamrandom(Dict(), "k") === nothing - Test.@test Mads.getparamrandom(Dict("Parameters"=>Dict("a"=>1)), "k") === nothing - Test.@test Mads.isopt(Dict("Parameters"=>Dict("k"=>Dict("init"=>1,"type"=>false))), "k") == false - Test.@test Mads.isopt(Dict("Parameters"=>Dict("k"=>Dict("init"=>1,"type"=>"opt"))), "k") == true - Test.@test Mads.setparamon!(Dict("Parameters"=>Dict("k"=>Dict{String,Any}("init"=>1,"type"=>false))), "k") == "opt" - Test.@test Mads.setparamoff!(Dict("Parameters"=>Dict("k"=>Dict{String,Any}("init"=>1,"type"=>false))), "k") === nothing + @Test.test Mads.getparamrandom(Dict(), "k") === nothing + @Test.test Mads.getparamrandom(Dict("Parameters"=>Dict("a"=>1)), "k") === nothing + @Test.test Mads.isopt(Dict("Parameters"=>Dict("k"=>Dict("init"=>1,"type"=>false))), "k") == false + @Test.test Mads.isopt(Dict("Parameters"=>Dict("k"=>Dict("init"=>1,"type"=>"opt"))), "k") == true + @Test.test Mads.setparamon!(Dict("Parameters"=>Dict("k"=>Dict{String,Any}("init"=>1,"type"=>false))), "k") == "opt" + @Test.test Mads.setparamoff!(Dict("Parameters"=>Dict("k"=>Dict{String,Any}("init"=>1,"type"=>false))), "k") === nothing Mads.getparamdistributions(Dict("Parameters"=>Dict("k"=>Dict("init"=>1,"init_dist"=>"Normal(0,1)"))); init_dist=true) - Test.@test Mads.settime!(Dict("t"=>1),2) == 2 - Test.@test Mads.setweight!(Dict("w"=>1),2) == 2 - Test.@test Mads.getweight(Dict("w"=>1)) == 1 - Test.@test Mads.settarget!(Dict("c"=>1),2) == 2 - Test.@test isnan(resultshouldbenan) + @Test.test Mads.settime!(Dict("t"=>1),2) == 2 + @Test.test Mads.setweight!(Dict("w"=>1),2) == 2 + @Test.test Mads.getweight(Dict("w"=>1)) == 1 + @Test.test Mads.settarget!(Dict("c"=>1),2) == 2 + @Test.test isnan(resultshouldbenan) Mads.seed!(2017, Random.MersenneTwister) - Test.@test isapprox(Mads.getparamrandom(Dict("Parameters"=>Dict("k"=>Dict("init"=>1,"log"=>true,"dist"=>"Normal(1,10)"))), "k")..., 0.107554; atol=1e-5) + @Test.test isapprox(Mads.getparamrandom(Dict("Parameters"=>Dict("k"=>Dict("init"=>1,"log"=>true,"dist"=>"Normal(1,10)"))), "k")..., 0.107554; atol=1e-5) end :passed \ No newline at end of file diff --git a/test/miscellaneous.jl b/test/miscellaneous.jl index acdc35e6..5d51d278 100644 --- a/test/miscellaneous.jl +++ b/test/miscellaneous.jl @@ -64,7 +64,7 @@ end Mads.stdouterrcaptureon() Mads.printerrormsg("a") -Mads.madsoutput("a") +madsoutput("a") Mads.madsdebug("a") Mads.madsinfo("Testing ...") Mads.help() @@ -145,13 +145,13 @@ else Mads.graphoff() end -Test.@test Mads.haskeyword(Dict("Problem"=>"ssdr"),"ssdr") == true -Test.@test Mads.haskeyword(Dict("Problem"=>Dict("ssdr"=>true)), "ssdr") == true -Test.@test Mads.haskeyword(Dict("Problem"=>["ssdr","paranoid"]), "ssdr") == true -Test.@test Mads.haskeyword(Dict("Problem"=>0.1), "Problem", "ssdr") == false +@Test.test Mads.haskeyword(Dict("Problem"=>"ssdr"),"ssdr") == true +@Test.test Mads.haskeyword(Dict("Problem"=>Dict("ssdr"=>true)), "ssdr") == true +@Test.test Mads.haskeyword(Dict("Problem"=>["ssdr","paranoid"]), "ssdr") == true +@Test.test Mads.haskeyword(Dict("Problem"=>0.1), "Problem", "ssdr") == false -Test.@test Mads.getdir("a.mads") == "." -Test.@test Mads.getdir("test/a.mads") == "test" +@Test.test Mads.getdir("a.mads") == "." +@Test.test Mads.getdir("test/a.mads") == "test" Mads.createobservations(4, 2; filename="a.inst") Mads.rmfile("a.inst") diff --git a/test/observations.jl b/test/observations.jl index 482439ff..390851bf 100644 --- a/test/observations.jl +++ b/test/observations.jl @@ -2,23 +2,23 @@ import Mads import Test # Test observations functions -Test.@testset "Observations" begin +@Test.testset "Observations" begin test_dict = Dict("a"=>1) - Test.@test Mads.isobs(test_dict, Dict("a"=>1)) == true + @Test.test Mads.isobs(test_dict, Dict("a"=>1)) == true test_dict["b"] = 2 - Test.@test Mads.isobs(test_dict, Dict("a"=>1)) == false + @Test.test Mads.isobs(test_dict, Dict("a"=>1)) == false obs_dict = Dict("Observations"=>Dict("a"=>Dict())) - Test.@test Mads.getobsdist(obs_dict) == String["Uniform(-Inf, Inf)"] + @Test.test Mads.getobsdist(obs_dict) == String["Uniform(-Inf, Inf)"] obs_dict["Observations"]["a"] = Dict("log"=>true) - Test.@test Mads.getobsmin(obs_dict)[1] ≈ eps(Float64) - Test.@test Mads.getobsmax(obs_dict)[1] ≈ Inf + @Test.test Mads.getobsmin(obs_dict)[1] ≈ eps(Float64) + @Test.test Mads.getobsmax(obs_dict)[1] ≈ Inf obs_dict = Dict("Observations"=>Dict("a"=>Dict("dist"=>"Uniform(14,15)"))) - Test.@test Mads.getobsmin(obs_dict) == [14] - Test.@test Mads.getobsmax(obs_dict) == [15] + @Test.test Mads.getobsmin(obs_dict) == [14] + @Test.test Mads.getobsmax(obs_dict) == [15] global a=4; b=12; c=7 test_dict = Dict("a"=>1) @@ -27,7 +27,7 @@ Test.@testset "Observations" begin Mads.setweight!(test_dict, b) Mads.settarget!(test_dict, c) - Test.@test Mads.gettime(test_dict) == a - Test.@test Mads.getweight(test_dict) == b - Test.@test Mads.gettarget(test_dict) == c + @Test.test Mads.gettime(test_dict) == a + @Test.test Mads.getweight(test_dict) == b + @Test.test Mads.gettarget(test_dict) == c end \ No newline at end of file diff --git a/test/parameters.jl b/test/parameters.jl index a602621f..1b7c1a8e 100644 --- a/test/parameters.jl +++ b/test/parameters.jl @@ -1,41 +1,41 @@ import Mads import Test -Test.@testset "Parameters" begin +@Test.testset "Parameters" begin test_dict = Dict("a"=>1) - Test.@test Mads.isparam(test_dict, Dict("a"=>1)) == true + @Test.test Mads.isparam(test_dict, Dict("a"=>1)) == true test_dict["b"] = 1 - Test.@test Mads.isparam(test_dict, Dict("a"=>1)) == false + @Test.test Mads.isparam(test_dict, Dict("a"=>1)) == false param_dict = Dict("Parameters"=>Dict("a"=>Dict())) - Test.@test Mads.getparamsmin(param_dict) == [-Inf] - Test.@test Mads.getparamsmax(param_dict) == [Inf] + @Test.test Mads.getparamsmin(param_dict) == [-Inf] + @Test.test Mads.getparamsmax(param_dict) == [Inf] param_dict["Parameters"]["a"] = Dict("log"=>true) - Test.@test Mads.getparamsmin(param_dict) == [eps(Float64)] - Test.@test Mads.getparamsmax(param_dict) == [Inf] - Test.@test Mads.getparamsinit_min(param_dict) == [eps(Float64)] - Test.@test Mads.getparamsinit_max(param_dict) == [Inf] + @Test.test Mads.getparamsmin(param_dict) == [eps(Float64)] + @Test.test Mads.getparamsmax(param_dict) == [Inf] + @Test.test Mads.getparamsinit_min(param_dict) == [eps(Float64)] + @Test.test Mads.getparamsinit_max(param_dict) == [Inf] param_dict["Parameters"]["a"] = Dict("init_min"=>14) - Test.@test Mads.getparamsinit_min(param_dict) == [14] + @Test.test Mads.getparamsinit_min(param_dict) == [14] param_dict["Parameters"]["a"] = Dict("init_max"=>16) - Test.@test Mads.getparamsinit_max(param_dict) == [16] + @Test.test Mads.getparamsinit_max(param_dict) == [16] dist_dict = Dict("Parameters"=>Dict("a"=>Dict("log"=>true, "type"=>"opt", "dist"=>"Uniform(14,15)"))) - Test.@test isapprox(Mads.getparamrandom(dist_dict, "a")[1], 14.5, atol=0.5) + @Test.test isapprox(Mads.getparamrandom(dist_dict, "a")[1], 14.5, atol=0.5) #dist_dict["Parameters"]["a"]["dist"] = "Normal(14,7)" #println(Mads.getparamrandom(dist_dict, "a")) - Test.@test Mads.void2nan!(Dict("a"=>Dict{Any,Any}("a"=>nothing))) === nothing - Test.@test Mads.void2nan!(Dict("a"=>Dict{Any,Any}("a"=>Dict{Any,Any}("a"=>nothing)))) === nothing + @Test.test Mads.void2nan!(Dict("a"=>Dict{Any,Any}("a"=>nothing))) === nothing + @Test.test Mads.void2nan!(Dict("a"=>Dict{Any,Any}("a"=>Dict{Any,Any}("a"=>nothing)))) === nothing basic_dict = Dict("a"=>1) - Test.@test Mads.filterkeys(basic_dict, "a") == String["a"] - Test.@test Mads.filterkeys(basic_dict, r"a") == String["a"] - Test.@test Mads.getdictvalues(basic_dict, "a")[1][2] == 1 - Test.@test Mads.getdictvalues(basic_dict, r"a")[1][2] == 1 + @Test.test Mads.filterkeys(basic_dict, "a") == String["a"] + @Test.test Mads.filterkeys(basic_dict, r"a") == String["a"] + @Test.test Mads.getdictvalues(basic_dict, "a")[1][2] == 1 + @Test.test Mads.getdictvalues(basic_dict, r"a")[1][2] == 1 # TODO: Verify that maxtofloatmax! is working correctly...returns `nothing` currently - #Test.@test 4 == Mads.maxtofloatmax!(convert(DataFrames.DataFrame, [1:4 1:4])) - #Test.@test floatmax(Float32) == Mads.maxtofloatmax!(convert(DataFrames.DataFrame, [[1,2] [1,floatmax(Float64)]])) + #@Test.test 4 == Mads.maxtofloatmax!(convert(DataFrames.DataFrame, [1:4 1:4])) + #@Test.test floatmax(Float32) == Mads.maxtofloatmax!(convert(DataFrames.DataFrame, [[1,2] [1,floatmax(Float64)]])) end \ No newline at end of file diff --git a/test/test_functions.jl b/test/test_functions.jl index 7f618b60..35ef18c2 100644 --- a/test/test_functions.jl +++ b/test/test_functions.jl @@ -4,14 +4,14 @@ import Random Mads.seed!(2017, Random.MersenneTwister) -Test.@testset "Functions" begin - Test.@test isapprox(Mads.rosenbrock_gradient!(rand(Mads.rng, 2), Array{Float64}(undef, 2)), 95, atol=10) - Test.@test Mads.rosenbrock_hessian!(rand(Mads.rng, 2),Array{Float64}(undef, 2,2)) == 200.0 - Test.@test all((Mads.makerosenbrock(2))([1,1]) .== [0,0]) - Test.@test all((Mads.makerosenbrock_gradient(2))([1,1]) .== [-1 0; -20 10]) - Test.@test all((Mads.makepowell(8))([1,1,1,1,1,1,1,1]) .== [11.0,0.0,1.0,0.0,11.0,0.0,1.0,0.0]) +@Test.testset "Functions" begin + @Test.test isapprox(Mads.rosenbrock_gradient!(rand(Mads.rng, 2), Array{Float64}(undef, 2)), 95, atol=10) + @Test.test Mads.rosenbrock_hessian!(rand(Mads.rng, 2),Array{Float64}(undef, 2,2)) == 200.0 + @Test.test all((Mads.makerosenbrock(2))([1,1]) .== [0,0]) + @Test.test all((Mads.makerosenbrock_gradient(2))([1,1]) .== [-1 0; -20 10]) + @Test.test all((Mads.makepowell(8))([1,1,1,1,1,1,1,1]) .== [11.0,0.0,1.0,0.0,11.0,0.0,1.0,0.0]) - Test.@test all(isapprox(Mads.makepowell_gradient(8)([1,1,1,1,1,1,1,1]), [1.0 10.0 0.0 0.0 0.0 0.0 0.0 0.0; + @Test.test all(isapprox(Mads.makepowell_gradient(8)([1,1,1,1,1,1,1,1]), [1.0 10.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 2.23607 -2.23607 0.0 0.0 0.0 0.0; 0.0 -2.0 4.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 -0.0 0.0 0.0 0.0 0.0; @@ -20,12 +20,12 @@ Test.@testset "Functions" begin 0.0 0.0 0.0 0.0 0.0 -2.0 4.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.0], atol=1e-2)) - Test.@test all(Mads.makesphere(2)([1,1]) .== [1,1]) - Test.@test all(Mads.makesphere_gradient(2)([1,1]) .== [1 0; 0 1]) - Test.@test all(isapprox(Mads.makedixonprice(2)([1,1]), [0.0,1.41421], atol=1e-2)) - Test.@test all(isapprox(Mads.makedixonprice_gradient(2)([1,1]), [1.41421 -2.0; 0.0 8.0], atol=1e-2)) - Test.@test all(isapprox(Mads.makesumsquares(2)([1,1]), [1.0,1.41421], atol=1e-2)) - Test.@test all(isapprox(Mads.makesumsquares_gradient(2)([1,1]), [1.41421 0.0; 0.0 2.0], atol=1e-2)) - Test.@test all(isapprox(Mads.makerotatedhyperellipsoid(2)([1,1]), [1.0,1.41421], atol=1e-2)) - Test.@test all(isapprox(Mads.makerotatedhyperellipsoid_gradient(2)([1,1]), [1.41421 1.0; 0.0 1.0], atol=1e-2)) + @Test.test all(Mads.makesphere(2)([1,1]) .== [1,1]) + @Test.test all(Mads.makesphere_gradient(2)([1,1]) .== [1 0; 0 1]) + @Test.test all(isapprox(Mads.makedixonprice(2)([1,1]), [0.0,1.41421], atol=1e-2)) + @Test.test all(isapprox(Mads.makedixonprice_gradient(2)([1,1]), [1.41421 -2.0; 0.0 8.0], atol=1e-2)) + @Test.test all(isapprox(Mads.makesumsquares(2)([1,1]), [1.0,1.41421], atol=1e-2)) + @Test.test all(isapprox(Mads.makesumsquares_gradient(2)([1,1]), [1.41421 0.0; 0.0 2.0], atol=1e-2)) + @Test.test all(isapprox(Mads.makerotatedhyperellipsoid(2)([1,1]), [1.0,1.41421], atol=1e-2)) + @Test.test all(isapprox(Mads.makerotatedhyperellipsoid_gradient(2)([1,1]), [1.41421 1.0; 0.0 1.0], atol=1e-2)) end \ No newline at end of file