Skip to content

Commit

Permalink
@ fix
Browse files Browse the repository at this point in the history
  • Loading branch information
montyvesselinov committed Aug 2, 2024
1 parent 2f9f1f9 commit 95ce7e8
Show file tree
Hide file tree
Showing 38 changed files with 263 additions and 263 deletions.
2 changes: 1 addition & 1 deletion scripts/stipple_cards.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Stipple
import StippleUI

Stipple.@vars Inverter begin
@Stipple.vars Inverter begin
process::Bool = false
input::String = ""
output::String
Expand Down
10 changes: 5 additions & 5 deletions scripts/stipple_checkbox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions scripts/stipple_hello.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import Stipple

Stipple.@vars Name begin
@Stipple.vars Name begin
name::String = "World!"
end

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
Expand Down
2 changes: 1 addition & 1 deletion scripts/stipple_mapbox.jl
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion scripts/stipple_row_cell.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Stipple
import StippleUI

Stipple.@vars Name begin
@Stipple.vars Name begin
name::String = "World!"
end

Expand Down
2 changes: 1 addition & 1 deletion scripts/stipple_row_cell_simple.jl
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/test-parallel-mads-servers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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()
4 changes: 2 additions & 2 deletions scripts/test-parallel-model-coupling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
2 changes: 1 addition & 1 deletion scripts/test-parallel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion src-old/MadsEmcee.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
2 changes: 1 addition & 1 deletion src/Mads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/MadsAnasol.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/MadsBlindSourceSeparation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions src/MadsCalibrate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/MadsDisplay.jl
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/MadsForward.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/MadsFunc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 95ce7e8

Please sign in to comment.