text:
function asap_plus(num_links, A)
    multiple_copies = true
    arch = TopLevel{A,2}("asap_plus")

    # Extra parameters
    num_fifos = 2
    mem_dict = Dict([(16,5),(17,5)] => [(15,5),(18,5)],
                    [(16,10),(17,10)] => [(15,10),(18,10)],
                    [(16,15),(17,15)] => [(15,15),(18,15)],
                    [(16,20),(17,20)] => [(15,20),(18,20)],
                    [(16,25),(17,25)] => [(15,25),(18,25)],
                    [(16,30),(17,30)] => [(15,30),(18,30)],
                    [(4,17),(4,18)] => [(4,16),(4,19)],
                    [(9,17),(9,18)] => [(9,16),(9,19)],
                    [(14,17),(14,18)] => [(14,16),(14,19)],
                    [(19,17),(19,18)] => [(19,16),(19,19)],
                    [(24,17),(24,18)] => [(24,16),(24,19)],
                    [(29,17),(29,18)] => [(29,16),(29,19)])

    mem_addrs = Array{Tuple{Int64,Int64},1}()
    mem_neighbor_addrs = Array{Tuple{Int64,Int64},1}()
    for (keys,values) in mem_dict
        for key in keys
            push!(mem_addrs,key)
        end
        for value in values
            push!(mem_neighbor_addrs,value)
        end
    end

    ####################
    # Normal Processor #
    ####################
    processor = build_processor_tile(num_links)
    for r in 1:32, c in 2:33
        in((r,c),mem_addrs) && continue
        in((r,c),mem_neighbor_addrs) && continue
        if multiple_copies
            add_child(arch, deepcopy(processor), CartesianIndex(r,c))
        else
            add_child(arch, processor, CartesianIndex(r,c))
        end
    end

    ####################
    # Memory Processor #
    ####################
    memory_processor = build_memory_processor_tile(num_links)
    for mem_neighbor_addr in mem_neighbor_addrs
        if multiple_copies
            add_child(arch, deepcopy(memory_processor),
                    CartesianIndex(mem_neighbor_addr[1],mem_neighbor_addr[2]))
        else
            add_child(arch, memory_processor,
                    CartesianIndex(mem_neighbor_addr[1],mem_neighbor_addr[2]))
        end
    end

    #################
    # 1 Port Memory #
    #################
    memory_1port = build_memory_1port()
    for mem_addr in mem_addrs
        add_child(arch, memory_1port, CartesianIndex(mem_addr[1],mem_addr[2]))
    end

    #################
    # Input Handler #
    #################
    input_handler = build_input_handler(num_links)
    for r ∈ (1, 13), c = 1
        add_child(arch, input_handler, CartesianIndex(r,c))
    end
    for r ∈ (12, 18), c = 34
        add_child(arch, input_handler, CartesianIndex(r,c))
    end

    ##################
    # Output Handler #
    ##################
    output_handler = build_output_handler(num_links)
    for (r,c) ∈ zip((12,18,1,14), (1, 1, 34, 34))
        add_child(arch, output_handler, CartesianIndex(r,c))
    end

    #######################
    # Global Interconnect #
    #######################
    connect_processors(arch, num_links)
    connect_io(arch, num_links)
    connect_memories_plus(arch)
    return arch
end

function connect_memories_plus(tl)
    # Create metadata dictionary for the memory links.
    metadata = Dict(
        "cost"      => 1.0,
        "capacity"  => 1,
        "network"   => ["memory"],
   )

    ###########################
    # Connect 1 port memories #
    ###########################
    proc_rule = x -> search_metadata!(x, "attributes", "memory_processor", in)
    mem1_rule = x -> search_metadata!(x, "attributes", "memory_1port", in)

    offset_rule = [(CartesianIndex(-1,0), "out[0]", "memory_in"),
                   (CartesianIndex(1,0), "out[0]", "memory_in"),
                   (CartesianIndex(0,-1), "out[0]", "memory_in"),
                   (CartesianIndex(0,1), "out[0]", "memory_in"),]
    connection_rule(tl, offset_rule, mem1_rule, proc_rule, metadata = metadata)

    offset_rule = [(CartesianIndex(1,0), "memory_out", "in[0]"),
                   (CartesianIndex(-1,0), "memory_out", "in[0]"),
                   (CartesianIndex(0,1), "out[0]", "memory_in"),
                   (CartesianIndex(0,-1), "out[0]", "memory_in"),]
    connection_rule(tl, offset_rule, proc_rule, mem1_rule, metadata = metadata)

    return nothing
end


text:
# Copyright (c) 2017: Miles Lubin and contributors
# Copyright (c) 2017: Google Inc.
#
# Use of this source code is governed by an MIT-style license that can be found
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.

module TestConstraintNormSpectral

using Test

using MathOptInterface
const MOI = MathOptInterface

function runtests()
    for name in names(@__MODULE__; all = true)
        if startswith("$(name)", "test_")
            @testset "$(name)" begin
                getfield(@__MODULE__, name)()
            end
        end
    end
    return
end

include("../utilities.jl")

function test_NormSpectral()
    mock = MOI.Utilities.MockOptimizer(
        MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()),
    )
    config = MOI.Test.Config()
    bridged_mock = MOI.Bridges.Constraint.NormSpectral{Float64}(mock)
    MOI.Test.runtests(
        bridged_mock,
        config,
        include = [
            "test_basic_VectorOfVariables_NormSpectralCone",
            "test_basic_VectorAffineFunction_NormSpectralCone",
            "test_basic_VectorQuadraticFunction_NormSpectralCone",
        ],
    )
    MOI.empty!(bridged_mock)
    inv6 = inv(6)
    rt3 = sqrt(3)
    invrt12 = inv(2 * rt3)
    psd_dual = [
        inv6,
        -invrt12,
        inv6,
        invrt12,
        -invrt12,
        inv6,
        0,
        0,
        0,
        0,
        -invrt12,
        invrt12,
        -invrt12,
        0,
        0.5,
    ]
    mock.optimize! =
        (mock::MOI.Utilities.MockOptimizer) -> MOI.Utilities.mock_optimize!(
            mock,
            [rt3],
            (
                MOI.VectorAffineFunction{Float64},
                MOI.PositiveSemidefiniteConeTriangle,
            ) => [psd_dual],
        )
    MOI.Test.test_conic_NormSpectralCone(bridged_mock, config)
    var_names = ["t"]
    MOI.set(
        bridged_mock,
        MOI.VariableName(),
        MOI.get(bridged_mock, MOI.ListOfVariableIndices()),
        var_names,
    )
    psd = MOI.get(
        mock,
        MOI.ListOfConstraintIndices{
            MOI.VectorAffineFunction{Float64},
            MOI.PositiveSemidefiniteConeTriangle,
        }(),
    )
    @test length(psd) == 1
    MOI.set(mock, MOI.ConstraintName(), psd[1], "psd")

    s = """
    variables: t
    psd: [t, 0.0, t, 0.0, 0.0, t, 1.0, 1.0, 0.0, t, 1.0, -1.0, 1.0, 0.0, t] in MathOptInterface.PositiveSemidefiniteConeTriangle(5)
    minobjective: t
    """
    model = MOI.Utilities.Model{Float64}()
    MOI.Utilities.loadfromstring!(model, s)
    MOI.Test.util_test_models_equal(mock, model, var_names, ["psd"])
    spec = MOI.get(
        bridged_mock,
        MOI.ListOfConstraintIndices{
            MOI.VectorAffineFunction{Float64},
            MOI.NormSpectralCone,
        }(),
    )
    @test length(spec) == 1
    MOI.set(bridged_mock, MOI.ConstraintName(), spec[1], "spec")

    s = """
    variables: t
    spec: [t, 1.0, 1.0, 1.0, -1.0, 0.0, 1.0] in MathOptInterface.NormSpectralCone(2, 3)
    minobjective: t
    """
    model = MOI.Utilities.Model{Float64}()
    MOI.Utilities.loadfromstring!(model, s)
    MOI.Test.util_test_models_equal(bridged_mock, model, var_names, ["spec"])
    ci = first(
        MOI.get(
            bridged_mock,
            MOI.ListOfConstraintIndices{
                MOI.VectorAffineFunction{Float64},
                MOI.NormSpectralCone,
            }(),
        ),
    )
    attr = MOI.ConstraintPrimalStart()
    @test MOI.supports(bridged_mock, attr, typeof(ci))
    value = Float64[4, 1, 1, 1, -1, 0, 1]
    MOI.set(bridged_mock, attr, ci, value)
    @test MOI.get(bridged_mock, attr, ci) ≈ value
    @test MOI.get(mock, attr, psd[1]) ==
          Float64[4, 0, 4, 0, 0, 4, 1, 1, 0, 4, 1, -1, 1, 0, 4]
    _test_delete_bridge(
        bridged_mock,
        ci,
        1,
        ((
            MOI.VectorAffineFunction{Float64},
            MOI.PositiveSemidefiniteConeTriangle,
            0,
        ),),
    )
    return
end

function test_NormNuclear()
    mock = MOI.Utilities.MockOptimizer(
        MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()),
    )
    config = MOI.Test.Config()
    bridged_mock = MOI.Bridges.Constraint.NormNuclear{Float64}(mock)
    MOI.Test.runtests(
        bridged_mock,
        config,
        include = [
            "test_basic_VectorOfVariables_NormNuclearCone",
            "test_basic_VectorAffineFunction_NormNuclearCone",
            "test_basic_VectorQuadraticFunction_NormNuclearCone",
        ],
    )
    MOI.empty!(bridged_mock)
    rt2 = sqrt(2)
    rt3 = sqrt(3)
    invrt2 = inv(rt2)
    invrt3 = inv(rt3)
    var_primal = [
        rt2 + rt3,
        invrt2 + invrt3,
        invrt2 - invrt3,
        invrt2 + invrt3,
        invrt3,
        -invrt3,
        invrt3,
        rt2,
        0,
        rt3,
    ]
    invrt8 = inv(sqrt(8))
    invrt12 = inv(sqrt(12))
    psd_dual = [
        0.5,
        0,
        0.5,
        0,
        0,
        0.5,
        -invrt8,
        -invrt8,
        0,
        invrt8,
        -invrt12,
        invrt12,
        -invrt12,
        0,
        0.5,
    ]
    mock.optimize! =
        (mock::MOI.Utilities.MockOptimizer) -> MOI.Utilities.mock_optimize!(
            mock,
            var_primal,
            (MOI.ScalarAffineFunction{Float64}, MOI.GreaterThan{Float64}) =>
                [[1.0]],
            (
                MOI.VectorAffineFunction{Float64},
                MOI.PositiveSemidefiniteConeTriangle,
            ) => [psd_dual],
        )
    MOI.Test.test_conic_NormNuclearCone(bridged_mock, config)
    greater = MOI.get(
        mock,
        MOI.ListOfConstraintIndices{
            MOI.ScalarAffineFunction{Float64},
            MOI.GreaterThan{Float64},
        }(),
    )
    psd = MOI.get(
        mock,
        MOI.ListOfConstraintIndices{
            MOI.VectorAffineFunction{Float64},
            MOI.PositiveSemidefiniteConeTriangle,
        }(),
    )
    var_names =
        ["t", "U11", "U12", "U22", "U31", "U32", "U33", "V11", "V12", "V22"]
    MOI.set(
        mock,
        MOI.VariableName(),
        MOI.get(mock, MOI.ListOfVariableIndices()),
        var_names,
    )
    @test length(greater) == 1
    MOI.set(mock, MOI.ConstraintName(), greater[1], "greater")
    @test length(psd) == 1
    MOI.set(mock, MOI.ConstraintName(), psd[1], "psd")

    s = """
    variables: t, U11, U12, U22, U31, U32, U33, V11, V12, V22
    greater: t + -0.5U11 + -0.5U22 + -0.5U33 + -0.5V11 + -0.5V22 >= 0.0
    psd: [U11, U12, U22, U31, U32, U33, 1.0, 1.0, 0.0, V11, 1.0, -1.0, 1.0, V12, V22] in MathOptInterface.PositiveSemidefiniteConeTriangle(5)
    minobjective: t
    """
    model = MOI.Utilities.Model{Float64}()
    MOI.Utilities.loadfromstring!(model, s)
    MOI.Test.util_test_models_equal(mock, model, var_names, ["greater", "psd"])
    MOI.set(
        bridged_mock,
        MOI.VariableName(),
        MOI.get(bridged_mock, MOI.ListOfVariableIndices()),
        ["t"],
    )
    nuc = MOI.get(
        bridged_mock,
        MOI.ListOfConstraintIndices{
            MOI.VectorAffineFunction{Float64},
            MOI.NormNuclearCone,
        }(),
    )
    @test length(nuc) == 1
    MOI.set(bridged_mock, MOI.ConstraintName(), nuc[1], "nuc")

    s = """
    variables: t
    nuc: [t, 1.0, 1.0, 1.0, -1.0, 0.0, 1.0] in MathOptInterface.NormNuclearCone(2, 3)
    minobjective: t
    """
    model = MOI.Utilities.Model{Float64}()
    MOI.Utilities.loadfromstring!(model, s)
    MOI.Test.util_test_models_equal(bridged_mock, model, ["t"], ["nuc"])
    ci = first(
        MOI.get(
            bridged_mock,
            MOI.ListOfConstraintIndices{
                MOI.VectorAffineFunction{Float64},
                MOI.NormNuclearCone,
            }(),
        ),
    )
    attr = MOI.ConstraintDualStart()
    @test MOI.supports(bridged_mock, attr, typeof(ci))
    value = Float64[4, 1, 1, 1, -1, 0, 1]
    MOI.set(bridged_mock, attr, ci, value)
    @test MOI.get(bridged_mock, attr, ci) ≈ value
    @test MOI.get(mock, attr, greater[1]) == 4
    @test MOI.get(mock, attr, psd[1]) ==
          Float64[4, 0, 4, 0, 0, 4, 0.5, 0.5, 0, 4, 0.5, -0.5, 0.5, 0, 4]
    _test_delete_bridge(
        bridged_mock,
        ci,
        1,
        (
            (MOI.ScalarAffineFunction{Float64}, MOI.GreaterThan{Float64}, 0),
            (
                MOI.VectorAffineFunction{Float64},
                MOI.PositiveSemidefiniteConeTriangle,
                0,
            ),
        ),
    )
    return
end

end  # module

TestConstraintNormSpectral.runtests()

ext: jl

max_stars_repo_name: JuliaOpt/MathOptInterface

max_issues_repo_name: JuliaOpt/MathOptInterface

max_forks_repo_name: JuliaOpt/MathOptInterface


text:
using Flux
using Revise
using MFGnet
using Test

R = Float32
m = 16
d = 2
nTh = 2

(K1,b1) = (R(.1)*randn(R,m,d+1),R(.1)*randn(R,m))
Θ1 = (K1,b1)
(K2,b2) = (R(.1)*repeat(randn(R,m,m),1,1,nTh),R(.1)*repeat(randn(R,m),1,nTh))
Θ2 = (K2,b2)
ΘN = (Θ1, Θ2)
(w0,A0,c0) = (ones(R,m)/R(sqrt(m)),zeros(R,d+1,d+1),zeros(R,d+1))
Θ = (w0,ΘN,A0,c0)

As  = copy(A0)
K1s = copy(K1)
K2s = copy(K2)
b1s = copy(b1)
b2s = copy(b2)
ws  = copy(w0)
cs  = copy(c0)

parms = (ws,((K1s,b1s),(K2s,b2s)),As,cs)
Θopt  = Array(MFGnet.param2vec(parms))

@test MFGnet.getParmsType(parms)==R
@test typeof(Θopt[1])==R
# println("Param2Vec and getParmsType Test Passed!")
#

max_stars_repo_name: EmoryMLIP/MFGnet

max_issues_repo_name: EmoryMLIP/MFGnet

max_forks_repo_name: EmoryMLIP/MFGnet


text:
using jlmie
using Plots

# settings
# structure
nmat = 4  # refractive index of a sphere
radius = 100*1e-9

# environment
nenv = 1.00

# wavelenth
lbd0 = (400:1000)*1e-9; lbdp = lbd0.*1e9;

# xy plot range
x = (-150:2:150)*1e-9
y = 0.0
z = (-150:2:150)*1e-9
xp = x*1e9; yp = y*1e9; zp = z*1e9;

# other settings
nmax = -1  # -1: namx large enough (determined from x)

# main
Et,Er,Ep = jlmie_Enf(nmat,radius,lbd0,nenv,x,y,z,nmax)

# save
if true
    runningfilename = splitext(splitpath(@__FILE__)[end])[1]
    outfilename = ".\\result\\" * runningfilename
    savefig(plt,outfilename)
    println("Graph has been saved in result directory")
end

max_stars_repo_name: Hinamoooon/jlmie

max_issues_repo_name: Hinamoooon/jlmie

max_forks_repo_name: Hinamoooon/jlmie


text:
module Visualization

# Write your package code here.
    # install necessary packages (open source)
    using Statistics, Plots, Distributions, FFTW, LinearAlgebra

    # install necessary packages (original)
    using .FundamentalStats

    # function name
    #OK
    #export SpectraPlot
    export BarcodePlot
    export BarcodePlot!
    export BinningPlot
    export BinningPlot!
    export Correlogram
    export Correlogram!
    export VariogramPlot
    export VariogramPlot!
    export RCDFPlot
    export RCDFPlot!
    export ECDFPlot
    export ECDFPlot!

    function LinearFilterPlot()
    end

    function BarcodePlot(t::Vector=[nothing], c="black", d::Dict = Dict(); data::Vector = t,color=c,kwargs::Dict = d)
        r = plot([data[1],data[1]],[0,1],linestyle=:solid,
            color=color,
            size=(3000,300),
            ylabel=nothing,
            ytick=nothing,
            xlim = [0,t[end]]
            ;kwargs)
        for i in data[2:end]
            plot!(r,[i,i],[0,1],linestyle=:solid,
            label=nothing,
            color=color,
            size=(3000,300),
            ylabel=nothing,
            ytick=nothing,
            xlim = [0,t[end]]
            ;kwargs
            )
        end
        return r
    end

    function BarcodePlot!(t::Vector=[nothing], c="black", d::Dict = Dict(); data::Vector = t,color=c,kwargs::Dict = d)
        r = plot!([data[1],data[1]],[0,1],linestyle=:solid,
            color=color,
            size=(3000,300),
            ylabel=nothing,
            ytick=nothing,
            xlim = [0,t[end]]
            ;kwargs)
        for i in data[2:end]
            plot!(r,[i,i],[0,1],linestyle=:solid,
            label=nothing,
            color=color,
            size=(3000,300),
            ylabel=nothing,
            ytick=nothing,
            xlim = [0,t[end]]
            ;kwargs
            )
        end
    end

    function Binningplot(X::Vector=[nothing], Y::Vector=[nothing], N = sqrt(length(X)), k::Dict = Dict() ;
        x::Vector=X, y::Vector=Y, num = N, kwargs::Dict = k )
        a,b,c = Binning(x = x, y = y, num = N)
        return plot(a,b,yerror = c;kwargs)
    end

    function Binningplot!(X::Vector=[nothing], Y::Vector=[nothing], N = sqrt(length(X)), k::Dict = Dict() ;
        x::Vector=X, y::Vector=Y, num = N, kwargs::Dict = k )
        a,b,c = Binning(x = x, y = y, num = N)
        plot!(a,b,yerror = c;kwargs)
    end

    function Correlogram(x::Vector = [nothing], l::Int64 = 10, k::Dict = Dict();
                            data::Vector = x, lag::Int64 = l, kwargs::Dict = k)
        x::Vector{Float64} = collect(0:lag)
        y::Vector{Float64} = AutoCorrelation(data = data,lag = lag+1)
        return plot(x, y; kwargs)
    end

    function Correlogram!(x::Vector = [nothing], l::Int64 = 10, k::Dict = Dict();
        data::Vector = x, lag::Int64 = l, kwargs::Dict = k)
        x::Vector{Float64} = collect(0:lag)
        y::Vector{Float64} = AutoCorrelation(data = data,lag = lag+1)
        plot!(x, y; kwargs)
    end

    function VariogramPlot(x::Vector = [nothing], l::Int64 = 10, k::Dict = Dict();
                            data::Vector=x, lag::Int64 = l, kwargs::Dict = k)
        x::Vector{Float64},y::Vector{Float64} = Variogram(data = data,lag = lag)
        return plot(x, y; kwargs)
    end

    function VariogramPlot!(x::Vector = [nothing], l::Int64 = 10,k::Dict = Dict();
                                 data::Vector=x,lag::Int64 = l, kwargs::Dict = k)
        x::Vector, y::Vector = Variogram(data = data,lag = lag)
        plot!(x, y; kwargs)
    end

    function RCDFPlot(x::Vector = [nothing], b::Bool = true, k::Dict = Dict();
                                data::Vector = x,complementary::Bool = b, kwargs::Dict= k)
        x::Vector, y::Vector = RCDF(data = data,complementary = complementary)
        return plot(x, y; kwargs)
    end

    function RCDFPlot!(x::Vector = [nothing], b::Bool = true, k::Dict = Dict();
                                data::Vector = x,complementary::Bool = b, kwargs::Dict = k)
        x::Vector, y::Vector = RCDF(data = data, complementary = complementary)
        plot!(x, y; kwargs)
    end

    function ECDFPlot(x::Vector = [nothing], b::Bool = true, k::Dict = Dict();
                        data::Vector = x, complementary::Bool = b, kwargs::Dict = k)
        x::Vector, y::Vector = ECDF(data = data, complementary = complementary)
        return plot(x, y; kwargs)
    end

    function ECDFPlot!(x::Vector = [nothing], b::Bool = true, k::Dict = Dict();
                        data::Vector=x, complementary::Bool = b, kwargs::Dict = k)
        x::Vector, y::Vector = ECDF(data = data, complementary = complementary)
        plot!(x, y; kwargs)
    end
end

max_stars_repo_name: yukki-jpn/JuliaTSA

max_issues_repo_name: yukki-jpn/JuliaTSA

max_forks_repo_name: yukki-jpn/JuliaTSA


text:
export ordered_pmap

function ordered_pmap(pool::WorkerPool, f, list)

    pids = pool.workers
    np = length(pids)
    n = length(list)
    results = Vector{Any}(undef,n)
    i = 1
    nextidx() = (idx=i; i+=1; idx)
    @sync begin
        for p in pids
            if p != myid() || np == 1
                @async begin
                    while true
                        idx = nextidx()
                        if idx > n
                            break
                        end
                        results[idx] = remotecall_fetch(f, p, list[idx])
                    end
                end
            end
        end
    end
    return results
end

ordered_pmap(f, c1,) = ordered_pmap(default_worker_pool(), f, c1)
ordered_pmap(f, c1, c...) = ordered_pmap(default_worker_pool(), a->f(a...), zip(c1,c))
ordered_pmap(p::WorkerPool, f, c1, c...) = ordered_pmap(p, a->f(a...),zip(c1,c))


text:
"""
`movefiles(flist::Vector, newdir::AbstractString)` move all items in `flist`to the `newdir` directory, preseving their original names.
"""
function movefiles(flist::Vector, newdir::AbstractString)
    for item in flist
        newpath = joinpath(newdir, basename(item))
        mv(item, newpath)
    end
end


text:
mutable struct LinearGlobalFunctionApproximator{W <: AbstractArray} <: GlobalFunctionApproximator
    weights::W
end

function fit!(lgfa::LinearGlobalFunctionApproximator, dataset_input::AbstractMatrix{T},
              dataset_output::AbstractArray{T}) where T
    # TODO: Since we are ASSIGNING to weights here, does templating even matter? Does the struct even matter?
    lgfa.weights = llsq(dataset_input, dataset_output, bias=false)
end

function compute_value(lgfa::LinearGlobalFunctionApproximator, v::AbstractArray{T}) where T
    return dot(lgfa.weights, v)
end


text:
# TODO: Temporary until this is turned into a package
using Pkg: Pkg

# https://github.com/JuliaLang/julia/pull/33128
if VERSION < v"1.4.0-DEV.397"
    function pkgdir(m::Module)
        rootmodule = Base.moduleroot(m)
        path = pathof(rootmodule)
        path === nothing && return nothing
        return dirname(dirname(path))
    end
end

"""
    @__VERSION__ -> Union{VersionNumber, Nothing}

Get the `VersionNumber` of the package which expands this macro. If executed outside of a
package `nothing` will be returned.
"""
macro __VERSION__()
    pkg_dir = pkgdir(__module__)

    if pkg_dir !== nothing
        project_data = Pkg.TOML.parsefile(Pkg.Types.projectfile_path(pkg_dir))
        return VersionNumber(project_data["version"])
    else
        return nothing
    end
end


text:
const output = IOBuffer()

if julia07
    using REPL
    const Void = Nothing
else
    const REPL = Base.REPL
end

const out_terminal = REPL.Terminals.TerminalBuffer(output)

const basic_repl = REPL.BasicREPL(out_terminal)

const basic_display = REPL.REPLDisplay(basic_repl)

## Base.pushdisplay(basic_display)

mutable struct DisplayManager <: Display
    repl_display :: REPL.REPLDisplay
    location :: Int64
end

DisplayManager(repl_display :: REPL.REPLDisplay) = DisplayManager(repl_display, 0)

function Rprint(s) ccall((:Rprintf,RCall.libR),Void,(Ptr{Cchar},), s) end

function proceed(dm :: DisplayManager)
    if dm.location < dm.repl_display.repl.terminal.out_stream.ptr-1
        Rprint(readstring(seek(dm.repl_display.repl.terminal.out_stream, dm.location)))
        dm.location = dm.repl_display.repl.terminal.out_stream.ptr-1
        Rprint("  \n")
    end
end

function display(dm :: DisplayManager, mime::MIME"text/plain", x)
    display(dm.repl_display, mime, x)
    proceed(dm)
    nothing
end

display(dm :: DisplayManager, x) = display(dm, MIME("text/plain"), x)

const basic_display_manager = DisplayManager(basic_display)

Base.pushdisplay(basic_display_manager)

max_stars_repo_name: pthariensflame/JuliaCall

max_issues_repo_name: tinagui/JuliaCall

max_forks_repo_name: tinagui/JuliaCall


text:
struct All <: Indices end

struct Cells <: Indices
    inds::Vector{<:CartesianIndex}
end

Cells(inds::Tuple{Int, Int}...) = Cells([CartesianIndex.(inds)...])

struct Rows <: Indices
    inds::Vector{<:Int}
end

Rows(ind::Int) = Rows([ind])
Rows(inds::Int...) = Rows([inds...])

struct Cols <: Indices
    inds::Vector{<:Int}
end

Cols(ind::Int) = Cols([ind])
Cols(inds::Int...) = Cols([inds...])

function setstyle!(c::Cell, args::LatexStyle...)
    for arg in args
        setstyle!(c.style, arg)
    end
end

function setstyle!(d::Dict{Symbol,LatexStyle}, s::LatexStyle)
    d[Symbol(lowercase(string(typeof(s))))] = s
end

function setstyle!(M::CellArray, args::LatexStyle...)
    for cell in M
        setstyle!(cell, args...)
    end
end

setstyle!(M::CellMatrix, r::All, args::LatexStyle...) = setstyle!(M, args...)
setstyle!(M::CellMatrix, r::Cells, args::LatexStyle...) = @views setstyle!(M[r.inds], args...)
setstyle!(M::CellMatrix, r::Rows, args::LatexStyle...) = @views setstyle!(M[r.inds, :], args...)
setstyle!(M::CellMatrix, r::Cols, args::LatexStyle...) = @views setstyle!(M[:, r.inds], args...)

function make_tex_file(file_name::String, s::String; compile=false, dir_name = pwd())

    full_name = joinpath(dir_name, file_name)

    mkpath(dir_name)

    f = open(full_name, "w")

    write(f, "\\documentclass{article}\n\n")
    write(f, "\\usepackage{xcolor}\n")
    write(f, "\\usepackage{colortbl}\n")
    write(f, "\\usepackage{booktabs}\n\n")
    write(f, "\\begin{document}\n\n")
    write(f, s)
    write(f, "\n")
    write(f, "\\end{document}\n")

    close(f)

    compile && run(`pdflatex -quiet -output-directory $dir_name $full_name`)

    return nothing
end


text:
using DFWannier
using Optim

function change_lsoc(model,indices,lambda)
  for wfc in model.wfcs[indices[1] : indices[2]]
    wfc.atom = PhysAtom(wfc.atom.center,lambda)
  end
end

function optimize_l()
  T = Float64

  cell_param = 4.3392*T[ 0.8424444 -0.4863855 -3.7e-8;-1.5e-8 0.972771 6.0e-9;-5.7e-8 6.0e-9 1.5226926]
  atom_pos   = [cell_param*[1/3 ,2/3, 0.3194],cell_param*[2/3,1/3,0.7363],cell_param*[0.0,0.0,0.0]]
  atoms = [[PhysAtom(Point3D(atom_pos[1]),0.0) for i=1:4];[PhysAtom(Point3D(atom_pos[2]),-0.8) for i=1:4];[PhysAtom(Point3D(atom_pos[3]),-1.0) for i=1:4]]
  x = WannierModel{T}("/home/ponet/Documents/PhD/BiTeI/NSOC/","/home/ponet/Documents/PhD/BiTeI/NSOC/2BiTeI_bands.out",atoms);

  dfbands = read_qe_bands_file("/home/ponet/Documents/PhD/BiTeI/SOC/2BiTeI_bands.out",T)[21:44]

  lambda1_s = -0.462138
  lambda2_s = 0.355636
  lambda3_s = -0.768408
  function f(lambdas)
    change_lsoc(x,[1,4],lambdas[1])
    change_lsoc(x,[5,8],lambdas[2])
    change_lsoc(x,[9,12],lambdas[3])
    tbbands = calculate_eig_soc_bloch(x)
    out_diff = 0.0
    for i=1:length(tbbands)
      for (calc,exact) in zip(tbbands[i].eigvals[80:120],dfbands[i].eigvals[80:120])
        out_diff += abs(calc-exact)
      end
    end
    return out_diff
  end
  return optimize(f,[lambda1_s,lambda2_s,lambda3_s],show_trace = true,show_every = 1,extended_trace=true)
end
results = optimize_l()
println(results)


text:
Pkg.add("Gadfly")
Pkg.add("Cairo")
using Gadfly
using Cairo

t = [1.1, 1.9, 3.3, 4.0]
x = [1, 2, 3, 4]

lambda = 0.01
#=
	model => y = w0 + w1x = w' x, where x0 = 1

	Cost function = Sum (t_n - y_n)^2 = (t_n - w0 - w1 x_n)^2

	Derivation of Cost function:

	d(Cost function) / d w0 = -2 (t - w0 - w1 x)
	d(Cost function) / d w1 = -2x (t - w0 - w1 x)

	We'll use gradient descent to learn the parameters:

	w0 = w0 - sum(lambda x d(Cost function) / d w0)
	w1 = w1 - sum(lambda x d(Cost function) / d w1)

	Here the sum is over all the data

	Repeat those iterations with respect to the input until w0 and w1 don't change anymore
=#

# initial values of the bias
# dimension is (2, )
w = [1.0, 1.0]

# transform x to add the bias point
# x_bias will become: [1.0  1
#					   1.0  2] etc
# dimension is (4, 2)
x_bias = [ones(length(x)) x]

for i = 1:10000
	y = x_bias * w
	w[1] = w[1] - lambda * sum( -2 * (t - y))
	w[2] = w[2] - lambda * sum( -2 * x' * (t - y))
end

println(w)
my_plot = plot(layer(x=x, y=t, Geom.point), layer(x=x, y=x_bias * w, Geom.line))
draw(PNG("myplot.png", 6inch, 3inch), my_plot)


text:
@testset "Test constrained NLP vector score" begin
  ###############################################################################
  #
  # The Stopping structure eases the implementation of algorithms and the
  # stopping criterion.
  # We illustrate here the basic features of Stopping.
  #
  # -> the case where the score is a Vector and not a Number.
  # a) tol_check is a Number;
  # b) tol_check is a Vector of the same size.
  # Note that if tol_check is a Vector and the score is a Number, only
  # the smallest value of tol_check is considered.
  #
  #Warning: see https://github.com/JuliaSmoothOptimizers/NLPModels.jl/blob/master/src/autodiff_model.jl
  #for the proper way of defining an ADNLPModel
  #
  ###############################################################################

  #We consider a regularized MPCC problem:
  x0 = ones(2)
  t = 1.0
  c(x) = [(x[1] - t) .* (x[2] - t)]
  meta = NLPModelMeta(
    2,
    x0 = x0,
    lvar = zeros(2),
    uvar = Inf * ones(2),
    ncon = 1,
    y0 = zeros(1),
    lcon = -Inf * ones(1),
    ucon = zeros(1),
  )
  f = x -> x[1] + x[2]
  nlp = ADNLPModel(meta, Counters(), ADNLPModels.ForwardDiffAD(1, 1, f, x0), f, c)

  #We consider a vectorized optimality_check KKT function:
  function KKTvect(pb::AbstractNLPModel, state::NLPAtX; kwargs...)

    #Check the gradient of the Lagrangian
    gLagx = Stopping._grad_lagrangian(pb, state)
    #Check the complementarity condition for the bounds
    dual_res_bounds = Stopping._sign_multipliers_bounds(pb, state)
    #Check the complementarity condition for the constraints
    res_nonlin = Stopping._sign_multipliers_nonlin(pb, state)
    #Check the feasibility
    feas = Stopping._feasibility(pb, state)

    res = vcat(gLagx, feas, dual_res_bounds, res_nonlin)

    return res
  end

  #One solution is [1.0, 0.0] while [1. + 1e-7, 0] is an approximate solution.
  sol = [1.0, 0.0]
  esol = [1.0 + 1e-7, 0.0]

  #As usual, we initialize the State and the Stopping
  nlp_at_x_c = NLPAtX(x0, NaN * ones(nlp.meta.ncon), Array{Float64, 1}(undef, 14))
  stop_nlp = NLPStopping(nlp, nlp_at_x_c, optimality_check = KKTvect)
  fill_in!(stop_nlp, x0)
  OK = stop!(stop_nlp)
  @test !OK #the initial guess (1.0, 1.0) is not a solution
  reinit!(stop_nlp, rstate = true) #reinitialize the Stopping and the State
  fill_in!(stop_nlp, sol)
  OK = stop!(stop_nlp)
  @test OK #sol is a solution
  reinit!(stop_nlp, rstate = true)
  fill_in!(stop_nlp, esol)
  OK = stop!(stop_nlp)
  @test OK #esol is also an (approximate) solution.
  #KKTvect(stop_nlp.pb, stop_nlp.current_state)

  #Our aim is to verify that a solution satisfies the strong epsilon-stationarity
  #condition, i.e. the feasibility and the complementarity condition have to be
  #satisfied exactly.
  tol_check1(atol, rtol, opt0) = vcat(max(atol, rtol * opt0) .* ones(6), zeros(8))

  stop_nlp = NLPStopping(nlp, nlp_at_x_c, optimality_check = KKTvect, tol_check = tol_check1)
  fill_in!(stop_nlp, esol)
  OK = stop!(stop_nlp)
  @test !OK #esol is not a solution in this case as it satisfies the feasibility approximately
  reinit!(stop_nlp, rstate = true) #reinitialize the Stopping and the State
  fill_in!(stop_nlp, sol)
  OK = stop!(stop_nlp)
  @test OK #However, sol is a solution.

  #We can also use an asymetric test on the optimality condition using tol_check_neg
  #by default tol_check_neg = - tol_check
  tol_check1_neg(atol, rtol, opt0) = -1e-3 * ones(14)
  stop_nlp = NLPStopping(
    nlp,
    nlp_at_x_c,
    optimality_check = KKTvect,
    tol_check = tol_check1,
    tol_check_neg = tol_check1_neg,
  )
  fill_in!(stop_nlp, sol)
  OK = stop!(stop_nlp)
  @test OK

  #An error is returned if size(KKT) is different from size(tol_check).
  try
    stop_nlp2 = NLPStopping(nlp, nlp_at_x_c, optimality_check = KKT, tol_check = tol_check1)
    fill_in!(stop_nlp2, esol)
    stop!(stop_nlp2)
    @test false
  catch
    @test true
  end
end


text:
using MPI, Knet, ParticleSwarmOptimization
include("Args.jl")

function main()
    MPI.Init()
    args = parse_commandline()
    gpu(args["gpu"])
    comm = MPI.COMM_WORLD
    rank = MPI.Comm_rank(comm)
    world = MPI.Comm_size(comm)

    if rank == 0
        println("Parsed args:")

        for (arg,val) in args
            println("  $arg  =>  $val")
        end
    end

    x = [0.0 0.0 1.0 1.1; 0.0 1.0 0.0 1.1]
    y = [0.0 1.0 1.0 0.0]

    @knet function mlp(x; winit=Gaussian(0,.1))
        h1 = wbf(x; out=100, f=:sigm, winit=winit)
        h2 = wbf(h1; out=100, f=:sigm, winit=winit)
        return wbf(h2; out=1, f=:sigm, winit=winit)
    end

    problem = NNProblem(:mlp, args["l"], args["h"], Single(x, y), quadloss)

    #last parameter for the parallelization
    gbest = pso(problem, args["num"], args["epoch"], args["phi1"], args["phi2"], args["w"], args["vmin"], args["vmax"], true)

    if rank == 0
        println("\nBest: $(gbest.pbest_fitness)\n")
        println("Gold: $(y)")
        println("Pred: $(forw(gbest.x, x))")
    end

    MPI.Finalize()
end

main()


text:
"""
```
Li2020{T} <: AbstractNLCTFPModel{T}
```

The `Li2020` type defines the structure of the model in Li, Wenhao (2020), "Public Liquidity and Financial Crises."

### Fields

#### Parameters
* `parameters::Vector{AbstractParameter}`: Vector of all time-invariant model
  parameters.

* `keys::OrderedDict{Symbol,Int}`: Maps human-readable names for all model
  parameters to their indices in `parameters`.

#### Inputs to Measurement and Equilibrium Functional Equations

The following fields are dictionaries that map human-readable names to indices.

* `state_variables::OrderedDict{Symbol,Int}`: Maps each state variable to its dimension on a Cartesian grid

* `endogenous_variables::OrderedDict{Symbol,Int}`: Maps endogenous variables
    calculated during the solution of functional equations to an index

* `exogenous_shocks::OrderedDict{Symbol,Int}`: Maps each shock to a column in
  the measurement equation

* `observables::OrderedDict{Symbol,Int}`: Maps each observable to a row in the
  model's measurement equation matrices.

* `pseudo_observables::OrderedDict{Symbol,Int}`: Maps each pseudo-observable to
  a row in the model's pseudo-measurement equation matrices.

#### Model Specifications and Settings

* `spec::String`: The model specification identifier, \"an_schorfheide\", cached
  here for filepath computation.

* `subspec::String`: The model subspecification number, indicating that some
  parameters from the original model spec (\"ss0\") are initialized
  differently. Cached here for filepath computation.

* `settings::Dict{Symbol,Setting}`: Settings/flags that affect computation
  without changing the economic or mathematical setup of the model.

* `test_settings::Dict{Symbol,Setting}`: Settings/flags for testing mode

#### Other Fields

* `rng::MersenneTwister`: Random number generator. Can be is seeded to ensure
  reproducibility in algorithms that involve randomness (such as
  Metropolis-Hastings).

* `testing::Bool`: Indicates whether the model is in testing mode. If `true`,
  settings from `m.test_settings` are used in place of those in `m.settings`.

* `observable_mappings::OrderedDict{Symbol,Observable}`: A dictionary that
  stores data sources, series mnemonics, and transformations to/from model units.
  DSGE.jl will fetch data from the Federal Reserve Bank of
  St. Louis's FRED database; all other data must be downloaded by the
  user. See `load_data` and `Observable` for further details.

* `pseudo_observable_mappings::OrderedDict{Symbol,PseudoObservable}`: A
  dictionary that stores names and transformations to/from model units. See
  `PseudoObservable` for further details.
"""
mutable struct Li2020{T} <: AbstractNLCTFPModel{T}
    parameters::ParameterVector{T}                         # vector of all time-invariant model parameters
    keys::OrderedDict{Symbol,Int}                          # human-readable names for all the model
                                                           # parameters and steady-states
    state_variables::OrderedDict{Symbol,Int}               # dimension number of state variable

    functional_variables::OrderedDict{Symbol,Int}
    derivatives::OrderedDict{Symbol,Int}
    endogenous_variables::OrderedDict{Symbol,Int}
    exogenous_shocks::OrderedDict{Symbol,Int}
    observables::OrderedDict{Symbol,Int}
    pseudo_observables::OrderedDict{Symbol,Int}

    spec::String                                           # Model specification number (eg "m990")
    subspec::String                                        # Model subspecification (eg "ss0")
    settings::Dict{Symbol,Setting}                         # Settings/flags for computation
    test_settings::Dict{Symbol,Setting}                    # Settings/flags for testing mode
    rng::MersenneTwister                                   # Random number generator
    testing::Bool                                          # Whether we are in testing mode or not

    observable_mappings::OrderedDict{Symbol, Observable}
    pseudo_observable_mappings::OrderedDict{Symbol, PseudoObservable}
end

description(m::Li2020) = "Julia implementation of model defined in 'Public Liquidity and Financial Crises' (2020) by Wenhao Li: Li2020, $(m.subspec)"

"""
`init_model_indices!(m::Li2020)`

Arguments:
`m:: Li2020`: a model object

Description:
Initializes indices for all of `m`'s states, shocks, and observables.
"""
function init_model_indices!(m::Li2020)
    # State_Variables
    state_variables = collect([:w])

    # Exogenous shocks
    exogenous_shocks = collect([:K_sh, :N_sh]) # capital shock K, liquidity shock N

    # Variables for functional equations
    functional_variables = collect([:p, :Q̂, :xg])

    # Derivatives of variables
    init_derivatives!(m, Dict{Symbol, Vector{Int}}(:p => standard_derivs(1)), state_variables)
    derivatives = keys(get_derivatives(m))

    # Endogenous variables
    endogenous_variables = collect([:ψ, :xK, :yK, :yg, :σp, :σ, :σh, :σw, :μR_rd, :rd_rg, :rd_rg_H, :μb_μh, :μw, :μp, :μK, :μR, :rd, :rg, :rd_rf,
                                    :μb, :μh, :invst, :lvg, :κp, :κb, :κd, :κh, :κfs, :firesale_jump, :κw, :liq_prem, :bank_liq_frac,
                                    :δ_x, :indic, :rf, :rh, :K_growth, :κK])

    # Observables
    observables = keys(m.observable_mappings)

    # Pseudo-observables
    pseudo_observables = keys(m.pseudo_observable_mappings)

    for (i,k) in enumerate(state_variables);        m.state_variables[k]      = i end
    for (i,k) in enumerate(exogenous_shocks);       m.exogenous_shocks[k]     = i end
    for (i,k) in enumerate(endogenous_variables);   m.endogenous_variables[k] = i end
    for (i,k) in enumerate(functional_variables);   m.functional_variables[k] = i end
    for (i,k) in enumerate(derivatives);            m.derivatives[k]          = i end
    for (i,k) in enumerate(observables);            m.observables[k]          = i end
    for (i,k) in enumerate(pseudo_observables);     m.pseudo_observables[k]   = i end
end

function Li2020(subspec::String = "ss0";
                custom_settings::Dict{Symbol, Setting} = Dict{Symbol, Setting}(),
                testing = false)

    # Model-specific specifications
    spec               = split(basename(@__FILE__),'.')[1]
    subspec            = subspec
    settings           = Dict{Symbol,Setting}()
    test_settings      = Dict{Symbol,Setting}()
    rng                = MersenneTwister(0)

    # initialize empty model
    m = Li2020{Float64}(
            # model parameters and steady state values
            Vector{AbstractParameter{Float64}}(), OrderedDict{Symbol,Int}(),

            # model indices
            OrderedDict{Symbol,Int}(), OrderedDict{Symbol,Int}(), OrderedDict{Symbol,Int}(), OrderedDict{Symbol,Int}(),
            OrderedDict{Symbol,Int}(), OrderedDict{Symbol,Int}(), OrderedDict{Symbol,Int}(),

            spec,
            subspec,
            settings,
            test_settings,
            rng,
            testing,
            OrderedDict{Symbol,Observable}(),
            OrderedDict{Symbol,PseudoObservable}())

    # Set settings
    model_settings!(m)

    # default_test_settings!(m)
    for custom_setting in values(custom_settings)
        m <= custom_setting
    end

    # Set observable and pseudo-observable transformations
    # init_observable_mappings!(m)
    # init_pseudo_observable_mappings!(m)

    # Initialize parameters
    init_parameters!(m)

    init_model_indices!(m)
    init_subspec!(m)

    return m
end

"""
```
init_parameters!(m::Li2020)
```
Initializes the model's parameters.
"""
function init_parameters!(m::Li2020)
    # Productivity
    m <= parameter(:AH, 0.15, (0., Inf), (0., 1e3), ModelConstructors.Untransformed(),
                   Uniform(0., 1e3), fixed = false, description = "Banker's productivity")
    m <= parameter(:AL, 0.125, (0., Inf), (0., 1e3), ModelConstructors.Untransformed(), Uniform(0., 1e3),
                   fixed = false, description = "Household's productivity")

    # Bank run and fire sales
    m <= parameter(:λ, 0.025, (0., 1.), (0., 1.), ModelConstructors.Untransformed(), Uniform(0., 1.),
                   fixed = false, description = "Probability of liquidity shock")
    m <= parameter(:β, 0.25, (0., 1.), (0., 1.), ModelConstructors.Untransformed(), Uniform(0., 1.), fixed = false,
                   description = "Probability of running on a deposit account")
    m <= parameter(:α, 0.21, (0., 1.), (0., 1.), ModelConstructors.Untransformed(), Uniform(0., 1.), fixed = false,
                   description = "Illiquidity discount on capital during fire sale")
    m <= parameter(:ϵ, 1e-3, (0., 1.), (0., 1.), ModelConstructors.Untransformed(), Uniform(0., 1.), fixed = false,
                   description = "Fraction of remaining wealth for bankers after bankruptcy")
    m <= parameter(:θ, 1e-5, (0., 1.), (0., 1.), ModelConstructors.Untransformed(), Uniform(0., 1.), fixed = false,
                   description = "Probability of non-zero exposure to liquidity shock")

    # Shadow value of liquidity
    m <= parameter(:π, 0.19, (0., 1.), (0., 1.), ModelConstructors.Untransformed(), Uniform(0., 1.), fixed = false,
                   description = "Illiquidity discount on illiquid safe asset")

    # Macro parameters
    m <= parameter(:δ, 0.1, (0., 1.), (0., 1.), ModelConstructors.Untransformed(), Uniform(0., 1.),
                   fixed = false, description = "Depreciation rate of capital")
    m <= parameter(:ρ, 0.04, (0., Inf), (0., 1e3), ModelConstructors.Untransformed(), Uniform(0., 1e3),
                   fixed = false, description = "Discount rate")
    m <= parameter(:σK, 0.033, (0., Inf), (0., 1e3), ModelConstructors.Untransformed(), Uniform(0., 1e3), fixed = false,
                   description = "Volatility of capital shocks")
    m <= parameter(:χ, 3., (0., Inf), (0., 1e3), ModelConstructors.Untransformed(), Uniform(0., 1e3), fixed = false,
                   description = "Adjustment cost of internal investment function")

    # Stationary distribution
    m <= parameter(:η, 0.05, (0., 1.), (0., 1.), ModelConstructors.Untransformed(), Uniform(0., 1.), fixed = false,
                   description = "Rate of retirement for bankers")
end

"""
```
model_settings!(m::Li2020)
```
creates the model's settings.
"""
function model_settings!(m::Li2020)

    # Investment functions
    m <= Setting(:Φ, quadratic_investment, "Internal investment function")
    m <= Setting(:μK, growth_quadratic_investment, "Rate of capital growth")
    m <= Setting(:∂Φ, derivative_quadratic_investment_li2020, "Derivative of internal investment function")

    # Numerical settings for grid
    m <= Setting(:N, 100, "Grid size")
    m <= Setting(:stategrid_method, :exponential, "Type of grid to construct for state variables")
    m <= Setting(:stategrid_dimensions, OrderedDict{Symbol, Tuple{Float64, Float64, Int}}(:w => (1e-3, 1., get_setting(m, :N))),
                 "Information about the dimensions of the state space")
    m <= Setting(:stategrid_splice, 0.2, "Li (2020) constructs the grid in two parts. This value is where the first half stops.")

    # Numerical settings for no jump equilibrium
    m <= Setting(:boundary_conditions, OrderedDict{Symbol, Vector{Float64}}(:p => [0.; 0.]),
                 "Boundary conditions for differential equations.")
    m <= Setting(:ode_reltol, 1e-4, "Relative tolerance for ODE integration")
    m <= Setting(:ode_abstol, 1e-12, "Absolute tolerance for ODE integration")
    m <= Setting(:essentially_one, 0.999,
                "If ψ is larger than this value, then we consider it essentially one for some numerical purposes.")
    m <= Setting(:ode_integrator, DP5(), "Numerical ODE integrator for no-jump solution") # DP5 is Matlab's ode45

    # Numerical settings for functional iteration
    m <= Setting(:tol, 1e-4, "Tolerance for functional iteration")
    m <= Setting(:learning_rate, 0.4, "Learning rate for the update of functional variables after each loop")
    m <= Setting(:max_iter, 40, "Maximum number of loops during functional iteration")
    m <= Setting(:error_method, :total_error, "Method for calculating error at the end of each loop during functional iteration")
    m <= Setting(:v₀, 3e-8, "Parameter for damping function")
    m <= Setting(:damping_function, x -> get_setting(m, :v₀) ./ x, "Dampling function to avoid corners")
    m <= Setting(:p₀_perturb, 1e-14, "Perturbation of boundary condition for q at w = 0")
    m <= Setting(:κp_grid, Vector{Float64}(undef, 0),
                 "Vector of guesses for κp used during iteration for new κp and xK within each functional loop")
    m <= Setting(:p_interpolant, Gridded(Linear()), "Interpolant method for fitted p.")
    m <= Setting(:xK_interpolant, Gridded(Linear()), "Interpolant method for xK after solving xK for each guess of κp.")
    m <= Setting(:xg_interpolant, Gridded(Linear()), "Interpolant method for xg after solving xK and κp.")
    m <= Setting(:κp_interpolant, Gridded(Linear()), "Interpolant method for κp after solving xK and κp.")
    m <= Setting(:Q̂_interpolant, Gridded(Linear()), "Interpolant method for Q̂.")
    m <= Setting(:inside_iteration_nlsolve_tol, 1e-6, "Tolerance for nlsolve in the inside iteration")
    m <= Setting(:inside_iteration_nlsolve_max_iter, 400, "Maximum number of iterations for nlsolve for the inside iteration")
    m <= Setting(:xg_tol, 2e-3, "Lower but permissible tolerance for xg fixed point in the inside iteration")
    m <= Setting(:yg_tol, 1e-5, "Lowest permissible value for yg")
    m <= Setting(:p_tol, 1e-8, "Tolerance when calculating p after completing an inside iteration")
    m <= Setting(:firesale_bound, 0.99, "Upper bound for size of firesale jumps that do not wipe out a banker's net worth")
    m <= Setting(:firesale_interpolant, Gridded(Linear()), "Interpolant method for the firesale value.")
    m <= Setting(:N_GH, 10, "Number of nodes for Gauss-Hermite quadrature.")
    m <= Setting(:Q̂_tol, 1e-5, "Tolerance for approximation of Q̂ via Gauss-Hermite quadrature")
    m <= Setting(:Q̂_max_it, 1000, "Maximum number of iterations for approximation of Q̂.")
    m <= Setting(:dt, 1. / 12., "Simulation interval for Q̂ approximation as a fraction of a 1 year")

    # Other settings for initialization
    m <= Setting(:nojump_parameters, [:ρ, :AH, :AL, :σK, :χ, :δ, :η], "Keys of parameters used when solving the no-jump equilibrium.")

    # Calibration targets
    m <= Setting(:avg_gdp, 0.145, "Average GDP")
    m <= Setting(:liq_gdp_ratio, 0.39, "Average Liquidity/GDP ratio in the data")
    m <= Setting(:gov_bond_gdp_level, 0.3, "Ratio of Government Bonds to GDP")
end


text:
module FixtureMacroTests

using Fixtures
using FactCheck

@fixture shorthand_beginend0a() = global state = "shorthand_beginend0a"
@fixture shorthand_beginend0b() = begin
  global state = "shorthand_beginend0b"
end
@fixture shorthand_beginend0c() = begin
  global state = "shorthand_beginend0c"
  yield_fixture()
end
@fixture shorthand_beginend0d() = begin
  global state = "shorthand_beginend0d"
  yield_fixture()
  global state = ""
end
@fixture (shorthand_beginend0e)() = begin
  global state = "shorthand_beginend0e"
  yield_fixture()
  global state = ""
end

@fixture shorthand_beginend1a(x) = global state = "shorthand_beginend1a_$x"
@fixture shorthand_beginend1b(x) = begin
  global state = "shorthand_beginend1b_$x"
end
@fixture shorthand_beginend1c(x) = begin
  global state = "shorthand_beginend1c_$x"
  yield_fixture()
end
@fixture shorthand_beginend1d(x) = begin
  global state = "shorthand_beginend1d_$x"
  yield_fixture()
  global state = ""
end
@fixture shorthand_beginend1e(x::Integer) = begin
  global state = "shorthand_beginend1e_$x"
  yield_fixture()
  global state = ""
end
@fixture shorthand_beginend1f{T}(x::T) = begin
  global state = "shorthand_beginend1f_$x"
  yield_fixture()
  global state = ""
end

@fixture shorthand_beginend2a(x, y) = global state = "shorthand_beginend2a_$(x)_$(y)"
@fixture shorthand_beginend2b(x, y) = begin
  global state = "shorthand_beginend2b_$(x)_$(y)"
end
@fixture shorthand_beginend2c(x, y) = begin
  global state = "shorthand_beginend2c_$(x)_$(y)"
  yield_fixture()
end
@fixture shorthand_beginend2d(x, y) = begin
  global state = "shorthand_beginend2d_$(x)_$(y)"
  yield_fixture()
  global state = ""
end
@fixture shorthand_beginend2e(x::Integer, y::Integer) = begin
  global state = "shorthand_beginend2e_$(x)_$(y)"
  yield_fixture()
  global state = ""
end
@fixture shorthand_beginend2f{T1, T2}(x::T1, y::T2) = begin
  global state = "shorthand_beginend2f_$(x)_$(y)"
  yield_fixture()
  global state = ""
end

@fixture shorthand_brackets0a() = global state = "shorthand_brackets0a"
@fixture shorthand_brackets0b() = (
  global state = "shorthand_brackets0b";
)
@fixture shorthand_brackets0c() = (
  global state = "shorthand_brackets0c";
  yield_fixture()
)
@fixture shorthand_brackets0d() = (
  global state = "shorthand_brackets0d";
  yield_fixture();
  global state = ""
)

@fixture shorthand_brackets1a(x) = global state = "shorthand_brackets1a_$x"
@fixture shorthand_brackets1b(x) = (
  global state = "shorthand_brackets1b_$x";
)
@fixture shorthand_brackets1c(x) = (
  global state = "shorthand_brackets1c_$x";
  yield_fixture()
)
@fixture shorthand_brackets1d(x) = (
  global state = "shorthand_brackets1d_$x";
  yield_fixture();
  global state = ""
)
@fixture shorthand_brackets1e(x::Integer) = (
  global state = "shorthand_brackets1e_$x";
  yield_fixture();
  global state = ""
)

@fixture shorthand_brackets2a(x, y) = global state = "shorthand_brackets2a_$(x)_$(y)"
@fixture shorthand_brackets2b(x, y) = (
  global state = "shorthand_brackets2b_$(x)_$(y)";
)
@fixture shorthand_brackets2c(x, y) = (
  global state = "shorthand_brackets2c_$(x)_$(y)";
  yield_fixture()
)
@fixture shorthand_brackets2d(x, y) = (
  global state = "shorthand_brackets2d_$(x)_$(y)";
  yield_fixture();
  global state = ""
)
@fixture shorthand_brackets2e(x::Integer, y::Integer) = (
  global state = "shorthand_brackets2e_$(x)_$(y)";
  yield_fixture();
  global state = ""
)

function0a = @fixture function()
  global state = "function0a"
end
function0b = @fixture function()
  global state = "function0b"
  yield_fixture()
end
function0c = @fixture function()
  global state = "function0c"
  yield_fixture()
  global state = ""
end

function1a = @fixture function(x)
  global state = "function1a_$x"
end
function1b = @fixture function(x)
  global state = "function1b_$x"
  yield_fixture()
end
function1c = @fixture function(x)
  global state = "function1c_$x"
  yield_fixture()
  global state = ""
end
function1d = @fixture function(x::Integer)
  global state = "function1d_$x"
  yield_fixture()
  global state = ""
end

function2a = @fixture function(x, y)
  global state = "function2a_$(x)_$(y)"
end
function2b = @fixture function(x, y)
  global state = "function2b_$(x)_$(y)"
  yield_fixture()
end
function2c = @fixture function(x, y)
  global state = "function2c_$(x)_$(y)"
  yield_fixture()
  global state = ""
end
function2d = @fixture function(x::Integer, y::Integer)
  global state = "function2d_$(x)_$(y)"
  yield_fixture()
  global state = ""
end

@fixture function method0a()
  global state = "method0a"
end
@fixture function method0b()
  global state = "method0b"
  yield_fixture()
end
@fixture function method0c()
  global state = "method0c"
  yield_fixture()
  global state = ""
end
@fixture function (method0d)()
  global state = "method0d"
  yield_fixture()
  global state = ""
end

@fixture function method1a(x)
  global state = "method1a_$x"
end
@fixture function method1b(x)
  global state = "method1b_$x"
  yield_fixture()
end
@fixture function method1c(x)
  global state = "method1c_$x"
  yield_fixture()
  global state = ""
end
@fixture function method1d(x::Integer)
  global state = "method1d_$x"
  yield_fixture()
  global state = ""
end
@fixture function method1e{T}(x::T)
  global state = "method1e_$x"
  yield_fixture()
  global state = ""
end

@fixture function method2a(x, y)
  global state = "method2a_$(x)_$(y)"
end
@fixture function method2b(x, y)
  global state = "method2b_$(x)_$(y)"
  yield_fixture()
end
@fixture function method2c(x, y)
  global state = "method2c_$(x)_$(y)"
  yield_fixture()
  global state = ""
end
@fixture function method2d(x::Integer, y::Integer)
  global state = "method2d_$(x)_$(y)"
  yield_fixture()
  global state = ""
end
@fixture function method2e{T1, T2}(x::T1, y::T2)
  global state = "method2e_$(x)_$(y)"
  yield_fixture()
  global state = ""
end

lambda_beginend0a = @fixture () -> global state = "lambda_beginend0a"
lambda_beginend0b = @fixture () -> begin
  global state = "lambda_beginend0b"
end
lambda_beginend0c = @fixture () -> begin
  global state = "lambda_beginend0c"
  yield_fixture()
end
lambda_beginend0d = @fixture () -> begin
  global state = "lambda_beginend0d"
  yield_fixture()
  global state = ""
end

lambda_beginend1a = @fixture (x) -> global state = "lambda_beginend1a_$x"
lambda_beginend1b = @fixture (x) -> begin
  global state = "lambda_beginend1b_$x"
end
lambda_beginend1c = @fixture (x) -> begin
  global state = "lambda_beginend1c_$x"
  yield_fixture()
end
lambda_beginend1d = @fixture (x) -> begin
  global state = "lambda_beginend1d_$x"
  yield_fixture()
  global state = ""
end
lambda_beginend1e = @fixture (x::Integer) -> begin
  global state = "lambda_beginend1e_$x"
  yield_fixture()
  global state = ""
end

lambda_beginend2a = @fixture (x, y) -> global state = "lambda_beginend2a_$(x)_$(y)"
lambda_beginend2b = @fixture (x, y) -> begin
  global state = "lambda_beginend2b_$(x)_$(y)"
end
lambda_beginend2c = @fixture (x, y) -> begin
  global state = "lambda_beginend2c_$(x)_$(y)"
  yield_fixture()
end
lambda_beginend2d = @fixture (x, y) -> begin
  global state = "lambda_beginend2d_$(x)_$(y)"
  yield_fixture()
  global state = ""
end
lambda_beginend2e = @fixture (x::Integer, y::Integer) -> begin
  global state = "lambda_beginend2e_$(x)_$(y)"
  yield_fixture()
  global state = ""
end

lambda_brackets0a = @fixture () -> global state = "lambda_brackets0a"
lambda_brackets0b = @fixture () -> (
  global state = "lambda_brackets0b";
)
lambda_brackets0c = @fixture () -> (
  global state = "lambda_brackets0c";
  yield_fixture()
)
lambda_brackets0d = @fixture () -> (
  global state = "lambda_brackets0d";
  yield_fixture();
  global state = ""
)

lambda_brackets1a = @fixture (x) -> global state = "lambda_brackets1a_$x"
lambda_brackets1b = @fixture (x) -> (
  global state = "lambda_brackets1b_$x";
)
lambda_brackets1c = @fixture (x) -> (
  global state = "lambda_brackets1c_$x";
  yield_fixture()
)
lambda_brackets1d = @fixture (x) -> (
  global state = "lambda_brackets1d_$x";
  yield_fixture();
  global state = ""
)
lambda_brackets1e = @fixture (x::Integer) -> (
  global state = "lambda_brackets1e_$x";
  yield_fixture();
  global state = ""
)

lambda_brackets2a = @fixture (x, y) -> global state = "lambda_brackets2a_$(x)_$(y)"
lambda_brackets2b = @fixture (x, y) -> (
  global state = "lambda_brackets2b_$(x)_$(y)";
)
lambda_brackets2c = @fixture (x, y) -> (
  global state = "lambda_brackets2c_$(x)_$(y)";
  yield_fixture()
)
lambda_brackets2d = @fixture (x, y) -> (
  global state = "lambda_brackets2d_$(x)_$(y)";
  yield_fixture();
  global state = ""
)
lambda_brackets2e = @fixture (x::Integer, y::Integer) -> (
  global state = "lambda_brackets2e_$(x)_$(y)";
  yield_fixture();
  global state = ""
)

@fixture function fixture_that_produces_a_value()
  global state = "fixture_that_produces_a_value"
  yield_fixture(100)
  global state = ""
end

@fixture function fixture_that_produces_two_values()
  global state = "fixture_that_produces_two_values"
  yield_fixture(100,200)
  global state = ""
end

@fixture function method1p0d0kw(x)
  global state = "method1p0d0kw_$x"
  yield_fixture()
  global state = ""
end
@fixture function method0p1d0kw(x=10)
  global state = "method0p1d0kw_$x"
  yield_fixture()
  global state = ""
end
@fixture function method0p0d1kw(;x=10)
  global state = "method0p0d1kw_$x"
  yield_fixture()
  global state = ""
end
@fixture function method2p0d0kw(x,y)
  global state = "method2p0d0kw_$(x)_$(y)"
  yield_fixture()
  global state = ""
end
@fixture function method0p2d0kw(x=10,y=20)
  global state = "method2p0d0kw_$(x)_$(y)"
  yield_fixture()
  global state = ""
end
@fixture function method0p0d2kw(;x=10,y=20)
  global state = "method0p0d2kw_$(x)_$(y)"
  yield_fixture()
  global state = ""
end
@fixture function method1p1d1kw(x,y=10;z=20)
  global state = "method1p1d1kw_$(x)_$(y)_$z"
  yield_fixture()
  global state = ""
end
@fixture function method2p2d2kw(x1,x2,y1=10,y2=20;z1=30,z2=40)
  global state = "method2p2d2kw_$(x1)_$(x2)_$(y1)_$(y2)_$(z1)_$z2"
  yield_fixture()
  global state = ""
end
@fixture function method1p0d0kwT(x::Integer)
  global state = "method1p0d0kwT_$x"
  yield_fixture()
  global state = ""
end

@fixture function method0p1d0kwT(x::Integer=10)
  global state = "method0p1d0kwT_$x"
  yield_fixture()
  global state = ""
end
@fixture function method0p0d1kwT(;x::Integer=10)
  global state = "method0p0d1kwT_$x"
  yield_fixture()
  global state = ""
end
@fixture function method2p0d0kwT(x::Integer,y::Integer)
  global state = "method2p0d0kwT_$(x)_$(y)"
  yield_fixture()
  global state = ""
end
@fixture function method0p2d0kwT(x::Integer=10,y::Integer=20)
  global state = "method0p2d0kwT$(x)_$(y)"
  yield_fixture()
  global state = ""
end
@fixture function method0p0d2kwT(;x::Integer=10,y::Integer=20)
  global state = "method0p0d2kwT_$(x)_$(y)"
  yield_fixture()
  global state = ""
end
@fixture function method1p1d1kwT(x::Integer,y::Integer=10;z::Integer=20)
  global state = "method1p1d1kwT_$(x)_$(y)_$z"
  yield_fixture()
  global state = ""
end
@fixture function method2p2d2kwT(x1::Integer,x2::Integer,y1::Integer=10,y2::Integer=20;z1::Integer=30,z2::Integer=40)
  global state = "method2p2d2kwT_$(x1)_$(x2)_$(y1)_$(y2)_$(z1)_$z2"
  yield_fixture()
  global state = ""
end

@fixture function method_variadic_a(args...)
  global state = "method_variadic_a_$args"
  yield_fixture()
  global state = ""
end
@fixture function method_variadic_b(;args...)
  global state = "method_variadic_b_$args"
  yield_fixture()
  global state = ""
end
@fixture function method_variadic_c(args...;kwargs...)
  global state = "method_variadic_c_$(args)_$kwargs"
  yield_fixture()
  global state = ""
end
@fixture function method_variadic_d(x, args...)
  global state = "method_variadic_d_$(x)_$args"
  yield_fixture()
  global state = ""
end
@fixture function method_variadic_e(; x=10, args...)
  global state = "method_variadic_e_$(x)_$args"
  yield_fixture()
  global state = ""
end
@fixture function method_variadic_f(x, args...; y=10, kwargs...)
  global state = "method_variadic_f_$(x)_$(args)_$(y)_$kwargs"
  yield_fixture()
  global state = ""
end
@fixture function method_variadic_g(args::Integer...)
  global state = "method_variadic_g_$args"
  yield_fixture()
  global state = ""
end
@fixture function method_variadic_h(args::Integer...;kwargs...)
  global state = "method_variadic_h_$(args)_$kwargs"
  yield_fixture()
  global state = ""
end
@fixture function method_variadic_i(x::Integer, args::Integer...)
  global state = "method_variadic_i_$(x)_$args"
  yield_fixture()
  global state = ""
end
@fixture function method_variadic_j(; x::Integer=10, args...)
  global state = "method_variadic_j_$(x)_$args"
  yield_fixture()
  global state = ""
end
@fixture function method_variadic_k(x::Integer, args::Integer...; y::Integer=10, kwargs...)
  global state = "method_variadic_k_$(x)_$(args)_$(y)_$kwargs"
  yield_fixture()
  global state = ""
end

facts("@Fixture tests") do
  context("shorthand_brackets0a") do
    res = shorthand_brackets0a() do
      @fact state-->"shorthand_brackets0a"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_brackets0b") do
    res = shorthand_brackets0b() do
      @fact state-->"shorthand_brackets0b"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_brackets0c") do
    res = shorthand_brackets0c() do
      @fact state-->"shorthand_brackets0c"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_brackets0d") do
    res = shorthand_brackets0d() do
      @fact state-->"shorthand_brackets0d"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_brackets1a") do
    res = shorthand_brackets1a(100) do
      @fact state-->"shorthand_brackets1a_100"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_brackets1b") do
    res = shorthand_brackets1b(100) do
      @fact state-->"shorthand_brackets1b_100"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_brackets1c") do
    res = shorthand_brackets1c(100) do
      @fact state-->"shorthand_brackets1c_100"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_brackets1d") do
    res = shorthand_brackets1d(100) do
      @fact state-->"shorthand_brackets1d_100"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_brackets1e") do
    res = shorthand_brackets1e(100) do
      @fact state-->"shorthand_brackets1e_100"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_brackets2a") do
    res = shorthand_brackets2a(100, 200) do
      @fact state-->"shorthand_brackets2a_100_200"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_brackets2b") do
    res = shorthand_brackets2b(100, 200) do
      @fact state-->"shorthand_brackets2b_100_200"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_brackets2c") do
    res = shorthand_brackets2c(100, 200) do
      @fact state-->"shorthand_brackets2c_100_200"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_brackets2d") do
    res = shorthand_brackets2d(100, 200) do
      @fact state-->"shorthand_brackets2d_100_200"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_brackets2e") do
    res = shorthand_brackets2e(100, 200) do
      @fact state-->"shorthand_brackets2e_100_200"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_beginend0a") do
    res = shorthand_beginend0a() do
      @fact state-->"shorthand_beginend0a"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_beginend0b") do
    res = shorthand_beginend0b() do
      @fact state-->"shorthand_beginend0b"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_beginend0c") do
    res = shorthand_beginend0c() do
      @fact state-->"shorthand_beginend0c"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_beginend0d") do
    res = shorthand_beginend0d() do
      @fact state-->"shorthand_beginend0d"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_beginend0e") do
    res = shorthand_beginend0e() do
      @fact state-->"shorthand_beginend0e"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_beginend1a") do
    res = shorthand_beginend1a(100) do
      @fact state-->"shorthand_beginend1a_100"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_beginend1b") do
    res = shorthand_beginend1b(100) do
      @fact state-->"shorthand_beginend1b_100"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_beginend1c") do
    res = shorthand_beginend1c(100) do
      @fact state-->"shorthand_beginend1c_100"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_beginend1d") do
    res = shorthand_beginend1d(100) do
      @fact state-->"shorthand_beginend1d_100"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_beginend1e") do
    res = shorthand_beginend1e(100) do
      @fact state-->"shorthand_beginend1e_100"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_beginend1f") do
    res = shorthand_beginend1f(100) do
      @fact state-->"shorthand_beginend1f_100"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_beginend2a") do
    res = shorthand_beginend2a(100, 200) do
      @fact state-->"shorthand_beginend2a_100_200"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_beginend2b") do
    res = shorthand_beginend2b(100, 200) do
      @fact state-->"shorthand_beginend2b_100_200"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_beginend2c") do
    res = shorthand_beginend2c(100, 200) do
      @fact state-->"shorthand_beginend2c_100_200"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_beginend2d") do
    res = shorthand_beginend2d(100, 200) do
      @fact state-->"shorthand_beginend2d_100_200"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_beginend2e") do
    res = shorthand_beginend2e(100, 200) do
      @fact state-->"shorthand_beginend2e_100_200"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("shorthand_beginend2f") do
    res = shorthand_beginend2f(100, 200) do
      @fact state-->"shorthand_beginend2f_100_200"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method0a") do
    res = method0a() do
      @fact state-->"method0a"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method0b") do
    res = method0b() do
      @fact state-->"method0b"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method0c") do
    res = method0c() do
      @fact state-->"method0c"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method0d") do
    res = method0d() do
      @fact state-->"method0d"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method1a") do
    res = method1a(100) do
      @fact state-->"method1a_100"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method1b") do
    res = method1b(100) do
      @fact state-->"method1b_100"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method1c") do
    res = method1c(100) do
      @fact state-->"method1c_100"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method1d") do
    res = method1d(100) do
      @fact state-->"method1d_100"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method1e") do
    res = method1e(100) do
      @fact state-->"method1e_100"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method2a") do
    res = method2a(100, 200) do
      @fact state-->"method2a_100_200"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method2b") do
    res = method2b(100, 200) do
      @fact state-->"method2b_100_200"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method2c") do
    res = method2c(100, 200) do
      @fact state-->"method2c_100_200"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method2d") do
    res = method2d(100, 200) do
      @fact state-->"method2d_100_200"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method2e") do
    res = method2e(100, 200) do
      @fact state-->"method2e_100_200"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("function0a") do
    res = function0a() do
      @fact state-->"function0a"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("function0b") do
    res = function0b() do
      @fact state-->"function0b"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("function0c") do
    res = function0c() do
      @fact state-->"function0c"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("function1a") do
    res = function1a(100) do
      @fact state-->"function1a_100"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("function1b") do
    res = function1b(100) do
      @fact state-->"function1b_100"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("function1c") do
    res = function1c(100) do
      @fact state-->"function1c_100"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("function1d") do
    res = function1d(100) do
      @fact state-->"function1d_100"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("function2a") do
    res = function2a(100, 200) do
      @fact state-->"function2a_100_200"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("function2b") do
    res = function2b(100, 200) do
      @fact state-->"function2b_100_200"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("function2c") do
    res = function2c(100, 200) do
      @fact state-->"function2c_100_200"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("function2d") do
    res = function2d(100, 200) do
      @fact state-->"function2d_100_200"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_beginend0a") do
    res = lambda_beginend0a() do
      @fact state-->"lambda_beginend0a"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_beginend0b") do
    res = lambda_beginend0b() do
      @fact state-->"lambda_beginend0b"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_beginend0c") do
    res = lambda_beginend0c() do
      @fact state-->"lambda_beginend0c"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_beginend0d") do
    res = lambda_beginend0d() do
      @fact state-->"lambda_beginend0d"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_beginend1a") do
    res = lambda_beginend1a(100) do
      @fact state-->"lambda_beginend1a_100"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_beginend1b") do
    res = lambda_beginend1b(100) do
      @fact state-->"lambda_beginend1b_100"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_beginend1c") do
    res = lambda_beginend1c(100) do
      @fact state-->"lambda_beginend1c_100"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_beginend1d") do
    res = lambda_beginend1d(100) do
      @fact state-->"lambda_beginend1d_100"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_beginend1e") do
    res = lambda_beginend1e(100) do
      @fact state-->"lambda_beginend1e_100"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_beginend2a") do
    res = lambda_beginend2a(100, 200) do
      @fact state-->"lambda_beginend2a_100_200"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_beginend2b") do
    res = lambda_beginend2b(100, 200) do
      @fact state-->"lambda_beginend2b_100_200"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_beginend2c") do
    res = lambda_beginend2c(100, 200) do
      @fact state-->"lambda_beginend2c_100_200"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_beginend2d") do
    res = lambda_beginend2d(100, 200) do
      @fact state-->"lambda_beginend2d_100_200"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_beginend2e") do
    res = lambda_beginend2e(100, 200) do
      @fact state-->"lambda_beginend2e_100_200"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_brackets0a") do
    res = lambda_brackets0a() do
      @fact state-->"lambda_brackets0a"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_brackets0b") do
    res = lambda_brackets0b() do
      @fact state-->"lambda_brackets0b"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_brackets0c") do
    res = lambda_brackets0c() do
      @fact state-->"lambda_brackets0c"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_brackets0d") do
    res = lambda_brackets0d() do
      @fact state-->"lambda_brackets0d"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_brackets1a") do
    res = lambda_brackets1a(100) do
      @fact state-->"lambda_brackets1a_100"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_brackets1b") do
    res = lambda_brackets1b(100) do
      @fact state-->"lambda_brackets1b_100"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_brackets1c") do
    res = lambda_brackets1c(100) do
      @fact state-->"lambda_brackets1c_100"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_brackets1d") do
    res = lambda_brackets1d(100) do
      @fact state-->"lambda_brackets1d_100"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_brackets1e") do
    res = lambda_brackets1e(100) do
      @fact state-->"lambda_brackets1e_100"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_brackets2a") do
    res = lambda_brackets2a(100, 200) do
      @fact state-->"lambda_brackets2a_100_200"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_brackets2b") do
    res = lambda_brackets2b(100, 200) do
      @fact state-->"lambda_brackets2b_100_200"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_brackets2c") do
    res = lambda_brackets2c(100, 200) do
      @fact state-->"lambda_brackets2c_100_200"
      global state=""
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_brackets2d") do
    res = lambda_brackets2d(100, 200) do
      @fact state-->"lambda_brackets2d_100_200"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("lambda_brackets2e") do
    res = lambda_brackets2e(100, 200) do
      @fact state-->"lambda_brackets2e_100_200"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("misplaced yield_fixture() causes an error") do
    caught = false
    try
      eval(:(yield_fixture()))
    catch
      caught = true
    end
    @fact caught-->true
  end

  context("fixture_that_produces_a_value") do
    res = fixture_that_produces_a_value() do x
      @fact state-->"fixture_that_produces_a_value"
      @fact x-->100
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("fixture_that_produces_two_values") do
    res = fixture_that_produces_two_values() do x, y
      @fact state-->"fixture_that_produces_two_values"
      @fact x-->100
      @fact y-->200
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method0p0d1kw") do
    res = method0p0d1kw(x=100) do
      @fact state-->"method0p0d1kw_100"
      1234
    end
    @fact res-->1234
    @fact state-->""
    res = method0p0d1kw() do
      @fact state-->"method0p0d1kw_10"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method0p0d1kwT") do
    res = method0p0d1kwT(x=100) do
      @fact state-->"method0p0d1kwT_100"
      1234
    end
    @fact res-->1234
    @fact state-->""
    res = method0p0d1kwT() do
      @fact state-->"method0p0d1kwT_10"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method0p0d2kw") do
    res = method0p0d2kw(x=100,y=200) do
      @fact state-->"method0p0d2kw_100_200"
      1234
    end
    @fact res-->1234
    @fact state-->""
    res = method0p0d2kw() do
      @fact state-->"method0p0d2kw_10_20"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method0p0d2kwT") do
    res = method0p0d2kwT(x=100,y=200) do
      @fact state-->"method0p0d2kwT_100_200"
      1234
    end
    @fact res-->1234
    @fact state-->""
    res = method0p0d2kwT() do
      @fact state-->"method0p0d2kwT_10_20"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method0p1d0kw") do
    res = method0p1d0kw() do
      @fact state-->"method0p1d0kw_10"
      1234
    end
    @fact res-->1234
    @fact state-->""
    res = method0p1d0kw(100) do
      @fact state-->"method0p1d0kw_100"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method0p1d0kwT") do
    res = method0p1d0kwT() do
      @fact state-->"method0p1d0kwT_10"
      1234
    end
    @fact res-->1234
    @fact state-->""
    res = method0p1d0kwT(100) do
      @fact state-->"method0p1d0kwT_100"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method0p2d0kw") do
    res = method0p2d0kw(100,200) do
      @fact state-->"method2p0d0kw_100_200"
      1234
    end
    @fact res-->1234
    @fact state-->""
    res = method0p2d0kw() do
      @fact state-->"method2p0d0kw_10_20"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method0p2d0kwT") do
    res = method0p2d0kwT(100,200) do
      @fact state-->"method0p2d0kwT100_200"
      1234
    end
    @fact res-->1234
    @fact state-->""
    res = method0p2d0kwT() do
      @fact state-->"method0p2d0kwT10_20"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method1p0d0kw") do
    res = method1p0d0kw(100) do
      @fact state-->"method1p0d0kw_100"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method1p0d0kwT") do
    res = method1p0d0kwT(100) do
      @fact state-->"method1p0d0kwT_100"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method1p1d1kw") do
    res = method1p1d1kw(100,200,z=300) do
      @fact state-->"method1p1d1kw_100_200_300"
      1234
    end
    @fact res-->1234
    @fact state-->""
    res = method1p1d1kw(100) do
      @fact state-->"method1p1d1kw_100_10_20"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method1p1d1kwT") do
    res = method1p1d1kwT(100,200,z=300) do
      @fact state-->"method1p1d1kwT_100_200_300"
      1234
    end
    @fact res-->1234
    @fact state-->""
    res = method1p1d1kwT(100) do
      @fact state-->"method1p1d1kwT_100_10_20"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method2p0d0kw") do
    res = method2p0d0kw(100,200) do
      @fact state-->"method2p0d0kw_100_200"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method2p0d0kwT") do
    res = method2p0d0kwT(100,200) do
      @fact state-->"method2p0d0kwT_100_200"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method2p2d2kw") do
    res = method2p2d2kw(100,200,300,400,z1=500,z2=600) do
      @fact state-->"method2p2d2kw_100_200_300_400_500_600"
      1234
    end
    @fact res-->1234
    @fact state-->""
    res = method2p2d2kw(100,200) do
      @fact state-->"method2p2d2kw_100_200_10_20_30_40"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method2p2d2kwT") do
    res = method2p2d2kwT(100,200,300,400,z1=500,z2=600) do
      @fact state-->"method2p2d2kwT_100_200_300_400_500_600"
      1234
    end
    @fact res-->1234
    @fact state-->""
    res = method2p2d2kwT(100,200) do
      @fact state-->"method2p2d2kwT_100_200_10_20_30_40"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method_variadic_a") do
    res = method_variadic_a(10,20,30) do
      @fact state-->"method_variadic_a_(10,20,30)"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method_variadic_b") do
    res = method_variadic_b(x=10,y=20,z=30) do
      kwargs = Any[(:x,10),(:y,20),(:z,30)]
      @fact state-->"method_variadic_b_$kwargs"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method_variadic_c") do
    res = method_variadic_c(10,20,30,x=10,y=20,z=30) do
      args = (10, 20 , 30)
      kwargs = Any[(:x,10),(:y,20),(:z,30)]
      @fact state-->"method_variadic_c_$(args)_$kwargs"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method_variadic_d") do
    res = method_variadic_d(10,20,30) do
      @fact state-->"method_variadic_d_10_(20,30)"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method_variadic_e") do
    res = method_variadic_e(x=10,y=20,z=30) do
      kwargs = Any[(:y,20),(:z,30)]
      @fact state-->"method_variadic_e_10_$kwargs"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method_variadic_f") do
    res = method_variadic_f(10,20,30,x=10,y=20,z=30) do
      kwargs = Any[(:x,10),(:z,30)]
      @fact state-->"method_variadic_f_10_(20,30)_20_$kwargs"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method_variadic_g") do
    res = method_variadic_g(10,20,30) do
      @fact state-->"method_variadic_g_(10,20,30)"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method_variadic_h") do
    res = method_variadic_h(10,20,30,x=10,y=20,z=30) do
      kwargs = Any[(:x,10),(:y,20),(:z,30)]
      @fact state-->"method_variadic_h_(10,20,30)_$kwargs"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method_variadic_i") do
    res = method_variadic_i(10,20,30) do
      @fact state-->"method_variadic_i_10_(20,30)"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method_variadic_j") do
    res = method_variadic_j(x=10,y=20,z=30) do
      kwargs = Any[(:y,20),(:z,30)]
      @fact state-->"method_variadic_j_10_$kwargs"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

  context("method_variadic_k") do
    res = method_variadic_k(10,20,30,x=10,y=20,z=30) do
      kwargs = Any[(:x,10),(:z,30)]
      @fact state-->"method_variadic_k_10_(20,30)_20_$kwargs"
      1234
    end
    @fact res-->1234
    @fact state-->""
  end

end

end


text:
module ProtoBufTestWellKnown
using ProtoBuf
using google.protobuf
using Base.Test
using Compat

print_hdr(tname) = println("testing $tname...")

function test_listvalue()
    print_hdr(ListValue.name)
    v1 = Value(;number_value=10.10)
    v2 = Value(;string_value="hello")
    va = [v1, v2]
    l = ListValue(;values=va)
    iob = PipeBuffer()
    writeproto(iob, l)
    l1 = ListValue()
    readproto(iob, l1)

    @test length(l.values) == length(l1.values)
    @test l.values[1].number_value == l1.values[1].number_value
    @test l.values[2].string_value == l1.values[2].string_value
    @test l == l1
end

function test_struct()
    print_hdr(Struct.name)
    v1 = Value(;number_value=10.10)
    v2 = Value(;string_value="hello")
    vd = Dict{AbstractString,Any}()
    vd["v1"] = v1
    vd["v2"] = v2
    s = Struct(;fields=vd)
    iob = PipeBuffer()
    writeproto(iob, s)
    s1 = Struct()
    readproto(iob, s1)

    @test length(s.fields) == length(s1.fields)
    @test s.fields["v1"].number_value == s1.fields["v1"].number_value
    @test s.fields["v2"].string_value == s1.fields["v2"].string_value
    @test s == s1
end

function test_generic{T}(::Type{T}; kwargs...)
    print_hdr(T.name)
    w = T(;kwargs...)
    iob = PipeBuffer()
    writeproto(iob, w)
    r = T()
    readproto(iob, r)
    @test w == r
end

test_any() = test_generic(_Any; type_url="testurl", value=UInt8[1,2,3,4,5])
test_empty() = test_generic(Empty)
test_timestamp() = test_generic(Timestamp; seconds=10, nanos=100)
test_duration() = test_generic(Duration; seconds=10, nanos=100)
test_fieldmask() = test_generic(FieldMask; paths=[randstring(10), randstring(10)])

function test_wrappers()
    types = [DoubleValue, FloatValue, Int64Value, UInt64Value, Int32Value, UInt32Value, BoolValue, StringValue, BytesValue]
    vals = Any[1.1, @compat(Float32(1.1)), 100, rand(UInt64), rand(Int32), rand(UInt32), true, randstring(10), rand(UInt8, 10)]
    for idx in 1:length(types)
        test_generic(types[idx]; value=vals[idx])
    end
end

end # module ProtoBufTestWellKnown

ProtoBufTestWellKnown.test_listvalue()
ProtoBufTestWellKnown.test_struct()
ProtoBufTestWellKnown.test_any()
ProtoBufTestWellKnown.test_empty()
ProtoBufTestWellKnown.test_timestamp()
ProtoBufTestWellKnown.test_duration()
ProtoBufTestWellKnown.test_fieldmask()
ProtoBufTestWellKnown.test_wrappers()


text:
using OrdinaryDiffEq, DiffEqBase, Base.Test, DiffEqProblemLibrary, DiffEqDevTools
srand(100)
u = [0.5,0.2]
prob = prob_ode_2Dlinear

## Convergence Testing
println("Convergence Test on Linear")
dts = 1.//2.^(4:-1:2)
testTol = 1

println("Feagin RKs")
sol =solve(prob,Feagin10(),dt=dts[1])

const linear_bigα = parse(BigFloat,"1.01")
f = (t,u,du) -> begin
  for i in 1:length(u)
    du[i] = linear_bigα*u[i]
  end
end
analytic = (t,u0) -> u0*exp(linear_bigα*t)
prob_ode_bigfloat2Dlinear = ODETestProblem(f,map(BigFloat,rand(4,2)).*ones(4,2)/2,analytic)

prob = prob_ode_bigfloat2Dlinear

sim = test_convergence(dts,prob,Feagin10())
@test abs(sim.𝒪est[:final]-8) < testTol #Lowered due to low test dt

sim = test_convergence(dts,prob,Feagin12())
@test abs(sim.𝒪est[:final]-12) < testTol

sim = test_convergence(dts,prob,Feagin14())
@test abs(sim.𝒪est[:final]-15) < testTol #Upped to 15 for test

f = (t,u) -> (linear_bigα*u)
prob_ode_bigfloatlinear = ODETestProblem(f,parse(BigFloat,"0.5"),analytic)
prob = prob_ode_bigfloatlinear

dts = 1.//2.^(6:-1:3)
sim = test_convergence(dts,prob,Feagin10())
@test abs(sim.𝒪est[:final]-10) < testTol

dts = 1.//2.^(4:-1:2)
sim = test_convergence(dts,prob,Feagin12())
@test abs(sim.𝒪est[:final]-12) < testTol

sim = test_convergence(dts,prob,Feagin14())
@test abs(sim.𝒪est[:final]-15) < testTol #Upped to 15 for test

prob = prob_ode_bigfloat2Dlinear

#compile
sol =solve(prob,Feagin10(),dt=dts[1])
sol =solve(prob,Feagin12(),dt=dts[1])
sol =solve(prob,Feagin14(),dt=dts[1])

#test
@time sol =solve(prob,Feagin10(),dt=dts[1])
@time sol =solve(prob,Feagin12(),dt=dts[1])
@time sol =solve(prob,Feagin14(),dt=dts[1])


text:
module Json
    import JSON2
    export json

    function json(req, res, route)
        req[:json] = this -> this.json = try
            JSON2.read(this.body)
        catch e
            @error "invalid json" this.body
            return res.code(400)
        end

        res[:json] = this -> let
            function _json(x)
                this.status = 200
                this.body = JSON2.write(x)
                this.content_type = "application/json"
            end
            _json(;x...) = _json(x.data)
        end

        route.next()
    end
end


text:
using DashBootstrapComponents, DashHtmlComponents

fade = html_div([
    dbc_button(
        "Toggle fade",
        id="fade-transition-button",
        className="mb-3",
        n_clicks=0,
    ),
    dbc_fade(
        dbc_card(
            dbc_cardbody(html_p("This content fades in and out", className="card-text")),
        ),
        id="fade-transition",
        is_in=true,
        style=Dict("transition" => "opacity 2000ms ease"),
        timeout=2000,
    ),
]);

callback!(
    app,
    Output("fade-transition", "is_in"),
    Input("fade-transition-button", "n_clicks"),
    State("fade-transition", "is_in"),
) do n, is_in
    return n > 0 ? is_in == 0 : true
end;

max_stars_repo_name: harisbal/dash-bootstrap-components

max_issues_repo_name: harisbal/dash-bootstrap-components

max_forks_repo_name: harisbal/dash-bootstrap-components