text:
# Chunk
# =====
#
# Consecutive range of BGZF files.
#
# This file is a part of BioJulia.
# License is MIT: https://github.com/BioJulia/Bio.jl/blob/master/LICENSE.md

# BGZF file chunk [.start, .stop).
struct Chunk
    start::BGZFStreams.VirtualOffset
    stop::BGZFStreams.VirtualOffset
end

function Base.in(voffset::BGZFStreams.VirtualOffset, chunk::Chunk)
    return chunk.start ≤ voffset < chunk.stop
end

function Base.:(==)(chunk1::Chunk, chunk2::Chunk)
    return chunk1.start == chunk2.start && chunk1.stop == chunk2.stop
end

function Base.isless(chunk1::Chunk, chunk2::Chunk)

    if isless(chunk1.start, chunk2.start)
        return true
    end

    if chunk1.start == chunk2.start && isless(chunk1.stop, chunk2.stop)
        return true
    end

    return false
end

function Base.seek(stream::BGZFStreams.BGZFStream, chunk::Chunk)
    return seek(stream, chunk.start)
end


text:
@testset "Lifting Line" begin

    section_models = fill(Steady(), 2)
    submodel = Submodel(LiftingLine(section_models))
    submodel_jacobian_tests(submodel)
    submodel_io_tests(submodel)

    section_models = fill(QuasiSteady(), 2)
    submodel = Submodel(LiftingLine(section_models))
    submodel_jacobian_tests(submodel)
    submodel_io_tests(submodel)

    section_models = fill(Wagner(), 2)
    submodel = Submodel(LiftingLine(section_models))
    submodel_jacobian_tests(submodel)
    submodel_io_tests(submodel)

    section_models = fill(Peters{4}(), 2)
    submodel = Submodel(LiftingLine(section_models))
    submodel_jacobian_tests(submodel)
    submodel_io_tests(submodel)

end

ext: jl


text:
#! /usr/bin/julia

# Rosetta Code, N'th

function sprintfordinal{T<:Integer}(n::T)
    const sfixes = ["st", "nd", "rd"]
    0 <= n || throw(ArgumentError("number to be formatted must be ≥ 0, got $n"))
    u = n%10
    t = div(n, 10)%10
    if 3 < u || u == 0 || t == 1
        sf = "th"
    else
        sf = sfixes[u]
    end
    @sprintf "%d%s" n sf
end

println("Tests of ordinal formatting of integers.")
for (i, n) in enumerate(0:25)
    if (i-1)%10 == 0
        print("\n   ")
    end
    print(@sprintf("%7s", sprintfordinal(n)))
end
println()

for (i, n) in enumerate(250:265)
    if (i-1)%10 == 0
        print("\n   ")
    end
    print(@sprintf("%7s", sprintfordinal(n)))
end
println()

for (i, n) in enumerate(1000:1025)
    if (i-1)%10 == 0
        print("\n   ")
    end
    print(@sprintf("%7s", sprintfordinal(n)))
end
println()

max_stars_repo_name: MichaeLeroy/rosetta-code

max_issues_repo_name: MichaeLeroy/rosetta-code

max_forks_repo_name: MichaeLeroy/rosetta-code


text:
function calcSim(duals, dist, S)
    if dist == "L1"
        # Measures L1 distance - Minkowski with p=1
        # https://juliahub.com/docs/LSHFunctions/nLuMy/0.1.2/similarities/lp_distance/
        Sim = collect(ℓ1(duals[i,:],duals[j,:]) for i in S, j in S)
    elseif dist == "L2"
        # Measures L2 distance - Minkowski with p=1
        # https://juliahub.com/docs/LSHFunctions/nLuMy/0.1.2/similarities/lp_distance/
        Sim = collect(ℓ2(duals[i,:],duals[j,:]) for i in S, j in S)
    elseif dist == "jaccard"
        # Measures Jaccard similarity
        # https://juliahub.com/docs/LSHFunctions/nLuMy/0.1.2/similarities/jaccard/
        Sim = collect(LSHFunctions.jaccard(duals[i,:],duals[j,:]) for i in S, j in S)
    elseif dist in ["wcityblock" "weuclidean" "whamming" "wsqeuclidean"]
        # Weighted metrics with equal weights
        W = ones(length(T))
        Sim = collect(Distances.eval(Symbol(dist))(duals[i,:],duals[j,:],W)+0. for i in S, j in S)
    elseif dist in ["wcityblockvar" "weuclideanvar" "whammingvar" "wsqeuclideanvar"]
        # Weighted metrics with weights proportional to variance
        dist = dist[1:end-3] # Renaming to use proper function
        W = var(duals, dims=1)
        Sim = collect(Distances.eval(Symbol(dist))(duals[i,:],duals[j,:],W)+0. for i in S, j in S)
    elseif dist in ["wcityblockinv" "weuclideaninv" "whamminginv" "wsqeuclideaninv"]
        dist = dist[1:end-3] # Renaming to use proper function
        # Weighted metrics with weights inverse to variance
        VAR = var(duals, dims=1)
        W = 1  .- VAR./maximum(VAR)
        Sim = collect(Distances.eval(Symbol(dist))(duals[i,:],duals[j,:],W)+0. for i in S, j in S)
    else
        Sim = collect(Distances.eval(Symbol(dist))(duals[i,:],duals[j,:])+0. for i in S, j in S)
    end
    return Sim
end

max_stars_repo_name: gonzalez-alvaro/MultidimensionalGAPM

max_issues_repo_name: gonzalez-alvaro/MultidimensionalGAPM

max_forks_repo_name: gonzalez-alvaro/MultidimensionalGAPM


text:
precompile(Tuple{Type{Array{T, 2} where T}, FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}})
precompile(Tuple{Type{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Axes, F, Args} where Args<:Tuple where F where Axes}, typeof(Base.:(+)), Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Base.:(*)), Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{0}, Nothing, typeof(Base.:(-)), Tuple{Int64, Float64}}, Array{Float64, 1}}}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Base.:(*)), Tuple{Float64, FrankWolfe.ScaledHotVector{Base.Rational{Base.GMP.BigInt}}}}}})
precompile(Tuple{Type{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Axes, F, Args} where Args<:Tuple where F where Axes}, typeof(Base.:(+)), Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Base.:(*)), Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{0}, Nothing, typeof(Base.:(-)), Tuple{Int64, Float64}}, Array{Float64, 1}}}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Base.:(*)), Tuple{Float64, FrankWolfe.ScaledHotVector{Float64}}}}})
precompile(Tuple{Type{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Axes, F, Args} where Args<:Tuple where F where Axes}, typeof(Base.:(-)), Tuple{FrankWolfe.ScaledHotVector{Float64}, Array{Float64, 1}}})
precompile(Tuple{Type{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Axes, F, Args} where Args<:Tuple where F where Axes}, typeof(Base.:(*)), Tuple{Int64, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Base.:(-)), Tuple{FrankWolfe.ScaledHotVector{Float64}, Array{Float64, 1}}}}})
precompile(Tuple{Type{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2}, Axes, F, Args} where Args<:Tuple where F where Axes}, typeof(Base.:(-)), Tuple{Array{Float64, 2}, FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}}})
precompile(Tuple{Type{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2}, Axes, F, Args} where Args<:Tuple where F where Axes}, typeof(Base.:(+)), Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2}, Nothing, typeof(Base.:(*)), Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{0}, Nothing, typeof(Base.:(-)), Tuple{Int64, Float64}}, Array{Float64, 2}}}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2}, Nothing, typeof(Base.:(*)), Tuple{Float64, FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}}}}})
precompile(Tuple{Type{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2}, Axes, F, Args} where Args<:Tuple where F where Axes}, typeof(Base.:(*)), Tuple{Float64, FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}}})
precompile(Tuple{Type{FrankWolfe.KSparseLMO{T} where T}, Int64, Float64})
precompile(Tuple{Type{FrankWolfe.LpNormLMO{2, p} where p}, Float64})
precompile(Tuple{Type{FrankWolfe.LpNormLMO{Float64, 1}}, Float64})
precompile(Tuple{Type{FrankWolfe.MultiCacheLMO{500, FrankWolfe.BirkhoffPolytopeLMO, SparseArrays.SparseMatrixCSC{Float64, Int64}}}, FrankWolfe.BirkhoffPolytopeLMO})
precompile(Tuple{Type{FrankWolfe.MultiCacheLMO{500, FrankWolfe.KSparseLMO{Float64}, SparseArrays.SparseVector{Float64, Int64}}}, FrankWolfe.KSparseLMO{Float64}})
precompile(Tuple{Type{FrankWolfe.NuclearNormLMO{T} where T}, Float64})
precompile(Tuple{Type{FrankWolfe.ProbabilitySimplexOracle{Base.Rational{Base.GMP.BigInt}}}, Int64})
precompile(Tuple{Type{FrankWolfe.ProbabilitySimplexOracle{T} where T}, Float64})
precompile(Tuple{Type{FrankWolfe.ProbabilitySimplexOracle{T} where T}, Int64})
precompile(Tuple{Type{FrankWolfe.RankOneMatrix{T, UT, VT} where VT<:(AbstractArray{T, 1} where T) where UT<:(AbstractArray{T, 1} where T) where T}, Array{Float64, 1}, Array{Float64, 1}})
precompile(Tuple{Type{FrankWolfe.VectorCacheLMO{FrankWolfe.BirkhoffPolytopeLMO, SparseArrays.SparseMatrixCSC{Float64, Int64}}}, FrankWolfe.BirkhoffPolytopeLMO})
precompile(Tuple{Type{FrankWolfe.VectorCacheLMO{FrankWolfe.KSparseLMO{Float64}, SparseArrays.SparseVector{Float64, Int64}}}, FrankWolfe.KSparseLMO{Float64}})
precompile(Tuple{Type{FrankWolfe.VectorCacheLMO{FrankWolfe.NuclearNormLMO{Float64}, FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}}}, FrankWolfe.NuclearNormLMO{Float64}})
precompile(Tuple{Type{NamedTuple{(:epsilon, :max_iteration, :line_search, :print_iter, :emphasis, :L, :verbose, :trajectory, :K, :weight_purge_threshold), T} where T<:Tuple}, Tuple{Float64, Int64, FrankWolfe.Adaptive, Float64, FrankWolfe.Emphasis, Float64, Bool, Bool, Float64, Float64}})
precompile(Tuple{Type{NamedTuple{(:epsilon, :max_iteration, :line_search, :print_iter, :hessian, :emphasis, :L, :accelerated, :verbose, :trajectory, :K, :weight_purge_threshold), T} where T<:Tuple}, Tuple{Float64, Int64, FrankWolfe.Adaptive, Float64, Array{Float64, 2}, FrankWolfe.Emphasis, Float64, Bool, Bool, Bool, Float64, Float64}})
precompile(Tuple{Type{NamedTuple{(:L, :verbose, :line_search, :max_iteration, :print_iter, :trajectory), T} where T<:Tuple}, Tuple{Int64, Bool, FrankWolfe.Adaptive, Int64, Float64, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :epsilon, :line_search, :print_iter, :emphasis, :trajectory, :verbose), T} where T<:Tuple}, Tuple{Int64, Float64, FrankWolfe.Adaptive, Float64, FrankWolfe.Emphasis, Bool, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :L, :print_iter, :emphasis, :verbose, :epsilon, :trajectory), T} where T<:Tuple}, Tuple{Int64, FrankWolfe.Adaptive, Int64, Float64, FrankWolfe.Emphasis, Bool, Float64, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :L, :print_iter, :emphasis, :verbose, :epsilon, :trajectory), T} where T<:Tuple}, Tuple{Int64, FrankWolfe.Agnostic, Int64, Float64, FrankWolfe.Emphasis, Bool, Float64, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :L, :print_iter, :emphasis, :verbose, :trajectory), T} where T<:Tuple}, Tuple{Int64, FrankWolfe.Shortstep, Int64, Float64, FrankWolfe.Emphasis, Bool, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :L, :print_iter, :epsilon, :emphasis, :verbose, :away_steps, :trajectory), T} where T<:Tuple}, Tuple{Int64, FrankWolfe.Adaptive, Int64, Float64, Float64, FrankWolfe.Emphasis, Bool, Bool, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :L, :print_iter, :epsilon, :momentum, :emphasis, :verbose, :away_steps, :trajectory), T} where T<:Tuple}, Tuple{Int64, FrankWolfe.Adaptive, Int64, Float64, Float64, Float64, FrankWolfe.Emphasis, Bool, Bool, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :L, :print_iter, :verbose, :emphasis), T} where T<:Tuple}, Tuple{Int64, FrankWolfe.RationalShortstep, Int64, Float64, Bool, FrankWolfe.Emphasis}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :print_iter, :emphasis, :verbose, :epsilon, :trajectory, :away_steps), T} where T<:Tuple}, Tuple{Int64, FrankWolfe.Adaptive, Float64, FrankWolfe.Emphasis, Bool, Float64, Bool, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :print_iter, :emphasis, :verbose, :epsilon, :trajectory), T} where T<:Tuple}, Tuple{Int64, FrankWolfe.Adaptive, Float64, FrankWolfe.Emphasis, Bool, Float64, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :print_iter, :emphasis, :verbose, :trajectory), T} where T<:Tuple}, Tuple{Int64, FrankWolfe.Adaptive, Float64, FrankWolfe.Emphasis, Bool, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :print_iter, :emphasis, :verbose, :trajectory), T} where T<:Tuple}, Tuple{Int64, FrankWolfe.Agnostic, Float64, FrankWolfe.Emphasis, Bool, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :print_iter, :emphasis, :verbose), T} where T<:Tuple}, Tuple{Float64, FrankWolfe.Agnostic, Float64, FrankWolfe.Emphasis, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :print_iter, :emphasis, :verbose), T} where T<:Tuple}, Tuple{Int64, FrankWolfe.Agnostic, Float64, FrankWolfe.Emphasis, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :print_iter, :epsilon, :emphasis, :trajectory, :cache_size, :verbose), T} where T<:Tuple}, Tuple{Int64, FrankWolfe.Adaptive, Float64, Float64, FrankWolfe.Emphasis, Bool, Int64, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :print_iter, :epsilon, :emphasis, :trajectory, :verbose), T} where T<:Tuple}, Tuple{Int64, FrankWolfe.Adaptive, Float64, Float64, FrankWolfe.Emphasis, Bool, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :print_iter, :epsilon, :emphasis, :verbose, :away_steps, :trajectory), T} where T<:Tuple}, Tuple{Int64, FrankWolfe.Adaptive, Float64, Float64, FrankWolfe.Emphasis, Bool, Bool, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :print_iter, :epsilon, :emphasis, :verbose, :trajectory, :lazy), T} where T<:Tuple}, Tuple{Int64, FrankWolfe.Adaptive, Float64, Float64, FrankWolfe.Emphasis, Bool, Bool, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :print_iter, :epsilon, :linesearch_tol, :emphasis, :trajectory, :verbose), T} where T<:Tuple}, Tuple{Int64, FrankWolfe.Adaptive, Float64, Float64, Float64, FrankWolfe.Emphasis, Bool, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :print_iter, :linesearch_tol, :epsilon, :emphasis, :lazy, :trajectory, :verbose), T} where T<:Tuple}, Tuple{Int64, FrankWolfe.Adaptive, Float64, Float64, Float64, FrankWolfe.Emphasis, Bool, Bool, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :print_iter, :linesearch_tol, :epsilon, :emphasis, :trajectory, :verbose), T} where T<:Tuple}, Tuple{Int64, FrankWolfe.Adaptive, Float64, Float64, Float64, FrankWolfe.Emphasis, Bool, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :print_iter, :verbose, :emphasis), T} where T<:Tuple}, Tuple{Int64, FrankWolfe.Agnostic, Float64, Bool, FrankWolfe.Emphasis}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :line_search, :print_iter, :verbose), T} where T<:Tuple}, Tuple{Float64, FrankWolfe.Nonconvex, Float64, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :L, :line_search, :print_iter, :emphasis, :cache_size, :verbose), T} where T<:Tuple}, Tuple{Int64, Int64, FrankWolfe.Adaptive, Float64, FrankWolfe.Emphasis, Int64, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :L, :line_search, :print_iter, :emphasis, :verbose), T} where T<:Tuple}, Tuple{Int64, Int64, FrankWolfe.Adaptive, Float64, FrankWolfe.Emphasis, Bool}})
precompile(Tuple{Type{NamedTuple{(:max_iteration, :L, :line_search, :print_iter, :linesearch_tol, :emphasis, :trajectory, :verbose), T} where T<:Tuple}, Tuple{Int64, Int64, FrankWolfe.Adaptive, Float64, Float64, FrankWolfe.Emphasis, Bool, Bool}})
precompile(Tuple{Type{NamedTuple{(:momentum, :verbose, :rng, :line_search, :max_iteration, :print_iter, :batch_size, :trajectory), T} where T<:Tuple}, Tuple{Float64, Bool, Random._GLOBAL_RNG, FrankWolfe.Nonconvex, Int64, Float64, Int64, Bool}})
precompile(Tuple{Type{NamedTuple{(:t, :primal, :dual, :dual_gap, :time, :cache_size, :x, :v), T} where T<:Tuple}, Tuple{Int64, Float64, Float64, Float64, Float64, Int64, Array{Float64, 2}, FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}}})
precompile(Tuple{Type{NamedTuple{(:t, :primal, :dual, :dual_gap, :time, :x, :v, :active_set_length, :non_simplex_iter), T} where T<:Tuple}, Tuple{Int64, Float64, Float64, Float64, Float64, SparseArrays.SparseVector{Float64, Int64}, FrankWolfe.ScaledHotVector{Float64}, Int64, Int64}})
precompile(Tuple{Type{NamedTuple{(:t, :primal, :dual, :dual_gap, :time, :x, :v, :active_set_length), T} where T<:Tuple}, Tuple{Int64, Float64, Float64, Float64, Float64, SparseArrays.SparseVector{Float64, Int64}, FrankWolfe.ScaledHotVector{Float64}, Int64}})
precompile(Tuple{Type{NamedTuple{(:t, :primal, :dual, :dual_gap, :time, :x, :v), T} where T<:Tuple}, Tuple{Int64, Float64, Float64, Float64, Float64, Array{Float64, 1}, FrankWolfe.ScaledHotVector{Float64}}})
precompile(Tuple{Type{NamedTuple{(:t, :primal, :dual, :dual_gap, :time, :x, :v), T} where T<:Tuple}, Tuple{Int64, Float64, Float64, Float64, Float64, Array{Float64, 2}, FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}}})
precompile(Tuple{Type{NamedTuple{(:t, :primal, :dual, :dual_gap, :time, :x, :v), T} where T<:Tuple}, Tuple{Int64, Float64, Float64, Float64, Float64, FrankWolfe.ScaledHotVector{Float64}, Array{Float64, 1}}})
precompile(Tuple{Type{NamedTuple{(:t, :primal, :dual, :dual_gap, :time, :x, :v), T} where T<:Tuple}, Tuple{Int64, Float64, Float64, Float64, Float64, FrankWolfe.ScaledHotVector{Float64}, FrankWolfe.ScaledHotVector{Float64}}})
precompile(Tuple{Type{NamedTuple{(:t, :primal, :dual, :dual_gap, :time, :x, :v), T} where T<:Tuple}, Tuple{Int64, Float64, Float64, Float64, Float64, SparseArrays.SparseVector{Float64, Int64}, FrankWolfe.ScaledHotVector{Float64}}})
precompile(Tuple{Type{NamedTuple{(:verbose, :rng, :line_search, :max_iteration, :print_iter, :batch_size, :trajectory), T} where T<:Tuple}, Tuple{Bool, Random._GLOBAL_RNG, FrankWolfe.Nonconvex, Int64, Float64, Int64, Bool}})
precompile(Tuple{typeof(Base.afoldl), typeof(Base.:(*)), LinearAlgebra.Transpose{Float64, Array{Float64, 1}}, FrankWolfe.ScaledHotVector{Float64}})
precompile(Tuple{typeof(Base.:(+)), Array{Float64, 1}, FrankWolfe.ScaledHotVector{Base.MPFR.BigFloat}})
precompile(Tuple{typeof(Base.:(+)), Array{Float64, 1}, FrankWolfe.ScaledHotVector{Float64}})
precompile(Tuple{typeof(Base.:(*)), Array{Float64, 2}, FrankWolfe.ScaledHotVector{Float64}})
precompile(Tuple{typeof(Base.axes), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2}, Nothing, typeof(Base.:(*)), Tuple{Float64, FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}}}})
precompile(Tuple{typeof(Base.Broadcast.broadcasted), Function, Array{Float64, 2}, FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}})
precompile(Tuple{typeof(Base.Broadcast.broadcasted), Function, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Base.:(*)), Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{0}, Nothing, typeof(Base.:(-)), Tuple{Int64, Float64}}, Array{Float64, 1}}}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Base.:(*)), Tuple{Float64, FrankWolfe.ScaledHotVector{Base.Rational{Base.GMP.BigInt}}}}})
precompile(Tuple{typeof(Base.Broadcast.broadcasted), Function, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Base.:(*)), Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{0}, Nothing, typeof(Base.:(-)), Tuple{Int64, Float64}}, Array{Float64, 1}}}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Base.:(*)), Tuple{Float64, FrankWolfe.ScaledHotVector{Float64}}}})
precompile(Tuple{typeof(Base.Broadcast.broadcasted), Function, Float64, FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}})
precompile(Tuple{typeof(Base.Broadcast.broadcasted), Function, FrankWolfe.ScaledHotVector{Float64}, Array{Float64, 1}})
precompile(Tuple{typeof(Base.Broadcast.broadcasted), Function, Int64, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Base.:(-)), Tuple{FrankWolfe.ScaledHotVector{Float64}, Array{Float64, 1}}}})
precompile(Tuple{typeof(Base.Broadcast.materialize!), Array{Base.Rational{Base.GMP.BigInt}, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Base.:(-)), Tuple{Array{Base.Rational{Base.GMP.BigInt}, 1}, FrankWolfe.ScaledHotVector{Base.Rational{Base.GMP.BigInt}}}}})
precompile(Tuple{typeof(Base.Broadcast.materialize!), Array{Float64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Base.:(-)), Tuple{Array{Float64, 1}, FrankWolfe.ScaledHotVector{Float64}}}})
precompile(Tuple{typeof(Base.Broadcast.materialize!), Array{Float64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Base.:(+)), Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Base.:(*)), Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{0}, Nothing, typeof(Base.:(-)), Tuple{Int64, Float64}}, Array{Float64, 1}}}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Base.:(*)), Tuple{Float64, FrankWolfe.ScaledHotVector{Base.Rational{Base.GMP.BigInt}}}}}}})
precompile(Tuple{typeof(Base.Broadcast.materialize!), Array{Float64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Base.:(+)), Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Base.:(*)), Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{0}, Nothing, typeof(Base.:(-)), Tuple{Int64, Float64}}, Array{Float64, 1}}}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Base.:(*)), Tuple{Float64, FrankWolfe.ScaledHotVector{Float64}}}}}})
precompile(Tuple{typeof(Base.Broadcast.materialize!), Array{Float64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Base.:(*)), Tuple{Int64, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Base.:(-)), Tuple{FrankWolfe.ScaledHotVector{Float64}, Array{Float64, 1}}}}}})
precompile(Tuple{typeof(Base.Broadcast.materialize!), Array{Float64, 2}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2}, Nothing, typeof(Base.:(-)), Tuple{Array{Float64, 2}, FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}}}})
precompile(Tuple{typeof(Base.Broadcast.materialize), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2}, Nothing, typeof(Base.:(*)), Tuple{Float64, FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}}}})
precompile(Tuple{typeof(Base.Broadcast.materialize!), Base.Broadcast.DefaultArrayStyle{2}, Array{Float64, 2}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2}, Nothing, typeof(Base.:(+)), Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2}, Nothing, typeof(Base.:(*)), Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{0}, Nothing, typeof(Base.:(-)), Tuple{Int64, Float64}}, Array{Float64, 2}}}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2}, Nothing, typeof(Base.:(*)), Tuple{Float64, FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}}}}}})
precompile(Tuple{typeof(Base.collect), FrankWolfe.ScaledHotVector{Float64}})
precompile(Tuple{typeof(Base.copy), FrankWolfe.ScaledHotVector{Float64}})
precompile(Tuple{typeof(Base.deepcopy), FrankWolfe.ScaledHotVector{Float64}})
precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Array{Base.Rational{Base.GMP.BigInt}, 1}, FrankWolfe.ScaledHotVector{Base.Rational{Base.GMP.BigInt}}, Base.MPFR.BigFloat, Base.Rational{Base.GMP.BigInt}, Array{Any, 1}}, Int64})
precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Array{Base.Rational{Base.GMP.BigInt}, 1}, FrankWolfe.ScaledHotVector{Base.Rational{Base.GMP.BigInt}}, Base.MPFR.BigFloat, Base.Rational{Base.GMP.BigInt}, Array{Any, 1}}, Int64, Int64})
precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Array{Float64, 1}, FrankWolfe.ScaledHotVector{Float64}, Float64, Float64, Array{Any, 1}}, Int64})
precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Array{Float64, 1}, FrankWolfe.ScaledHotVector{Float64}, Float64, Float64, Array{Any, 1}}, Int64, Int64})
precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Array{Float64, 2}, FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}, Float64, Float64, Array{Any, 1}}, Int64})
precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Array{Float64, 2}, FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}, Float64, Float64, Array{Any, 1}}, Int64, Int64})
precompile(Tuple{typeof(Base.indexed_iterate), Tuple{SparseArrays.SparseMatrixCSC{Float64, Int64}, SparseArrays.SparseMatrixCSC{Float64, Int64}, Float64, Float64, Array{Any, 1}, FrankWolfe.ActiveSet{SparseArrays.SparseMatrixCSC{Float64, Int64}, Float64, SparseArrays.SparseMatrixCSC{Float64, Int64}}}, Int64})
precompile(Tuple{typeof(Base.indexed_iterate), Tuple{SparseArrays.SparseMatrixCSC{Float64, Int64}, SparseArrays.SparseMatrixCSC{Float64, Int64}, Float64, Float64, Array{Any, 1}, FrankWolfe.ActiveSet{SparseArrays.SparseMatrixCSC{Float64, Int64}, Float64, SparseArrays.SparseMatrixCSC{Float64, Int64}}}, Int64, Int64})
precompile(Tuple{typeof(Base.indexed_iterate), Tuple{SparseArrays.SparseVector{Base.Rational{Base.GMP.BigInt}, Int64}, FrankWolfe.ScaledHotVector{Base.Rational{Base.GMP.BigInt}}, Base.Rational{Base.GMP.BigInt}, Base.Rational{Base.GMP.BigInt}, Array{Any, 1}}, Int64})
precompile(Tuple{typeof(Base.indexed_iterate), Tuple{SparseArrays.SparseVector{Base.Rational{Base.GMP.BigInt}, Int64}, FrankWolfe.ScaledHotVector{Base.Rational{Base.GMP.BigInt}}, Base.Rational{Base.GMP.BigInt}, Base.Rational{Base.GMP.BigInt}, Array{Any, 1}}, Int64, Int64})
precompile(Tuple{typeof(Base.indexed_iterate), Tuple{SparseArrays.SparseVector{Float64, Int64}, FrankWolfe.ScaledHotVector{Float64}, Float64, Float64, Array{Any, 1}, FrankWolfe.ActiveSet{FrankWolfe.ScaledHotVector{Float64}, Float64, SparseArrays.SparseVector{Float64, Int64}}}, Int64})
precompile(Tuple{typeof(Base.indexed_iterate), Tuple{SparseArrays.SparseVector{Float64, Int64}, FrankWolfe.ScaledHotVector{Float64}, Float64, Float64, Array{Any, 1}, FrankWolfe.ActiveSet{FrankWolfe.ScaledHotVector{Float64}, Float64, SparseArrays.SparseVector{Float64, Int64}}}, Int64, Int64})
precompile(Tuple{typeof(Base.indexed_iterate), Tuple{SparseArrays.SparseVector{Float64, Int64}, FrankWolfe.ScaledHotVector{Float64}, Float64, Float64, Array{Any, 1}}, Int64})
precompile(Tuple{typeof(Base.indexed_iterate), Tuple{SparseArrays.SparseVector{Float64, Int64}, FrankWolfe.ScaledHotVector{Float64}, Float64, Float64, Array{Any, 1}}, Int64, Int64})
precompile(Tuple{typeof(Base.indexed_iterate), Tuple{SparseArrays.SparseVector{Float64, Int64}, SparseArrays.SparseVector{Float64, Int64}, Float64, Float64, Array{Any, 1}, FrankWolfe.ActiveSet{SparseArrays.SparseVector{Float64, Int64}, Float64, SparseArrays.SparseVector{Float64, Int64}}}, Int64})
precompile(Tuple{typeof(Base.indexed_iterate), Tuple{SparseArrays.SparseVector{Float64, Int64}, SparseArrays.SparseVector{Float64, Int64}, Float64, Float64, Array{Any, 1}, FrankWolfe.ActiveSet{SparseArrays.SparseVector{Float64, Int64}, Float64, SparseArrays.SparseVector{Float64, Int64}}}, Int64, Int64})
precompile(Tuple{typeof(Base.length), FrankWolfe.MultiCacheLMO{500, FrankWolfe.BirkhoffPolytopeLMO, SparseArrays.SparseMatrixCSC{Float64, Int64}}})
precompile(Tuple{typeof(Base.length), FrankWolfe.MultiCacheLMO{500, FrankWolfe.KSparseLMO{Float64}, SparseArrays.SparseVector{Float64, Int64}}})
precompile(Tuple{typeof(Base.length), FrankWolfe.VectorCacheLMO{FrankWolfe.BirkhoffPolytopeLMO, SparseArrays.SparseMatrixCSC{Float64, Int64}}})
precompile(Tuple{typeof(Base.length), FrankWolfe.VectorCacheLMO{FrankWolfe.KSparseLMO{Float64}, SparseArrays.SparseVector{Float64, Int64}}})
precompile(Tuple{typeof(Base.length), FrankWolfe.VectorCacheLMO{FrankWolfe.NuclearNormLMO{Float64}, FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}}})
precompile(Tuple{typeof(Base.print), Base.GenericIOBuffer{Array{UInt8, 1}}, FrankWolfe.Adaptive})
precompile(Tuple{typeof(Base.print), Base.GenericIOBuffer{Array{UInt8, 1}}, FrankWolfe.Agnostic})
precompile(Tuple{typeof(Base.print), Base.GenericIOBuffer{Array{UInt8, 1}}, FrankWolfe.Emphasis})
precompile(Tuple{typeof(Base.print), Base.GenericIOBuffer{Array{UInt8, 1}}, FrankWolfe.Nonconvex})
precompile(Tuple{typeof(Base.print), Base.GenericIOBuffer{Array{UInt8, 1}}, FrankWolfe.RationalShortstep})
precompile(Tuple{typeof(Base.print), Base.GenericIOBuffer{Array{UInt8, 1}}, FrankWolfe.Shortstep})
precompile(Tuple{typeof(Base.push!), Array{FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}, 1}, FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}})
precompile(Tuple{typeof(Base.size), FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}})
precompile(Tuple{typeof(FrankWolfe.backtrackingLS), Function, SparseArrays.SparseMatrixCSC{Float64, Int64}, Array{Float64, 2}, Array{Float64, 2}, Float64})
precompile(Tuple{typeof(FrankWolfe.compute_extreme_point), FrankWolfe.BirkhoffPolytopeLMO, Array{Float64, 2}})
precompile(Tuple{typeof(FrankWolfe.compute_extreme_point), FrankWolfe.KSparseLMO{Float64}, Array{Float64, 1}})
precompile(Tuple{typeof(FrankWolfe.compute_extreme_point), FrankWolfe.LpNormLMO{Float64, 1}, Array{Float64, 1}})
precompile(Tuple{typeof(FrankWolfe.compute_extreme_point), FrankWolfe.LpNormLMO{Float64, 2}, Array{Float64, 1}})
precompile(Tuple{typeof(FrankWolfe.compute_extreme_point), FrankWolfe.MultiCacheLMO{500, FrankWolfe.BirkhoffPolytopeLMO, SparseArrays.SparseMatrixCSC{Float64, Int64}}, SparseArrays.SparseMatrixCSC{Float64, Int64}})
precompile(Tuple{typeof(FrankWolfe.compute_extreme_point), FrankWolfe.MultiCacheLMO{500, FrankWolfe.KSparseLMO{Float64}, SparseArrays.SparseVector{Float64, Int64}}, SparseArrays.SparseVector{Float64, Int64}})
precompile(Tuple{typeof(FrankWolfe.compute_extreme_point), FrankWolfe.NuclearNormLMO{Float64}, SparseArrays.SparseMatrixCSC{Float64, Int64}})
precompile(Tuple{typeof(FrankWolfe.compute_extreme_point), FrankWolfe.ProbabilitySimplexOracle{Base.Rational{Base.GMP.BigInt}}, Array{Float64, 1}})
precompile(Tuple{typeof(FrankWolfe.compute_extreme_point), FrankWolfe.ProbabilitySimplexOracle{Float64}, Array{Float64, 1}})
precompile(Tuple{typeof(FrankWolfe.compute_extreme_point), FrankWolfe.VectorCacheLMO{FrankWolfe.BirkhoffPolytopeLMO, SparseArrays.SparseMatrixCSC{Float64, Int64}}, SparseArrays.SparseMatrixCSC{Float64, Int64}})
precompile(Tuple{typeof(FrankWolfe.compute_extreme_point), FrankWolfe.VectorCacheLMO{FrankWolfe.KSparseLMO{Float64}, SparseArrays.SparseVector{Float64, Int64}}, SparseArrays.SparseVector{Float64, Int64}})
precompile(Tuple{typeof(FrankWolfe.compute_extreme_point), FrankWolfe.VectorCacheLMO{FrankWolfe.NuclearNormLMO{Float64}, FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}}, SparseArrays.SparseMatrixCSC{Float64, Int64}})
precompile(Tuple{typeof(FrankWolfe.fast_dot), Array{Float64, 1}, Array{Float64, 1}})
precompile(Tuple{typeof(FrankWolfe.fast_dot), Array{Float64, 1}, SparseArrays.SparseVector{Float64, Int64}})
precompile(Tuple{typeof(FrankWolfe.fast_dot), Array{Float64, 2}, Array{Float64, 2}})
precompile(Tuple{typeof(FrankWolfe.fast_dot), FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}, Array{Float64, 2}})
precompile(Tuple{typeof(FrankWolfe.fast_dot), FrankWolfe.RankOneMatrix{Float64, Array{Float64, 1}, Array{Float64, 1}}, SparseArrays.SparseMatrixCSC{Float64, Int64}})
precompile(Tuple{typeof(FrankWolfe.fast_dot), FrankWolfe.ScaledHotVector{Base.Rational{Base.GMP.BigInt}}, Array{Float64, 1}})
precompile(Tuple{typeof(FrankWolfe.fast_dot), FrankWolfe.ScaledHotVector{Float64}, Array{Float64, 1}})
precompile(Tuple{typeof(FrankWolfe.fast_dot), FrankWolfe.ScaledHotVector{Float64}, SparseArrays.SparseVector{Float64, Int64}})
precompile(Tuple{typeof(FrankWolfe.fast_dot), SparseArrays.SparseMatrixCSC{Float64, Int64}, Array{Float64, 2}})
precompile(Tuple{typeof(FrankWolfe.fast_dot), SparseArrays.SparseMatrixCSC{Float64, Int64}, SparseArrays.SparseMatrixCSC{Float64, Int64}})
precompile(Tuple{typeof(FrankWolfe.fast_dot), SparseArrays.SparseVector{Float64, Int64}, Array{Float64, 1}})
precompile(Tuple{typeof(FrankWolfe.fast_dot), SparseArrays.SparseVector{Float64, Int64}, SparseArrays.SparseVector{Float64, Int64}})
precompile(Tuple{typeof(FrankWolfe.line_search_wrapper), FrankWolfe.Adaptive, Int64, Function, Function, Array{Float64, 1}, Array{Float64, 1}, Array{Float64, 1}, Float64, Float64, Int64, Float64, Int64, Float64})
precompile(Tuple{typeof(FrankWolfe.line_search_wrapper), FrankWolfe.Adaptive, Int64, Function, Function, Array{Float64, 1}, Array{Float64, 1}, Array{Float64, 1}, Float64, Int64, Int64, Float64, Int64, Float64})
precompile(Tuple{typeof(FrankWolfe.line_search_wrapper), FrankWolfe.Adaptive, Int64, Function, Function, Array{Float64, 2}, Array{Float64, 2}, SparseArrays.SparseMatrixCSC{Float64, Int64}, Float64, Float64, Int64, Float64, Int64, Float64})
precompile(Tuple{typeof(FrankWolfe.line_search_wrapper), FrankWolfe.Adaptive, Int64, Function, Function, SparseArrays.SparseMatrixCSC{Float64, Int64}, SparseArrays.SparseMatrixCSC{Float64, Int64}, SparseArrays.SparseMatrixCSC{Float64, Int64}, Float64, Float64, Int64, Float64, Int64, Float64})
precompile(Tuple{typeof(FrankWolfe.line_search_wrapper), FrankWolfe.Adaptive, Int64, Function, Function, SparseArrays.SparseVector{Float64, Int64}, SparseArrays.SparseVector{Float64, Int64}, SparseArrays.SparseVector{Float64, Int64}, Float64, Float64, Int64, Float64, Int64, Float64})
precompile(Tuple{typeof(FrankWolfe.line_search_wrapper), FrankWolfe.Adaptive, Int64, Function, Function, SparseArrays.SparseVector{Float64, Int64}, SparseArrays.SparseVector{Float64, Int64}, SparseArrays.SparseVector{Float64, Int64}, Float64, Float64, Int64, Float64, Int64, Int64})
precompile(Tuple{typeof(FrankWolfe.line_search_wrapper), FrankWolfe.Adaptive, Int64, Function, Function, SparseArrays.SparseVector{Float64, Int64}, SparseArrays.SparseVector{Float64, Int64}, SparseArrays.SparseVector{Float64, Int64}, Float64, Int64, Int64, Float64, Int64, Float64})
precompile(Tuple{typeof(FrankWolfe.line_search_wrapper), FrankWolfe.Adaptive, Int64, Function, Function, SparseArrays.SparseVector{Float64, Int64}, SparseArrays.SparseVector{Float64, Int64}, SparseArrays.SparseVector{Float64, Int64}, Float64, Int64, Int64, Float64, Int64, Int64})
precompile(Tuple{typeof(FrankWolfe.line_search_wrapper), FrankWolfe.RationalShortstep, Int64, Function, Function, FrankWolfe.ScaledHotVector{Base.Rational{Base.GMP.BigInt}}, SparseArrays.SparseVector{Base.Rational{Base.GMP.BigInt}, Int64}, SparseArrays.SparseVector{Base.Rational{Base.GMP.BigInt}, Int64}, Base.Rational{Base.GMP.BigInt}, Int64, Int64, Float64, Int64, Base.Rational{Base.GMP.BigInt}})
precompile(Tuple{typeof(FrankWolfe.line_search_wrapper), FrankWolfe.RationalShortstep, Int64, Function, Function, SparseArrays.SparseVector{Base.Rational{Base.GMP.BigInt}, Int64}, SparseArrays.SparseVector{Base.Rational{Base.GMP.BigInt}, Int64}, SparseArrays.SparseVector{Base.Rational{Base.GMP.BigInt}, Int64}, Base.Rational{Base.GMP.BigInt}, Int64, Int64, Float64, Int64, Base.Rational{Base.GMP.BigInt}})
precompile(Tuple{typeof(FrankWolfe.line_search_wrapper), FrankWolfe.Shortstep, Int64, Function, Function, Array{Float64, 1}, Array{Float64, 1}, Array{Float64, 1}, Float64, Int64, Int64, Float64, Int64, Float64})
precompile(Tuple{typeof(FrankWolfe.line_search_wrapper), FrankWolfe.Shortstep, Int64, Function, Function, Array{Float64, 1}, Array{Float64, 1}, SparseArrays.SparseVector{Float64, Int64}, Float64, Int64, Int64, Float64, Int64, Float64})
precompile(Tuple{typeof(FrankWolfe.line_search_wrapper), FrankWolfe.Shortstep, Int64, Function, Function, FrankWolfe.ScaledHotVector{Float64}, Array{Float64, 1}, SparseArrays.SparseVector{Float64, Int64}, Float64, Int64, Int64, Float64, Int64, Float64})
precompile(Tuple{typeof(FrankWolfe.line_search_wrapper), FrankWolfe.Shortstep, Int64, Function, Function, FrankWolfe.ScaledHotVector{Float64}, SparseArrays.SparseVector{Float64, Int64}, SparseArrays.SparseVector{Float64, Int64}, Float64, Int64, Int64, Float64, Int64, Float64})
precompile(Tuple{typeof(FrankWolfe.line_search_wrapper), FrankWolfe.Shortstep, Int64, Function, Function, SparseArrays.SparseVector{Float64, Int64}, SparseArrays.SparseVector{Float64, Int64}, SparseArrays.SparseVector{Float64, Int64}, Float64, Int64, Int64, Float64, Int64, Float64})
precompile(Tuple{typeof(FrankWolfe.plot_trajectories), Array{Array{Any, 1}, 1}, Array{String, 1}})
precompile(Tuple{typeof(FrankWolfe.plot_trajectories), Array{Array{Any, 1}, 1}, Array{String, 2}})
precompile(Tuple{typeof(FrankWolfe.print_callback), Tuple{String, String, Float64, Float64, Float64, Float64, Float64, Int64, Int64}, String})
precompile(Tuple{typeof(FrankWolfe.print_callback), Tuple{String, String, Float64, Float64, Float64, Float64, Float64, Int64}, String})
precompile(Tuple{typeof(FrankWolfe.print_callback), Tuple{String, String, Float64, Float64, Float64, Float64, Float64}, String})
precompile(Tuple{typeof(LinearAlgebra.dot), Array{Float64, 1}, FrankWolfe.ScaledHotVector{Float64}})


text:
# path to the GISSMO Julia storage folder.
#cs_config_path = "/home/roy/MEGAsync/inputs/NMR/configs/reduced_cs_config.txt"

function calibratesolute(project_name, molecule_names, w;
    max_iters = 50000,
    projects_dir = "/home/roy/MEGAsync/outputs/NMR/calibrate/final",
    base_path_JLD = "/home/roy/Documents/repo/NMRData//src/input/molecules",
    cs_config_path = "/home/roy/Documents/repo/NMRData/src/input/reduced_cs_config.txt")

    println("Now on $(project_name)")

    PyPlot.close("all")
    fig_num = 1

    Random.seed!(25)
    PyPlot.matplotlib["rcParams"][:update](["font.size" => 22, "font.family" => "serif"])

    ### user inputs.
    # 0.1% DSS is 0.0046 M = 4.6 mM.
    save_folder_path = joinpath(projects_dir, project_name)
    #@assert 1==2

    #### TODO: load from project name, molecule_names, w from BSON files.
    # find a story to write about.

    # ## reboot. #######
    # project_name = "D-(+)-Glucose-700"
    # molecule_names = ["D-(+)-Glucose"; "DSS"]
    # w = [20.0/4.6; 1.0] # BMRB: DSS is 0.1 % => 4.6 mM

    # project_name = "D-(+)-Glucose-NRC-600"
    # molecule_names = ["D-(+)-Glucose";]
    # w = [1.0; ]

    # project_name = "L-Phenylalanine-700"
    # molecule_names = ["L-Phenylalanine"; "DSS"]
    # w = [20/0.5; 1.0] # BMRB-700 phenylalanine: DSS is 500 micro M.

    # project_name = "L-Glutamine-700"
    # molecule_names = ["L-Glutamine"; "DSS"]
    # w = [20.0/0.5; 1.0] # BMRB: DSS is 500 uM => 0.5 mM

    # project_name = "L-Glutamic acid-700"
    # molecule_names = ["L-Glutamic acid"; "DSS"]
    # w = [20.0/4.6; 1.0] # BMRB: DSS is 0.1% => 4.6 mM

    # project_name = "L-Histidine-700"
    # molecule_names = ["L-Histidine"; "DSS"]
    # w = [20.0/46; 1.0] # BMRB: DSS is 1 % => 46 mM
    #
    # project_name = "L-Isoleucine-700"
    # molecule_names = ["L-Isoleucine"; "DSS"]
    # w = [20.0/46; 1.0] # BMRB: DSS is 1 % => 46 mM

    # project_name = "L-Serine-700"
    # molecule_names = ["L-Serine"; "DSS"]
    # w = [20.0/46; 1.0] # BMRB: DSS is 1 % => 46 mM
    #
    #
    # project_name = "L-Alanine-700"
    # molecule_names = ["L-Alanine"; "DSS"]
    # w = [20.0/0.5; 1.0] # BMRB: DSS is 500uM => 0.5 mM
    #
    # project_name = "L-Threonine-700"
    # molecule_names = ["L-Threonine"; "DSS"]
    # w = [20.0/0.5; 1.0] # BMRB: DSS is 500uM => 0.5 mM
    #
    # project_name = "L-Tryptophan-700"
    # molecule_names = ["L-Tryptophan"; "DSS"]
    # w = [20.0/0.5; 1.0] # BMRB: DSS is 500uM => 0.5 mM
    #
    # project_name = "L-Valine-700"
    # molecule_names = ["L-Valine"; "DSS"]
    # w = [20.0/0.5; 1.0] # BMRB: DSS is 500uM => 0.5 mM

    w = w ./ norm(w) # since the fit data, y, is normalized.

    # proxy-related.
    tol_coherence = 1e-2
    α_relative_threshold = 0.05
    #Δc_partition_radius = 1e-1 # 17 element partition for glucose spin group 2.
    Δc_partition_radius_candidates = [1e-1; 0.3; 0.5; 0.7; 0.8; 0.9]
    #Δc_partition_radius_candidates = [0.9;]
    λ0 = 3.4
    Δcs_max = 0.2 # for proxy.
    κ_λ_lb = 0.5
    κ_λ_ub = 2.5

    # if a Δc_partition_radius candidate gives max partition sizes less than of
    #   equal to this value, then use that candidate.
    early_exit_part_size = 7

    ### end inputs.

    ## load data.
    load_folder_path = joinpath(projects_dir, project_name)
    load_path = joinpath(load_folder_path, "$(project_name).bson")
    dic = BSON.load(load_path)
    s_t = dic[:s_t]
    fs = dic[:fs]
    SW = dic[:SW]
    ν_0ppm = dic[:ν_0ppm]

    # normalize.
    s_t = s_t

    hz2ppmfunc = uu->(uu - ν_0ppm)*SW/fs
    ppm2hzfunc = pp->(ν_0ppm + pp*fs/SW)

    offset_Hz = ν_0ppm - (ppm2hzfunc(0.3)-ppm2hzfunc(0.0))

    N = length(s_t)
    DFT_s = fft(s_t)
    U_DFT, U_y, U_inds = NMRDataSetup.getwraparoundDFTfreqs(N, fs, offset_Hz)

    Z = maximum(abs.(DFT_s))
    y = DFT_s[U_inds] ./ Z

    #
    S_U = DFT_s[U_inds]
    P_y = hz2ppmfunc.(U_y)

    PyPlot.figure(fig_num)
    fig_num += 1

    PyPlot.plot(P_y, real.(S_U), label = "data spectrum")

    PyPlot.legend()
    PyPlot.xlabel("ppm")
    PyPlot.ylabel("real")
    PyPlot.title("data spectra")

    ####### mixture proxy.

    Δcs_max_mixture = collect( Δcs_max for i = 1:length(molecule_names))

    println("Timing: trydiffΔcradius()")
    @time mixture_params, Δc_partition_radius = NMRCalibrate.trydiffΔcradius(Δc_partition_radius_candidates,
        molecule_names, base_path_JLD, Δcs_max_mixture, hz2ppmfunc, ppm2hzfunc,
        fs, SW, λ0, ν_0ppm, early_exit_part_size, Δcs_max, tol_coherence, α_relative_threshold)
    As = mixture_params

    ΩS_ppm = NMRSpectraSimulator.getPsnospininfo(As, hz2ppmfunc)
    ΩS_ppm_sorted = sort(NMRSpectraSimulator.combinevectors(ΩS_ppm))

    println("$(project_name): Partition sizes:")
    display(NMRCalibrate.displaypartitionsizes(As[1]))
    println("Δc_partition_radius = ", Δc_partition_radius)
    println()

    #@assert 1==2

    # u_min = ppm2hzfunc(-0.5)
    # u_max = ppm2hzfunc(3.0)

    u_offset = 0.5
    u_min = ppm2hzfunc(ΩS_ppm_sorted[1] - u_offset)
    u_max = ppm2hzfunc(ΩS_ppm_sorted[end] + u_offset)

    println("Timing: fitproxies!()")
    @time NMRSpectraSimulator.fitproxies!(As;
    #NMRSpectraSimulator.fitproxiessimple!(As;
    κ_λ_lb = κ_λ_lb,
    κ_λ_ub = κ_λ_ub,
    u_min = u_min,
    u_max = u_max,
    Δr = 1.0,
    Δκ_λ = 0.05)

    #
    # BSON.bson("/home/roy/MEGAsync/inputs/NMR/debug/test_As.bson",
    # As = As)
    # @assert 1==33

    ### cost func.
    combinevectors = NMRSpectraSimulator.combinevectors

    Δsys_cs, y_cost_all, U_cost_all, P_cost_all, exp_info, cost_inds,
    cost_inds_set = NMRCalibrate.prepareoptim(cs_config_path, molecule_names, hz2ppmfunc,
    U_y, y, As; region_min_dist = 0.1)

    # visualize cost regions.
    # sort(P_cost_set[1]) # etc..
    P_cost_set = collect( P_y[cost_inds_set[r]] for r = 1:length(cost_inds_set) )

    ### optim all regions. # 900 secs.
    y_cost = y_cost_all
    U_cost = U_cost_all
    P_cost = P_cost_all

    PyPlot.figure(fig_num)
    fig_num += 1

    PyPlot.plot(P_y, real.(y), label = "data spectrum")
    PyPlot.plot(P_cost, real.(y_cost), "^", label = "positions")

    PyPlot.legend()
    PyPlot.xlabel("ppm")
    PyPlot.ylabel("real")
    PyPlot.title("positions against data spectrum, real part")

    #@assert 1==2

    Δ_shifts = NMRSpectraSimulator.combinevectors(Δsys_cs)

    ##### set up updates.

    P = LinRange(hz2ppmfunc(u_min), hz2ppmfunc(u_max), 50000)
    U = ppm2hzfunc.(P)
    #ΩS_ppm = collect( hz2ppmfunc.( NMRSpectraSimulator.combinevectors(A.Ωs) ./ (2*π) ) for A in mixture_params )

    ## parameters that affect qs.
    # A.ss_params.d, A.ss_params.κs_λ, A.ss_params.κs_β
    # A.d_singlets, A.αs_singlets, A.Ωs_singlets, A.β_singlets, A.λ0, A.κs_λ_singlets
    # purposely perturb κ.

    Es = collect( NMRSpectraSimulator.κCompoundFIDType(As[i]) for i = 1:length(As) )

    κ_lb_default = 0.2
    κ_ub_default = 50.0

    #@assert 1==2

    ## fit model.
    println("Timing: calibrateregions()")
    @time cost_inds_set, p_star_set, κ_BLS_set, d_star_set, β_star_set, λ_star_set,
    proxies_set = calibrateregions(y, U_y, P_y, cost_inds_set,
    Δ_shifts, As, fs, SW, w;
    max_iters = max_iters,
    xtol_rel = 1e-7,
    ftol_rel = 1e-12,
    κ_lb_default = κ_lb_default,
    κ_ub_default = κ_ub_default,
    λ_each_lb = 0.9,
    λ_each_ub = 1.1)

    ### save block.

    save_path = joinpath(save_folder_path, "results_full.bson")
    BSON.bson(save_path,
    p_star_set = p_star_set,
    κ_lb_default = κ_lb_default,
    κ_ub_default = κ_ub_default,
    κ_star_set = κ_BLS_set,
    d_star_set = d_star_set,
    β_star_set = β_star_set,
    λ_star_set = λ_star_set,
    w = w,
    # proxy setup-related below.
    Δc_partition_radius = Δc_partition_radius,
    tol_coherence = tol_coherence,
    α_relative_threshold = α_relative_threshold,
    λ0 = λ0,
    Δcs_max = Δcs_max,
    κ_λ_lb = κ_λ_lb,
    κ_λ_ub = κ_λ_ub,
    # experiement/cost-related below.
    cost_inds_set = cost_inds_set,
    Δsys_cs = Δsys_cs,
    y_cost_all = y_cost_all,
    U_cost_all = U_cost_all,
    P_cost_all = P_cost_all,
    #exp_info = exp_info,
    cost_inds = cost_inds,
    As = As,
    y = y,
    U_y = U_y,
    fs = fs,
    SW = SW,
    ν_0ppm = ν_0ppm)
    ## end save block.

    q_U_set = collect( proxies_set[r].(U) for r = 1:length(proxies_set) )

end


text:
using Pkg
Pkg.activate(".");
using CSV
using Dates
using DataFrames
using SimpleHypergraphs
using LightGraphs
using Plots
using JSON

# download the data from
# https://data.mendeley.com/datasets/ct8f9skv97/1
df = DataFrame()

nodes = Dict{String, Int}()
edges = Vector{Vector{String}}()
nodeid = 1

df = DateFormat("y-m-dTH:M:S.000+0000")

matches_per_year = Dict{Int, Int}()

for line in readlines("data/json/nbagames.json")
    jsonline = JSON.parse(line)
    edge = Vector{String}()

    strdate = collect(values(jsonline["date"]))[1]
    dt = Date(strdate, df)
    year = Dates.year(dt)

    year < 2012 && continue

    matches_per_year[year] = get!(matches_per_year, year, 0) + 1

    for player in values(jsonline["teams"][1]["players"])
        push!(edge, player["player"])
    end
    for player in values(jsonline["teams"][2]["players"])
        push!(edge, player["player"])
    end

    push!(edges, edge)

    global nodeid
    for v in edge
        if !haskey(nodes, string(v))
            push!(nodes, string(v)=> nodeid)
            nodeid += 1
        end
    end
end
matches_per_year

h = Hypergraph{Bool}(length(nodes), 0)

for edge in edges
    d = Dict{Int, Bool}()
    for v in edge
        push!(d, get!(nodes, v, nothing) => true)
    end
    add_hyperedge!(h; vertices=d)
end

for e in 1:nhe(h)
    if length(getvertices(h,e)) == 0
     println("covid")
    end
 end

edges_distribution = []
for edge in edges
    if  length(edge) == 0
        println("error edge size is zero")
    end
    push!(edges_distribution, length(edge))
end

nodes_distribution = []
for v in 1:nhv(h)
    if  length(gethyperedges(h,v)) == 0
        println("error degree of v is zero")
    end
    push!(nodes_distribution, length(gethyperedges(h,v)))
end

h

savefig(histogram(nodes_distribution), "data/nba.nodes.png")
savefig(histogram(edges_distribution), "data/nba.edges.png")

hg_save("data/nba.hgf",h)


text:
#just a function, no struct
function SRK(components::Vector{String}; idealmodel=BasicIdeal,
    alpha = SoaveAlpha,
    mixing = vdW1fRule,
    activity = nothing,
    userlocations=String[],
    ideal_userlocations=String[],
    alpha_userlocations = String[],
    mixing_userlocations = String[],
    activity_userlocations = String[],
     verbose=false)

     return RK(components;
     idealmodel = idealmodel,
     alpha = alpha,
     mixing=mixing,
     activity = activity,
     ideal_userlocations = ideal_userlocations,
     alpha_userlocations = alpha_userlocations,
     mixing_userlocations = mixing_userlocations,
     activity_userlocations = activity_userlocations,
     verbose = verbose)
end
export SRK


text:
using Base
using Test
using LinearAlgebra
using Surrogates

#1D
lb = 0.0
ub = 4.0
x = [1.0,2.0,3.0]
y = [4.0,5.0,6.0]
linear = x -> norm(x)
cubic = x -> x^3
λ = 2.3
multiquadr = x -> sqrt(x^2+λ^2)
q = 1
my_rad = RadialBasis(x, y, lb, ub, rad = linearRadial)
est = my_rad(3.0)
@test est ≈ 6.0
add_point!(my_rad, 4.0, 10.0)
est = my_rad(3.0)
@test est ≈ 6.0
add_point!(my_rad,[3.2,3.3,3.4],[8.0,9.0,10.0])
est = my_rad(3.0)
@test est ≈ 6.0

my_rad = RadialBasis(x, y, lb, ub, rad = cubicRadial)
q = 2
my_rad = RadialBasis(x,y,lb,ub, rad = multiquadricRadial)

#ND
x = [(1.0, 2.0, 3.0), (4.0, 5.0, 6.0), (7.0, 8.0, 9.0)]
y = [4.0, 5.0, 6.0]
lb = [0.0,3.0,6.0]
ub = [4.0,7.0,10.0]
#bounds = [[0.0, 3.0, 6.0], [4.0, 7.0, 10.0]]
my_rad = RadialBasis(x, y, lb, ub)
est = my_rad((1.0,2.0,3.0))
@test est ≈ 4.0

#WITH ADD_POINT, adding singleton
x = [(1.0,2.0,3.0),(4.0,5.0,6.0),(7.0,8.0,9.0)]
y = [4.0,5.0,6.0]
lb = [0.0,3.0,6.0]
ub = [4.0,7.0,10.0]
#bounds = [[0.0,3.0,6.0],[4.0,7.0,10.0]]
my_rad = RadialBasis(x,y,lb,ub,rad = linearRadial, scale_factor = 1.0)
add_point!(my_rad,(9.0,10.0,11.0),10.0)
est = my_rad((1.0,2.0,3.0))
@test est ≈ 4.0

#WITH ADD_POINT, adding more
x = [(1.0,2.0,3.0),(4.0,5.0,6.0),(7.0,8.0,9.0)]
y = [4.0,5.0,6.0]
#bounds = [[0.0,3.0,6.0],[4.0,7.0,10.0]]
lb = [0.0,3.0,6.0]
ub = [4.0,7.0,10.0]
my_rad = RadialBasis(x,y,lb,ub)
add_point!(my_rad,[(9.0,10.0,11.0),(12.0,13.0,14.0)],[10.0,11.0])
est = my_rad((1.0,2.0,3.0))
@test est ≈ 4.0

lb = [0.0,0.0,0.0]
ub = [10.0,10.0,10.0]
#bounds = [lb,ub]
x = [(1.0,2.0,3.0),(4.0,5.0,6.0),(7.0,8.0,9.0)]
y = [4.0,5.0,6.0]

my_rad_ND = RadialBasis(x,y,lb,ub)
add_point!(my_rad_ND,(3.5,4.5,1.2),18.9)
add_point!(my_rad_ND,[(3.2,1.2,6.7),(3.4,9.5,7.4)],[25.72,239.0])
my_rad_ND = RadialBasis(x,y,lb,ub,rad = cubicRadial)
my_rad_ND = RadialBasis(x,y,lb,ub, rad = multiquadricRadial)
prediction = my_rad_ND((1.0,1.0,1.0))

# #100
f = x -> x[1]*x[2]
lb = [1.0, 2.0]
ub = [10.0, 8.5]
x = sample(500, lb, ub, SobolSample())
push!(x, (1.0, 2.0))
y = f.(x)
my_radial_basis = RadialBasis(x, y, lb, ub, rad = linearRadial)
@test my_radial_basis((1.0, 2.0)) ≈ 2
my_radial_basis = RadialBasis(x, y, lb, ub, rad =linearRadial)
@test my_radial_basis((1.0, 2.0)) ≈ 2

# #100
f = x -> x[1]*x[2]
lb = [1.0, 2.0]
ub = [10.0, 8.5]
x = sample(5, lb, ub, SobolSample())
push!(x, (1.0, 2.0))
y = f.(x)
my_radial_basis = RadialBasis(x, y, lb,ub, rad = linearRadial)
@test my_radial_basis((1.0, 2.0)) ≈ 2

# Multi-output #98
f  = x -> [x^2, x]
lb = 1.0
ub = 10.0
x  = sample(5, lb, ub, SobolSample())
push!(x, 2.0)
y  = f.(x)
my_radial_basis = RadialBasis(x, y, lb, ub, rad = linearRadial)
my_radial_basis(2.0)
@test my_radial_basis(2.0) ≈ [4, 2]

f  = x -> [x[1]*x[2], x[1]+x[2]^2]
lb = [1.0, 2.0]
ub = [10.0, 8.5]
x  = sample(5, lb, ub, SobolSample())
push!(x, (1.0, 2.0))
y  = f.(x)
my_radial_basis = RadialBasis(x, y, lb, ub, rad = linearRadial)
my_radial_basis((1.0, 2.0))
@test my_radial_basis((1.0, 2.0)) ≈ [2, 5]

x_new = (2.0, 2.0)
y_new = f(x_new)
add_point!(my_radial_basis, x_new, y_new)
@test my_radial_basis(x_new) ≈ y_new


text:
x=3                      # 3
typeof(x)                # Int64
x=3.3                    # 3.3
typeof(x)                # Float64
x=3.3+3.3im              # 3.3 + 3.3im
typeof(x)                # ComplexF64 (alias for Complex{Float64})

max_stars_repo_name: zhaiyusci/Julia-Notes

max_issues_repo_name: zhaiyusci/Julia-Notes

max_forks_repo_name: zhaiyusci/Julia-Notes


text:
## demo functions:

"""
    demo1(gridChoice::String)

Demonstrate basic functionalities (load grid, arithmetic, exchange, gradient,
etc.). Call sequence:

```
!isdir(MeshArrays.GRID_LLC90) ? error("missing files") : nothing

(D,Dexch,Darr,DD)=demo1("LatLonCap",MeshArrays.GRID_LLC90);
```
"""
function demo1(gridChoice::String,GridParentDir="./")

    γ=GridSpec(gridChoice,GridParentDir)

    D=γ.read(γ.path*"Depth.data",MeshArray(γ,γ.ioPrec))

    1000 .+ D
    D .+ 1000
    D+D
    D .- 1000
    1000 .- D
    D-D
    1000*D
    D*1000
    D*D
    D/1000
    1000 ./ D
    D/D

    Dexch=exchange(D,4)
    Darr=γ.write(D)
    DD=γ.read(Darr,D)
    DD .== D

    Γ=GridLoad(γ)

    (dFLDdx, dFLDdy)=gradient(Γ.YC,Γ)
    (dFLDdxEx,dFLDdyEx)=exchange(dFLDdx,dFLDdy,4)

    H=Γ.hFacC
    Ha=γ.write(H)
    Hb=γ.read(Ha,H)

    println(typeof(H))
    println(size(H))
    println(H.fSize[1])
    println(size(H.f[1]))
    if ndims(H)==3&&size(H,3)>40
        println(typeof(view(H,:,:,40)))
    elseif ndims(H.f)==2&&size(H.f,2)>40
        println(typeof(view(H,:,40)))
    end

    return (D,Dexch,Darr,DD)

end

##

"""
    demo2()

Demonstrate higher level functions using `smooth`. Call sequence:

```
(Rini,Rend,DXCsm,DYCsm)=demo2();

using Plots
include(joinpath(dirname(pathof(MeshArrays)),"../examples/Plots.jl"))
heatmap(Rend,title="smoothed noise",clims=(-0.5,0.5))
heatmap(Rini,title="raw noise",clims=(-0.5,0.5))

#gr(); contour(Rend,clims=(-0.5,0.5),levels=-0.5:0.1:0.5,fill=true)
```

"""
function demo2()

    #Pre-requisite: either load predefined grid using `demo1` or call `GridOfOnes`
    isdir(MeshArrays.GRID_LLC90) ? Γ=GridLoad(GridSpec("LatLonCap",MeshArrays.GRID_LLC90)) : (γ,Γ)=GridOfOnes("CubeSphere",6,100)

    (Rini,Rend,DXCsm,DYCsm)=demo2(Γ)
end

function demo2(Γ::NamedTuple)

    γ=Γ.XC.grid

    #initialize 2D field of random numbers
    tmp1=randn(Float32,Tuple(γ.ioSize))
    Rini=γ.read(tmp1,MeshArray(γ,Float32))

    #apply land mask
    if ndims(Γ.hFacC.f[1])>2
        tmp1=mask(view(Γ.hFacC,:,:,1),NaN,0)
    elseif ndims(Γ.hFacC.f)>1
        #tmp1=mask(view(Γ.hFacC,:,1),NaN,0)
        tmp1=similar(Rini)
        for i=1:length(tmp1.fIndex); tmp1[i]=Γ.hFacC[i,1]; end;
        tmp1=MeshArrays.mask(tmp1,NaN,0)
    else
        tmp1=MeshArrays.mask(Γ.hFacC,NaN,0)
    end
    msk=fill(1.,tmp1) + 0. *tmp1;
    Rini=msk*Rini;

    #specify smoothing length scales in x, y directions
    DXCsm=3*Γ.DXC; DYCsm=3*Γ.DYC;

    #apply smoother
    Rend=MeshArrays.smooth(Rini,DXCsm,DYCsm,Γ);

    return (Rini,Rend,DXCsm,DYCsm)

end

"""
    demo3()

Demonstrate ocean transport computations. Call sequence:

```
(UV,LC,Tr)=demo3();
using Plots; plot(Tr/1e6,title="meridional transport")

using Plots
include(joinpath(dirname(pathof(MeshArrays)),"../examples/Plots.jl"))
heatmap(1e-6*UV["U"],title="U comp. in Sv",clims=(-10,10))
heatmap(1e-6*UV["V"],title="V comp. in Sv",clims=(-10,10))
```
"""
function demo3()

    γ=GridSpec("LatLonCap",MeshArrays.GRID_LLC90)
    Γ=GridLoad(γ)

    TrspX=γ.read(γ.path*"TrspX.bin",MeshArray(γ,Float32))
    TrspY=γ.read(γ.path*"TrspY.bin",MeshArray(γ,Float32))
    TauX=γ.read(γ.path*"TauX.bin",MeshArray(γ,Float32))
    TauY=γ.read(γ.path*"TauY.bin",MeshArray(γ,Float32))
    SSH=γ.read(γ.path*"SSH.bin",MeshArray(γ,Float32))

    (UV, LC, Tr)=demo3(TrspX,TrspY,Γ)

end

function demo3(U::MeshArray,V::MeshArray,Γ::NamedTuple)

    LC=LatitudeCircles(-89.0:89.0,Γ)

    #UV=Dict("U"=>U,"V"=>V,"dimensions"=>["x","y","z","t"],"factors"=>["dxory","dz"])
    UV=NamedTuple("U"=>U,"V"=>V,"dimensions"=>["x","y"])

    Tr=Array{Float64,1}(undef,length(LC));
    for i=1:length(LC)
       Tr[i]=ThroughFlow(UV,LC[i],Γ)
    end

    return UV, LC, Tr

end


text:
abstract type AbstractCut end

struct FeasibilityCut{T, VT<:AbstractVector{T}} <: AbstractCut
    a::VT
    β::T
end

abstract type AbstractOptimalityCut <: AbstractCut end

struct MultiOptimalityCut{T, VT<:AbstractVector{T}} <: AbstractCut
    a::VT
    β::T
end

struct AveragedOptimalityCut{T, VT<:AbstractVector{T}} <: AbstractCut
    a::VT
    β::T
end

function SOI.addcut!(sp::StochasticProgram, node, pool::SOI.AbstractSolutionPool, to::TimerOutput, ztol)
    if SOI.allfeasible(pool)
        gencut(SOI.get(sp, CutGenerator(), node), sp, node, pool, to::TimerOutput, ztol)
    else
        gencut(FeasibilityCutGenerator(), sp, node, pool, to::TimerOutput, ztol)
    end
end

function SOI.addcut!(sp::StochasticProgram, tr::Transition, cut::FeasibilityCut)
    # coef is a ray
    # so alpha * coef is also valid for any alpha >= 0.
    # Hence coef might have very large coefficients and alter
    # the numerial accuracy of the master's solver.
    # We scale it to avoid this issue
    scaling = max(abs(cut.β), maximum(abs, cut.a))
    addcut(nodedata(sp, SOI.get(sp, SOI.Target(), tr)).fcuts, cut.a/scaling, sign(cut.β), nodedata(sp, SOI.get(sp, SOI.Source(), tr)).nlds)
end
function SOI.addcut!(sp::StochasticProgram, tr::Transition, cut::MultiOptimalityCut)
    addcut(nodedata(sp, SOI.get(sp, SOI.Target(), tr)).ocuts, cut.a, cut.β, nodedata(sp, SOI.get(sp, SOI.Source(), tr)).nlds)
end
function SOI.addcut!(sp::StochasticProgram, node, cut::AveragedOptimalityCut)
    addcut(nodedata(sp, node).nlds.localOC, cut.a, cut.β, nodedata(sp, node).nlds)
end

function SOI.applycuts!(sp::StochasticProgram, node)
    applycut(FeasibilityCutGenerator(), sp, node)
    applycut(SOI.get(sp, CutGenerator(), node), sp, node)
end

function SOI.applycuts!(sp::StochasticProgram, tr::Transition, ::Type{<:FeasibilityCut})
    apply!(nodedata(sp, SOI.get(sp, SOI.Target(), tr)).fcuts)
end
function SOI.applycuts!(sp::StochasticProgram, tr::Transition, ::Type{<:MultiOptimalityCut})
    apply!(nodedata(sp, SOI.get(sp, SOI.Target(), tr)).ocuts)
end
function SOI.applycuts!(sp::StochasticProgram, node, ::Type{<:AveragedOptimalityCut})
    apply!(nodedata(sp, node).nlds.localOC)
end


text:
# ---
# jupyter:
#   jupytext:
#     formats: ipynb,jl:hydrogen
#     text_representation:
#       extension: .jl
#       format_name: hydrogen
#       format_version: '1.3'
#       jupytext_version: 1.11.2
#   kernelspec:
#     display_name: Julia 1.6.2
#     language: julia
#     name: julia-1.6
# ---

# %%
arity(f) = extrema(m -> m.nargs, methods(f)) .- 1
findarity(f, k) = (ms = collect(methods(f)); ms[findall(m -> m.nargs - 1 == k, ms)])

# %%
arity(+)

# %%
findarity(+, 5)

# %%
findarity(+, 4)

# %%
@which +(1, 2)

# %%
@which +(1, 2, 3)

# %%
@which +(1, 2, 3, 4)

# %%
]add CairoMakie@0.6.3

# %%

max_stars_repo_path: 0016/arity of a function.jl

max_stars_repo_name: genkuroki/public

max_issues_repo_path: 0016/arity of a function.jl

max_issues_repo_name: genkuroki/public

max_forks_repo_path: 0016/arity of a function.jl

max_forks_repo_name: genkuroki/public


text:
@json struct Label
    id::Int
    node_id::String
    url::String
    name::String
    description::String
    color::String
    default::Bool
end

@json struct Milestone
    url::String
    html_url::String
    labels_url::String
    id::Int
    node_id::String
    number::Int
    state::String
    title::String
    description::String
    creator::User
    open_issues::Int
    closed_issues::Int
    created_at::DateTime
    updated_at::DateTime
    closed_at::DateTime
    due_on::DateTime
end

@json struct Team
    id::Int
    node_id::String
    url::String
    name::String
    slug::String
    description::String
    privacy::String
    permission::String
    members_url::String
    repositories_url::String
    parent::Team
end

# TODO: I don't really know what the right name for this is.
@json struct Head
    label::String
    ref::String
    sha::String
    user::User
    repo::Repo
    base::Head
end

@json struct Link
    href::String
end

@json struct Links
    self::Link
    html::Link
    issue::Link
    comments::Link
    review_comments::Link
    review_comment::Link
    commits::Link
    statuses::Link
end

@json struct PullRequest
    url::String
    id::Int
    node_id::String
    html_url::String
    diff_url::String
    patch_url::String
    issue_url::String
    commits_url::String
    review_comments_url::String
    review_comment_url::String
    comments_url::String
    statuses_url::String
    number::Int
    state::String
    locked::Bool
    title::String
    user::User
    body::String
    labels::Vector{Label}
    milestone::Milestone
    active_lock_reason::String
    created_at::DateTime
    updated_at::DateTime
    closed_at::DateTime
    merged_at::DateTime
    merge_commit_sha::String
    assignee::User
    assignees::Vector{User}
    requested_reviewers::Vector{User}
    requested_teams::Vector{Team}
    head::Head
    base::Head
    repo::Repo
    _links => links::Links
    author_association::String
    draft::Bool
    merged::Bool
    mergeable::Bool
    rebaseable::Bool
    mergeable_state::String
    merged_by::User
    comments::Int
    review_comments::Int
    maintainer_can_modify::Bool
    commits::Int
    additions::Int
    deletions::Int
    changed_files::Int
end

endpoint(::GitHubAPI, ::typeof(get_pull_requests), owner::AStr, repo::AStr) =
    Endpoint(:GET, "/repos/$owner/$repo/pulls")
into(::GitHubAPI, ::typeof(get_pull_requests)) = Vector{PullRequest}

endpoint(::GitHubAPI, ::typeof(get_pull_request), owner::AStr, repo::AStr, number::Integer) =
    Endpoint(:GET, "/repos/$owner/$repo/pulls/$number")
into(::GitHubAPI, ::typeof(get_pull_request)) = PullRequest

endpoint(::GitHubAPI, ::typeof(create_pull_request), owner::AStr, repo::AStr) =
    Endpoint(:POST, "/repos/$owner/$repo/pulls")
into(::GitHubAPI, ::typeof(create_pull_request)) = PullRequest

endpoint(::GitHubAPI, ::typeof(update_pull_request), owner::AStr, repo::AStr, number::Integer) =
    Endpoint(:PATCH, "/repos/$owner/$repo/pulls/$number")
into(::GitHubAPI, ::typeof(update_pull_request)) = PullRequest


text:
function commit_to_registry(pkg::String;
        registry::String = "", verbose = false, push = true
    )

    # parse args
    pkg = isempty(pkg) ? basename(pwd()) : pkg

    # add to registry
    verbose && _info("Update registry"; pkg, registry, push)
    isempty(registry) ?
        LocalRegistry.register(pkg; push) :
        LocalRegistry.register(pkg; registry, push)

    return pkg
end

## ---------------------------------------------------
function run_commit_to_registry(argv::Vector=ARGS)

    ## ---------------------------------------------------------
    argset = ArgParse.ArgParseSettings()
    ArgParse.@add_arg_table! argset begin
        "--pkgdir", "-d"
            help = "the package dir"
            arg_type = String
            default = pwd()
        "--registry", "-r"
            help = "-r=Name specify the register to record to"
            arg_type = String
            default = ""
        "--no-push", "-n"
            help = "If the registry will NOT be push"
            action = :store_true
    end

    parsed_args = ArgParse.parse_args(argv, argset)
    pkgdir = parsed_args["pkgdir"]
    registry = parsed_args["registry"]
    push = !parsed_args["no-push"]

    ## ---------------------------------------------------------
    commit_to_registry(pkgdir;
        registry, verbose = true, push
    )

end


text:
using FastLevenshtein
using Test

@testset "The Levenshtein distance should be 0 if..." begin
    @testset "the sequences are empty." begin
        @test fastlevenshtein("", "") == 0
        @test fastlevenshtein([], []) == 0
    end
    @testset "the sequences are the same." begin
        @test fastlevenshtein("a", "a") == 0
        @test fastlevenshtein("abc", "abc") == 0
        @test fastlevenshtein([1], [1]) == 0
        @test fastlevenshtein([1, 2, 3], [1, 2, 3]) == 0
    end
end;

@testset "The Levenshtein distance should be 1 if..." begin
    @testset "we only need to insert 1 value." begin
        @test fastlevenshtein("abc", "ab") == 1
        @test fastlevenshtein("abc", "ac") == 1
        @test fastlevenshtein("abc", "bc") == 1
        @test fastlevenshtein([1, 2, 3], [1, 2]) == 1
        @test fastlevenshtein([1, 2, 3], [1, 3]) == 1
        @test fastlevenshtein([1, 2, 3], [2, 3]) == 1
    end
    @testset "we only need to update 1 value." begin
        @test fastlevenshtein("abc", "abd") == 1
        @test fastlevenshtein("abc", "adc") == 1
        @test fastlevenshtein("abc", "dbc") == 1
        @test fastlevenshtein([1, 2, 3], [1, 2, 4]) == 1
        @test fastlevenshtein([1, 2, 3], [1, 4, 3]) == 1
        @test fastlevenshtein([1, 2, 3], [4, 2, 3]) == 1
    end
    @testset "we only need to remove 1 value." begin
        @test fastlevenshtein("abc", "dabc") == 1
        @test fastlevenshtein("abc", "adbc") == 1
        @test fastlevenshtein("abc", "abdc") == 1
        @test fastlevenshtein("abc", "abcd") == 1
        @test fastlevenshtein([1, 2, 3], [4, 1, 2, 3]) == 1
        @test fastlevenshtein([1, 2, 3], [1, 4, 2, 3]) == 1
        @test fastlevenshtein([1, 2, 3], [1, 2, 4, 3]) == 1
        @test fastlevenshtein([1, 2, 3], [1, 2, 3, 4]) == 1
    end
end;


text:
@testset "Dict to PowerModels" begin
    @testset "PowerModels Dict fields" begin
        @testset "PowerModels conversion" begin
            file = open(joinpath(@__DIR__,"data/pwf/test_system.pwf"))
            pwf_data = PWF._parse_pwf_data(file)
            pm_data = Dict{String, Any}()

            @testset "Bus" begin
                PWF._pwf2pm_bus!(pm_data, pwf_data, add_control_data = true)

                @test haskey(pm_data, "bus")
                @test length(pm_data["bus"]) == 9

                for (idx, bus) in pm_data["bus"]
                    @test haskey(bus, "zone")
                    @test haskey(bus, "bus_i")
                    @test haskey(bus, "bus_type")
                    @test haskey(bus, "name")
                    @test haskey(bus, "vmax")
                    @test haskey(bus, "source_id")
                    @test haskey(bus, "area")
                    @test haskey(bus, "vmin")
                    @test haskey(bus, "index")
                    @test haskey(bus, "va")
                    @test haskey(bus, "vm")
                    @test haskey(bus, "base_kv")
                    @test haskey(bus, "control_data")
                    @test haskey(bus["control_data"], "voltage_controlled_bus")

                    @test isa(bus["zone"], Int)
                    @test isa(bus["bus_i"], Int)
                    @test isa(bus["bus_type"], Int)
                    @test isa(bus["name"], String)
                    @test isa(bus["vmax"], Float64)
                    @test isa(bus["source_id"], Vector)
                    @test isa(bus["area"], Int)
                    @test isa(bus["vmin"], Float64)
                    @test isa(bus["index"], Int)
                    @test isa(bus["va"], Float64)
                    @test isa(bus["vm"], Float64)
                    @test isa(bus["base_kv"], Float64)
                    @test isa(bus["control_data"], Dict)
                    @test isa(bus["control_data"]["voltage_controlled_bus"], Int)
                end
            end

            @testset "Branch" begin
                PWF._pwf2pm_branch!(pm_data, pwf_data, add_control_data = true)
                PWF._pwf2pm_transformer!(pm_data, pwf_data, add_control_data = true)

                @test haskey(pm_data, "branch")
                @test length(pm_data["branch"]) == 7

                for (idx, branch) in pm_data["branch"]
                    @test haskey(branch, "br_r")
                    @test haskey(branch, "shift")
                    @test haskey(branch, "br_x")
                    @test haskey(branch, "g_to")
                    @test haskey(branch, "g_fr")
                    @test haskey(branch, "b_fr")
                    @test haskey(branch, "source_id")
                    @test haskey(branch, "f_bus")
                    @test haskey(branch, "br_status")
                    @test haskey(branch, "t_bus")
                    @test haskey(branch, "b_to")
                    @test haskey(branch, "index")
                    @test haskey(branch, "angmin")
                    @test haskey(branch, "angmax")
                    @test haskey(branch, "transformer")
                    @test haskey(branch, "tap")
                    @test haskey(branch, "control_data")

                    @test isa(branch["br_r"], Float64)
                    @test isa(branch["shift"], Float64)
                    @test isa(branch["br_x"], Float64)
                    @test isa(branch["g_to"], Float64)
                    @test isa(branch["g_fr"], Float64)
                    @test isa(branch["b_fr"], Float64)
                    @test isa(branch["source_id"], Vector)
                    @test isa(branch["f_bus"], Int)
                    @test isa(branch["br_status"], Int)
                    @test isa(branch["t_bus"], Int)
                    @test isa(branch["b_to"], Float64)
                    @test isa(branch["index"], Int)
                    @test isa(branch["angmin"], Float64)
                    @test isa(branch["angmax"], Float64)
                    @test isa(branch["transformer"], Bool)
                    @test isa(branch["tap"], Float64)
                    @test isa(branch["control_data"], Dict)
                end

            end

            @testset "DCline" begin
                pwf_dc = open(joinpath(@__DIR__,"data/pwf/300bus.pwf"))
                pwf_data_dc = PWF.parse_pwf_to_powermodels(pwf_dc)

                @test haskey(pwf_data_dc, "dcline")
                @test length(pwf_data_dc["dcline"]) == 1
                @test pwf_data_dc["dcline"]["1"]["pf"] == 1.0
                @test isapprox(pwf_data_dc["dcline"]["1"]["pt"], -0.99707, atol = 1e-4)
                @test pwf_data_dc["dcline"]["1"]["vf"] == 1.044
                @test pwf_data_dc["dcline"]["1"]["vt"] == 0.998
            end

        end

        @testset "Resulting Dict" begin
            file = open(joinpath(@__DIR__,"data/pwf/test_system.pwf"))
            pm_data = PWF.parse_pwf_to_powermodels(file; software = PWF.Organon)

            @testset "PowerModels Dict" begin
                @test isa(pm_data, Dict)

                @test haskey(pm_data, "name")
                @test haskey(pm_data, "source_version")
                @test haskey(pm_data, "baseMVA")
                @test haskey(pm_data, "branch")
                @test haskey(pm_data, "bus")
                @test haskey(pm_data, "per_unit")
                @test haskey(pm_data, "source_type")

                @test isa(pm_data["name"], AbstractString)
                @test isa(pm_data["source_version"], String)
                @test isa(pm_data["baseMVA"], Float64)
                @test isa(pm_data["branch"], Dict)
                @test isa(pm_data["bus"], Dict)
                @test isa(pm_data["per_unit"], Bool)
                @test isa(pm_data["source_type"], String)
            end

            @testset "Power Flow" begin

                pm = instantiate_model(pm_data, ACPPowerModel, PowerModels.build_pf)
                result = optimize_model!(pm, optimizer=ipopt)

                @testset "Status" begin
                    @test result["termination_status"] == LOCALLY_SOLVED
                    @test result["dual_status"]        == FEASIBLE_POINT
                    @test result["primal_status"]      == FEASIBLE_POINT
                end

                @testset "Result" begin
                    solution = result["solution"]

                    @test solution["baseMVA"]             == 100.0
                    @test solution["multiinfrastructure"] == false
                    @test solution["multinetwork"]        == false
                    @test solution["per_unit"]            == true
                    @test length(solution["bus"])         == 9
                end

            end

        end

        @testset "Power Flow results" begin
            filenames = ["3bus", "9bus"]

            for name in filenames
                file_raw = joinpath(@__DIR__,"data/raw/$name.raw")
                file_pwf = open(joinpath(@__DIR__,"data/pwf/$name.pwf"))

                pwf_data = PWF.parse_pwf_to_powermodels(file_pwf)
                raw_data = PowerModels.parse_file(file_raw)

                result_pwf = PowerModels.run_ac_pf(pwf_data, ipopt)
                result_raw = PowerModels.run_ac_pf(raw_data, ipopt)

                @test check_same_dict(result_pwf["solution"], result_raw["solution"], atol = 10e-9)
            end

        end

        @testset "PWF to PM corrections" begin
            file = open(joinpath(@__DIR__,"data/pwf/3bus_corrections.pwf"))
            pm_data = PWF.parse_pwf_to_powermodels(file; software = PWF.Organon)

            parse_result = PowerModels.run_ac_pf(pm_data, ipopt);

            result = Dict(
                "1" => Dict("va" => 0, "vm" => 1.029),
                "2" => Dict("va" => -0.0171315, "vm" => 1.03),
                "3" => Dict("va" => -0.02834, "vm" => 0.999)
            );
            @test check_same_dict(parse_result["solution"]["bus"], result)
        end
    end

    @testset "Control data fields" begin
        @testset "Shunt control_data" begin
            file = open(joinpath(@__DIR__,"data/pwf/3bus_shunt_fields.pwf"))
            pm_data = PWF.parse_pwf_to_powermodels(file, software = PWF.ANAREDE, add_control_data = true)

            @test length(pm_data["bus"]) == 3
            @test occursin("B s 1", pm_data["bus"]["1"]["name"])
            @test pm_data["bus"]["2"]["control_data"]["voltage_controlled_bus"] == 3

            @test length(pm_data["shunt"]) == 3

            @test pm_data["shunt"]["1"]["control_data"]["shunt_type"] == 1
            @test pm_data["shunt"]["1"]["control_data"]["shunt_control_type"] == 1
            @test pm_data["shunt"]["1"]["control_data"]["bsmin"] == -0.1
            @test pm_data["shunt"]["1"]["control_data"]["bsmax"] == -0.1
            @test pm_data["shunt"]["1"]["control_data"]["controlled_bus"] == 3
            @test pm_data["shunt"]["1"]["control_data"]["inclination"] == nothing
            @test pm_data["bus"]["3"]["control_data"]["vmmin"] == 1.03
            @test pm_data["bus"]["3"]["control_data"]["vmmax"] == 1.03

            @test pm_data["shunt"]["2"]["control_data"]["shunt_type"] == 2
            @test pm_data["shunt"]["2"]["control_data"]["shunt_control_type"] == 3
            @test pm_data["shunt"]["2"]["control_data"]["bsmin"] == -0.5
            @test pm_data["shunt"]["2"]["control_data"]["bsmax"] == 1.
            @test pm_data["shunt"]["2"]["control_data"]["controlled_bus"] == 1
            @test pm_data["shunt"]["2"]["control_data"]["inclination"] == 2.0
            @test pm_data["bus"]["1"]["control_data"]["vmmin"] == 1.029
            @test pm_data["bus"]["1"]["control_data"]["vmmax"] == 1.029

            @test pm_data["shunt"]["3"]["control_data"]["shunt_type"] == 2
            @test pm_data["shunt"]["3"]["control_data"]["shunt_control_type"] == 2
            @test pm_data["shunt"]["3"]["control_data"]["bsmin"] == -0.3
            @test pm_data["shunt"]["3"]["control_data"]["bsmax"] == 0.6
            @test pm_data["shunt"]["3"]["control_data"]["controlled_bus"] == 2
            @test pm_data["shunt"]["3"]["control_data"]["inclination"] == nothing
            @test pm_data["bus"]["2"]["control_data"]["vmmin"] == 0.9
            @test pm_data["bus"]["2"]["control_data"]["vmmax"] == 1.1

        end

        @testset "Line shunt" begin
            file = open(joinpath(@__DIR__,"data/pwf/test_line_shunt.pwf"))
            pm_data = PWF.parse_pwf_to_powermodels(file; software = PWF.Organon)

            @test pm_data["branch"]["1"]["b_fr"] == 4.5
            @test pm_data["branch"]["1"]["b_to"] == 7.8
            @test pm_data["branch"]["2"]["b_fr"] == -80
            @test pm_data["branch"]["2"]["b_to"] == -0.07
            @test pm_data["branch"]["3"]["b_fr"] == 0.0
            @test pm_data["branch"]["3"]["b_to"] == 0.0
            @test length(pm_data["shunt"]) == 1
            @test pm_data["shunt"]["1"]["bs"] == -1.755
        end

        @testset "Transformer control fields" begin
            data = PWF.parse_pwf_to_powermodels(joinpath(@__DIR__,"data/pwf/9bus_transformer_fields.pwf"), add_control_data = true)

            tap_automatic_control = findfirst(x -> x["f_bus"] == 1 && x["t_bus"] == 4, data["branch"])
            tap_variable_control = findfirst(x -> x["f_bus"] == 2 && x["t_bus"] == 7, data["branch"])
            phase_control = findfirst(x -> x["f_bus"] == 3 && x["t_bus"] == 9, data["branch"])

            tap_automatic_control = data["branch"][tap_automatic_control]["control_data"]
            tap_variable_control = data["branch"][tap_variable_control]["control_data"]
            phase_control = data["branch"][phase_control]["control_data"]

            @test tap_automatic_control["control_type"] == "tap_control"
            @test tap_automatic_control["constraint_type"] == "setpoint"
            @test tap_automatic_control["controlled_bus"] == 1
            @test tap_automatic_control["tapmin"] == 0.85
            @test tap_automatic_control["tapmax"] == 1.15
            @test tap_automatic_control["vmsp"] == 1.075
            @test tap_automatic_control["vmmin"] == 0.9
            @test tap_automatic_control["vmmax"] == 1.1
            @test tap_automatic_control["shift_control_variable"] == nothing
            @test tap_automatic_control["shiftmin"] == nothing
            @test tap_automatic_control["shiftmax"] == nothing
            @test tap_automatic_control["valsp"] == nothing
            @test tap_automatic_control["circuit"] == 1
            @test tap_automatic_control["control"] == false

            @test tap_variable_control["control_type"] == "tap_control"
            @test tap_variable_control["constraint_type"] == "bounds"
            @test tap_variable_control["controlled_bus"] == 7
            @test tap_variable_control["tapmin"] == 0.85
            @test tap_variable_control["tapmax"] == 1.15
            @test tap_variable_control["vmsp"] == 1.078
            @test tap_variable_control["vmmin"] == 0.8
            @test tap_variable_control["vmmax"] == 1.2
            @test tap_variable_control["shift_control_variable"] == nothing
            @test tap_variable_control["shiftmin"] == nothing
            @test tap_variable_control["shiftmax"] == nothing
            @test tap_variable_control["valsp"] == 100.0
            @test tap_variable_control["circuit"] == 1
            @test tap_variable_control["control"] == true

            @test phase_control["control_type"] == "shift_control"
            @test phase_control["constraint_type"] == "setpoint"
            @test phase_control["controlled_bus"] == 9
            @test phase_control["tapmin"] == nothing
            @test phase_control["tapmax"] == nothing
            @test phase_control["vmsp"] == 1.083
            @test phase_control["vmmin"] == 0.8
            @test phase_control["vmmax"] == 1.2
            @test phase_control["shift_control_variable"] == "power"
            @test isapprox(phase_control["shiftmin"], -0.523598775; atol = 1e-5)
            @test isapprox(phase_control["shiftmax"],  0.523598775; atol = 1e-5)
            @test phase_control["valsp"] == 2.505
            @test phase_control["circuit"] == 1
            @test phase_control["control"] == true
        end
    end

    @testset "Organon vs ANAREDE parser" begin
        @testset "DBSH" begin
            data_anarede = PWF.parse_pwf_to_powermodels(joinpath(@__DIR__,"data/pwf/3bus_DBSH.pwf"), software = PWF.ANAREDE)
            data_organon = PWF.parse_pwf_to_powermodels(joinpath(@__DIR__,"data/pwf/3bus_DBSH.pwf"), software = PWF.Organon)

            pm_anarede = PowerModels.instantiate_model(data_anarede, PowerModels.ACPPowerModel, PowerModels.build_pf);
            pm_organon = PowerModels.instantiate_model(data_organon, PowerModels.ACPPowerModel, PowerModels.build_pf);

            result_anarede = PowerModels.optimize_model!(pm_anarede, optimizer = ipopt)
            result_organon = PowerModels.optimize_model!(pm_organon, optimizer = ipopt)

            PowerModels.update_data!(data_anarede, result_anarede["solution"])
            PowerModels.update_data!(data_organon, result_organon["solution"])

            @test isapprox(data_anarede["bus"]["1"]["vm"], 1.029, atol = 1e-3)
            @test isapprox(data_anarede["bus"]["2"]["vm"], 1.03, atol = 1e-3)
            @test isapprox(data_anarede["bus"]["3"]["vm"], 0.960, atol = 1e-3)

            @test isapprox(data_anarede["bus"]["1"]["va"], 0.0, atol = 1e-1)
            @test isapprox(data_anarede["bus"]["2"]["va"], 0.0, atol = 1e-1)
            @test isapprox(data_anarede["bus"]["3"]["va"], 0.8*pi/180, atol = 1e-1)

            @test isapprox(data_anarede["gen"]["1"]["pg"], 0.162, atol = 1e-3)
            @test isapprox(data_anarede["gen"]["2"]["pg"], 0.171, atol = 1e-3)

            @test isapprox(data_anarede["gen"]["1"]["qg"], 0.233, atol = 1e-3)
            @test isapprox(data_anarede["gen"]["2"]["qg"], 0.242, atol = 1e-3)
        end

        @testset "DCER" begin
            data_anarede = PWF.parse_pwf_to_powermodels(joinpath(@__DIR__,"data/pwf/3bus_DCER.pwf"), software = PWF.ANAREDE)
            data_organon = PWF.parse_pwf_to_powermodels(joinpath(@__DIR__,"data/pwf/3bus_DCER.pwf"), software = PWF.Organon)

            pm_anarede = PowerModels.instantiate_model(data_anarede, PowerModels.ACPPowerModel, PowerModels.build_pf);
            pm_organon = PowerModels.instantiate_model(data_organon, PowerModels.ACPPowerModel, PowerModels.build_pf);

            result_anarede = PowerModels.optimize_model!(pm_anarede, optimizer = ipopt)
            result_organon = PowerModels.optimize_model!(pm_organon, optimizer = ipopt)

            PowerModels.update_data!(data_anarede, result_anarede["solution"])
            PowerModels.update_data!(data_organon, result_organon["solution"])

            @test isapprox(data_anarede["bus"]["1"]["vm"], 1.029, atol = 1e-3)
            @test isapprox(data_anarede["bus"]["2"]["vm"], 1.03, atol = 1e-3)
            # @test isapprox(data_anarede["bus"]["3"]["vm"], 1.024, atol = 1e-3)

            @test isapprox(data_anarede["bus"]["1"]["va"], 0.0, atol = 1e-1)
            @test isapprox(data_anarede["bus"]["2"]["va"], 0.0, atol = 1e-1)
            @test isapprox(data_anarede["bus"]["3"]["va"], -2.7*pi/180, atol = 1e-1)

            # DCER implicates ANAREDE control, which can't be replicated in PowerModels
            # @test isapprox(data_anarede["gen"]["1"]["pg"], 0.154, atol = 1e-3)
            # @test isapprox(data_anarede["gen"]["2"]["pg"], 0.163, atol = 1e-3)

            # @test isapprox(data_anarede["gen"]["1"]["qg"], -0.129, atol = 1e-3)
            # @test isapprox(data_anarede["gen"]["2"]["qg"], -0.120, atol = 1e-3)
        end

        @testset "DSHL" begin
            data_anarede = PWF.parse_pwf_to_powermodels(joinpath(@__DIR__,"data/pwf/3bus_DSHL.pwf"), software = PWF.ANAREDE)
            data_organon = PWF.parse_pwf_to_powermodels(joinpath(@__DIR__,"data/pwf/3bus_DSHL.pwf"), software = PWF.Organon)

            pm_anarede = PowerModels.instantiate_model(data_anarede, PowerModels.ACPPowerModel, PowerModels.build_pf);
            pm_organon = PowerModels.instantiate_model(data_organon, PowerModels.ACPPowerModel, PowerModels.build_pf);

            result_anarede = PowerModels.optimize_model!(pm_anarede, optimizer = ipopt)
            result_organon = PowerModels.optimize_model!(pm_organon, optimizer = ipopt)

            PowerModels.update_data!(data_anarede, result_anarede["solution"])
            PowerModels.update_data!(data_organon, result_organon["solution"])

            @test isapprox(data_anarede["bus"]["1"]["vm"], 1.029, atol = 1e-3)
            @test isapprox(data_anarede["bus"]["2"]["vm"], 0.662, atol = 1e-3)
            @test isapprox(data_anarede["bus"]["3"]["vm"], 0.695, atol = 1e-3)

            @test isapprox(data_anarede["bus"]["1"]["va"], 0.0, atol = 1e-1)
            @test isapprox(data_anarede["bus"]["2"]["va"], 19*pi/180, atol = 1e-1)
            @test isapprox(data_anarede["bus"]["3"]["va"], 11.8*pi/180, atol = 1e-1)

            @test isapprox(data_anarede["gen"]["1"]["pg"], 1.205, atol = 1e-3)
            @test isapprox(data_anarede["gen"]["2"]["pg"], 0.130, atol = 1e-3)

            @test isapprox(data_anarede["gen"]["1"]["qg"], 3.191, atol = 1e-3)
            @test isapprox(data_anarede["gen"]["2"]["qg"], 0.025, atol = 1e-3)

            @test isapprox(data_organon["bus"]["1"]["vm"], 1.029, atol = 1e-3)

            # Organon performs automatic controls that can't be replicated in PowerModels
            # @test isapprox(data_organon["bus"]["2"]["vm"], 0.665, atol = 1e-3)
            # @test isapprox(data_organon["bus"]["3"]["vm"], 0.705, atol = 1e-3)

            @test isapprox(data_organon["bus"]["1"]["va"], 0.0, atol = 1e-1)
            @test isapprox(data_organon["bus"]["2"]["va"], 19.34*pi/180, atol = 1e-2)
            # @test isapprox(data_organon["bus"]["3"]["va"], 12.51*pi/180, atol = 1e-2)

            # @test isapprox(data_organon["gen"]["1"]["pg"], 1.131, atol = 1e-3)
            @test isapprox(data_organon["gen"]["2"]["pg"], 0.130, atol = 1e-3)

            # @test isapprox(data_organon["gen"]["1"]["qg"], 3.209, atol = 1e-3)
            @test isapprox(data_organon["gen"]["2"]["qg"], 0.025, atol = 1e-3)
        end

        @testset "DCSC" begin
            data_anarede = PWF.parse_pwf_to_powermodels(joinpath(@__DIR__,"data/pwf/3bus_DCSC.pwf"), software = PWF.ANAREDE)
            data_organon = PWF.parse_pwf_to_powermodels(joinpath(@__DIR__,"data/pwf/3bus_DCSC.pwf"), software = PWF.Organon)

            pm_anarede = PowerModels.instantiate_model(data_anarede, PowerModels.ACPPowerModel, PowerModels.build_pf);
            pm_organon = PowerModels.instantiate_model(data_organon, PowerModels.ACPPowerModel, PowerModels.build_pf);

            result_anarede = PowerModels.optimize_model!(pm_anarede, optimizer = ipopt)
            result_organon = PowerModels.optimize_model!(pm_organon, optimizer = ipopt)

            PowerModels.update_data!(data_anarede, result_anarede["solution"])
            PowerModels.update_data!(data_organon, result_organon["solution"])

            @test isapprox(data_anarede["bus"]["1"]["vm"], 1.029, atol = 1e-3)
            @test isapprox(data_anarede["bus"]["2"]["vm"], 1.030, atol = 1e-3)
            @test isapprox(data_anarede["bus"]["3"]["vm"], 1.030, atol = 1e-3)

            @test isapprox(data_anarede["bus"]["1"]["va"], 0.0, atol = 1e-1)
            @test isapprox(data_anarede["bus"]["2"]["va"], 0.0, atol = 1e-1)
            @test isapprox(data_anarede["bus"]["3"]["va"], -1.8*pi/180, atol = 1e-1)

            @test isapprox(data_anarede["gen"]["1"]["pg"], 0.088, atol = 1e-3)
            @test isapprox(data_anarede["gen"]["2"]["pg"], 0.091, atol = 1e-3)
            @test isapprox(data_anarede["gen"]["3"]["pg"], 0.130, atol = 1e-3)

            @test isapprox(data_anarede["gen"]["1"]["qg"], 0.067, atol = 1e-3)
            @test isapprox(data_anarede["gen"]["2"]["qg"], -0.254, atol = 1e-3)
            @test isapprox(data_anarede["gen"]["3"]["qg"], 0.246, atol = 1e-3)

            @test isapprox(data_organon["bus"]["1"]["vm"], 1.029, atol = 1e-3)
            @test isapprox(data_organon["bus"]["2"]["vm"], 1.030, atol = 1e-3)
            @test isapprox(data_organon["bus"]["3"]["vm"], 1.011, atol = 1e-3)

            @test isapprox(data_organon["bus"]["1"]["va"], 0.0, atol = 1e-1)
            @test isapprox(data_organon["bus"]["2"]["va"], 0.0, atol = 1e-2)
            @test isapprox(data_organon["bus"]["3"]["va"], -0.69*pi/180, atol = 1e-2)

            @test isapprox(data_organon["gen"]["1"]["pg"], 0.087, atol = 1e-3)
            @test isapprox(data_organon["gen"]["2"]["pg"], 0.090, atol = 1e-3)
            @test isapprox(data_organon["gen"]["3"]["pg"], 0.130, atol = 1e-3)

            @test isapprox(data_organon["gen"]["1"]["qg"], 0.176, atol = 1e-3)
            @test isapprox(data_organon["gen"]["2"]["qg"], -0.145, atol = 1e-3)
            @test isapprox(data_organon["gen"]["3"]["qg"], 0.025, atol = 1e-3)
        end

        @testset "DC line" begin
            data_anarede = PWF.parse_pwf_to_powermodels(joinpath(@__DIR__,"data/pwf/3bus_DCline.pwf"), software = PWF.ANAREDE)
            pm_anarede = PowerModels.instantiate_model(data_anarede, PowerModels.ACPPowerModel, PowerModels.build_pf);
            result_anarede = PowerModels.optimize_model!(pm_anarede, optimizer = ipopt)
            PowerModels.update_data!(data_anarede, result_anarede["solution"])

            @test isapprox(data_anarede["bus"]["1"]["vm"], 1.029, atol = 1e-3)
            @test isapprox(data_anarede["bus"]["2"]["vm"], 1.030, atol = 1e-3)
            @test isapprox(data_anarede["bus"]["3"]["vm"], 0.997, atol = 1e-3)

            @test isapprox(data_anarede["bus"]["1"]["va"], 0.0, atol = 1e-1)
            @test isapprox(data_anarede["bus"]["2"]["va"], 0.0, atol = 1e-1)
            @test isapprox(data_anarede["bus"]["3"]["va"], -1.2*pi/180, atol = 1e-1)

            @test isapprox(data_anarede["gen"]["1"]["pg"], 6.405, atol = 1e-3)
            @test isapprox(data_anarede["gen"]["2"]["pg"], -5.979, atol = 1e-3)

            # PowerModels' DC line model can't replicate exactly ANAREDE's
            # @test isapprox(data_anarede["gen"]["1"]["qg"], 2.503, atol = 1e-3)
            # @test isapprox(data_anarede["gen"]["2"]["qg"], 2.605, atol = 1e-3)

            @test isapprox(data_anarede["dcline"]["1"]["pf"], 6.250, atol = 1e-3)
            @test isapprox(data_anarede["dcline"]["1"]["pt"], -6.136, atol = 1e-3)
            # @test isapprox(data_anarede["dcline"]["1"]["qf"], 2.473, atol = 1e-3)
            # @test isapprox(data_anarede["dcline"]["1"]["qt"], 2.573, atol = 1e-3)
        end
    end
end


text:
##### Beginning of file

module MirrorUpdater # Begin module MirrorUpdater

__precompile__(true)

import ArgParse
import Conda
import Coverage
import Dates
import GitHub
import HTTP
import JSON
import Pkg
import Test
import TimeZones

include(joinpath("delayederrors.jl"))

include(joinpath("package_directory.jl"))
include(joinpath("version.jl"))
include(joinpath("welcome.jl"))

include(joinpath("Types", "Types.jl"))

include(joinpath("Utils", "Utils.jl"))

include(joinpath("Common", "Common.jl"))

include(joinpath("Run", "Run.jl"))

include(joinpath("CommandLine", "CommandLine.jl"))

include(joinpath("Hosts", "Hosts.jl"))

include(joinpath("init.jl"))

end # End module MirrorUpdater

##### Beginning of file


text:
using Documenter, MathematicalPredicates
import LazySets

DocMeta.setdocmeta!(MathematicalPredicates, :DocTestSetup,
                    :(using MathematicalPredicates); recursive=true)

makedocs(
    sitename = "MathematicalPredicates.jl",
    modules = [MathematicalPredicates],
    format = Documenter.HTML(
        prettyurls = get(ENV, "CI", nothing) == "true",
        assets = ["assets/aligned.css"]),
    pages = [
        "Home" => "index.md",
        "About" => "about.md"
    ],
    strict = true
)

deploydocs(
    repo = "github.com/JuliaReach/MathematicalPredicates.jl.git",
    push_preview = true
)


text:
function position(decal::Maple.Decal)
    return (
        floor(Int, decal.x),
        floor(Int, decal.y)
    )
end

function decalSelection(decal::Maple.Decal)
    texture = "decals/$(decal.texture)"
    sprite = getTextureSprite(texture)

    x, y = round(Int, decal.x), round(Int, decal.y)
    sx, sy = round(Int, decal.scaleX), round(Int, decal.scaleY)

    width, height = sprite.width, sprite.height
    realWidth, realHeight = sprite.realWidth, sprite.realHeight

    drawX, drawY = floor(Int, x - (realWidth / 2 + sprite.offsetX) * sx), floor(Int, y - (realHeight / 2 + sprite.offsetY) * sy)
    drawX += sx < 0 ? width * sx : 0
    drawY += sy < 0 ? height * sy : 0

    return Rectangle(drawX, drawY, width * abs(sx), height * abs(sy))
end

function drawDecal(ctx::Cairo.CairoContext, decal::Maple.Decal; alpha::Number=getGlobalAlpha())
    texture = "decals/$(decal.texture)"
    sprite = getTextureSprite(texture, "Gameplay")

    realWidth, realHeight = sprite.realWidth, sprite.realHeight
    width, height = sprite.width, sprite.height

    x, y = round(Int, decal.x), round(Int, decal.y)
    sx, sy = round(Int, decal.scaleX), round(Int, decal.scaleY)

    if width > 0 && height > 0
        Cairo.save(ctx)

        translate(ctx, x, y)
        scale(ctx, sx, sy)
        translate(ctx, -sprite.offsetX, -sprite.offsetY)
        translate(ctx, -realWidth / 2, -realHeight / 2)

        drawImage(ctx, sprite, 0, 0, alpha=alpha)

        restore(ctx)

    else
        debug.log("Couldn't render decal with texture '$texture' at ($x, $y)", "DRAWING_DECAL_MISSING")
    end
end

function spritesToDecalTextures(sprites::Dict{String, SpriteHolder})
    res = String[]

    for (path, spriteHolder) in sprites
        if startswith(path, "decals/")
            if spriteHolder.sprite.width > 0 && spriteHolder.sprite.height > 0
                push!(res, path[8:end])
            end
        end
    end

    return res
end

animationRegex = r"\D+0*?$"
filterAnimations(s::String) = occursin(animationRegex, s)

function decalTextures(animationFrames::Bool=false)
    Ahorn.loadExternalSprites!()
    textures = Ahorn.spritesToDecalTextures(Ahorn.getAtlas("Gameplay"))

    if !animationFrames
        filter!(filterAnimations, textures)
    end

    sort!(textures)

    return textures
end

function decalConfigOptions(decal::Maple.Decal, ignores::Array{String, 1}=String[])
    res = Form.Option[]

    names = get(langdata, ["placements", "decals", "names"])
    tooltips = get(langdata, ["placements", "decals", "tooltips"])

    ignores = vcat("__name", ignores)
    data = Dict(decal)

    for (attr, value) in data
        if attr in ignores
            continue
        end

        name = expandTooltipText(get(names, Symbol(attr), ""))
        displayName = isempty(name) ? humanizeVariableName(attr) : name
        tooltip = expandTooltipText(get(tooltips, Symbol(attr), ""))
        textures = attr == "texture" ? decalTextures() : nothing

        push!(res, Form.suggestOption(displayName, value, dataName=attr, tooltip=tooltip, choices=textures, editable=true))
    end

    return res
end


text:
# Set up PoolModel
pm = PoolModel("ss1")
pm <= Setting(:data_vintage, "190822")
filepath = dirname(@__FILE__)
pm <= Setting(:dataroot, "$(filepath)/../reference/")
df = load_data(pm)
data = df_to_matrix(pm, df)

# Run test
bma_ans = zeros(2)
bma_ans[1] = 0.5 * data[1,1] / (.5 * data[1,1] + .5 * data[2,1])
bma_ans[2] = bma_ans[1] * data[1,2] / (bma_ans[1] * data[1,2] + (1 - bma_ans[1]) * data[2,2])
@testset "Check that BMA is correct for PoolModels" begin
    estimate_bma(pm, df[1:2,:]; save_output = false)
    global λ, ~ = estimate_bma(pm, df[1:2,:]; save_output = false, return_output = true)
    @test λ == bma_ans
    global λ, ~ = estimate_bma(pm, data[:,1:2]; save_output = false, return_output = true)
    @test λ == bma_ans
end


text:
using OrdinaryDiffEq, DataFrames, Test
f_2dlinear = (du,u,p,t) -> du.=1.01u;
prob = ODEProblem(f_2dlinear,rand(2,2),(0.0,1.0));
sol1 =solve(prob,Euler();dt=1//2^(4));
df = DataFrame(sol1)
@test names(df) == ["timestamp","value1","value2","value3","value4"]

prob = ODEProblem(ODEFunction(f_2dlinear,syms=[:a,:b,:c,:d]),rand(2,2),(0.0,1.0));
sol2 =solve(prob,Euler();dt=1//2^(4));
df = DataFrame(sol2)
@test names(df) == ["timestamp","a","b","c","d"]


text:
n = 10 # rand(1:10)
@test matrixdepot("parter", n) == matrixdepot("parter", Float64, n)

A = matrixdepot("cauchy", [1.:n;] .+ 0.5, -[1.:n;])

@test matrixdepot("parter", n) ≈ A
println("'parter' passed test...")


text:
import Base: getindex, to_index
export IndexAtom, getindex

const ArrayOrNothing = Union{AbstractArray, Nothing}

struct IndexAtom <: AbstractExpr
    head::Symbol
    id_hash::UInt64
    children::Tuple{AbstractExpr}
    size::Tuple{Int, Int}
    rows::ArrayOrNothing
    cols::ArrayOrNothing
    inds::ArrayOrNothing

    function IndexAtom(x::AbstractExpr, rows::AbstractArray, cols::AbstractArray)
        sz = (length(rows), length(cols))
        children = (x,)
        return new(:index, hash((children, rows, cols, nothing)), children, sz, rows, cols, nothing)
    end

    function IndexAtom(x::AbstractExpr, inds::AbstractArray)
        sz = (length(inds), 1)
        children = (x,)
        return new(:index, hash((children, nothing, nothing, inds)), children, sz, nothing, nothing, inds)
    end
end

## Type definition ends here

function sign(x::IndexAtom)
    return sign(x.children[1])
end

function monotonicity(x::IndexAtom)
    return (Nondecreasing(),)
end

function curvature(x::IndexAtom)
    return ConstVexity()
end

function evaluate(x::IndexAtom)
    if x.inds === nothing
        return getindex(evaluate(x.children[1]), x.rows, x.cols)
    else
        return getindex(evaluate(x.children[1]), x.inds)
    end
end

function conic_form!(x::IndexAtom, unique_conic_forms::UniqueConicForms)
    if !has_conic_form(unique_conic_forms, x)
        m = length(x)
        n = length(x.children[1])

        if x.inds === nothing
            sz = length(x.cols) * length(x.rows)
            J = Array{Int}(undef, sz)
            k = 1

            num_rows = x.children[1].size[1]
            for c in x.cols
                for r in x.rows
                    J[k] = num_rows * (convert(Int, c) - 1) + convert(Int, r)
                    k += 1
                end
            end

            index_matrix = sparse(1:sz, J, 1.0, m, n)
        else
            index_matrix = sparse(1:length(x.inds), x.inds, 1.0, m, n)
        end
        objective = conic_form!(x.children[1], unique_conic_forms)
        objective = index_matrix * objective
        cache_conic_form!(unique_conic_forms, x, objective)
    end
    return get_conic_form(unique_conic_forms, x)
end

## API Definition begins

getindex(x::AbstractExpr, rows::AbstractVector{T}, cols::AbstractVector{T}) where {T<:Real} = IndexAtom(x, rows, cols)
getindex(x::AbstractExpr, inds::AbstractVector{<:Real}) = IndexAtom(x, inds)
getindex(x::AbstractExpr, ind::Real) = getindex(x, ind:ind)
getindex(x::AbstractExpr, row::Real, col::Real) = getindex(x, row:row, col:col)
getindex(x::AbstractExpr, row::Real, cols::AbstractVector{<:Real}) = getindex(x, row:row, cols)
getindex(x::AbstractExpr, rows::AbstractVector{<:Real}, col::Real) = getindex(x, rows, col:col)
# XXX todo: speed test; there are lots of possible solutions for this
function getindex(x::AbstractExpr, I::AbstractMatrix{Bool})
    return [xi for (xi,ii) in zip(x,I) if ii]
end
function getindex(x::AbstractExpr, I::AbstractVector{Bool})
    return [xi for (xi,ii) in zip(x,I) if ii]
end
# Colon methods
# All rows and columns
function getindex(x::AbstractExpr, cln_r::Colon, cln_c::Colon)
    rows, cols = size(x)
    getindex(x, 1:rows, 1:cols)
end
# All rows for this column(s)
getindex(x::AbstractExpr, cln_r::Colon, col) = getindex(x, 1:size(x)[1], col)
# All columns for this row(s)
getindex(x::AbstractExpr, row, cln_c::Colon) = getindex(x, row, 1:size(x)[2])

## API Definition ends