text:
# ROBDD.jl
# David Merrell
# (c) 2020-07-03
#
# A simple Julia module for building and working with ROBDDs.

module ROBDD

export ROBDDTable, build_robdd, apply, restrict, satcount, anysat, allsat, clean_table

# Some essential functionality for the ROBDDTable
# and its members.
import Base: getindex, setindex!, show, iterate

using LRUCache

# The simple building block of our ROBDDs.
struct BDDNode
    var::UInt32
    lo::UInt32
    hi::UInt32
end

# We define a `ROBDDTable` that
# (1) tracks the variables we're working with, and their ordering; and
# (2) maintains some hash tables for bookkeeping

mutable struct NodeTable
    d::Dict{UInt32,BDDNode}
    latest::UInt32
end

function NodeTable(n::UInt32)
    d = Dict{UInt32,BDDNode}()
    d[0] = BDDNode(n+1,0,0)
    d[1] = BDDNode(n+1,1,1)
    return NodeTable(d,1)
end

mutable struct LookupTable
    d::Dict{BDDNode,UInt32}
end

LookupTable() = LookupTable(Dict{BDDNode,UInt32}())

mutable struct ROBDDTable
    order::Vector{Symbol}
    order_lookup::Dict{Symbol,UInt32}
    T::NodeTable
    H::LookupTable
end

ROBDDTable(order::Vector{Symbol}) = ROBDDTable(order,
                                               Dict(name=>idx for (idx,name) in enumerate(order)),
                                               NodeTable(UInt32(length(order))),
                                               LookupTable()
                                              )

function show(io::IO, bddtab::ROBDDTable)
    out_str = string("(0) false\n(1) true")
    for i=2:bddtab.T.latest
        v = varname(bddtab,UInt32(i))
        out_str = string(out_str, "\n","(",i,") ",
                         varname(bddtab,UInt32(i)), " ",
                         lo(bddtab,UInt32(i)), " ",
                         hi(bddtab,UInt32(i)))
    end
    print(io, out_str)

    return
end

# Basic operations for the node table
function add!(T::NodeTable, node::BDDNode)
    T.latest = T.latest + 1
    T.d[T.latest] = node
    return T.latest
end

getindex(T::NodeTable, idx::UInt32) = T.d[idx]

# Basic operations for the "inverse" lookup table
member(H::LookupTable, node::BDDNode) = haskey(H.d, node)
getindex(H::LookupTable, node::BDDNode) = H.d[node]
getindex(bddtab::ROBDDTable, node::BDDNode) = bddtab.H[node]

function setindex!(H::LookupTable, idx::UInt32, node::BDDNode)
    setindex!(H.d, idx, node)
end

function get_or_add(bddtab::ROBDDTable, node::BDDNode)
    if node.lo == node.hi
        return node.lo
    elseif member(bddtab.H, node)
        return bddtab.H[node]
    else
        u = add!(bddtab.T, node)
        bddtab.H[node] = u
        return u
    end
end

getindex(bddtab::ROBDDTable, idx::UInt32) = bddtab.T[idx]
var(bddtab::ROBDDTable, idx::UInt32) = bddtab[idx].var
varname(bddtab::ROBDDTable, idx::UInt32) = bddtab.order[bddtab[idx].var]
lo(bddtab::ROBDDTable, idx::UInt32) = bddtab[idx].lo
hi(bddtab::ROBDDTable, idx::UInt32) = bddtab[idx].hi

"""
Apply a unary operation `op` to a BDD
"""
function apply(bddtab::ROBDDTable, op::Function, idx::UInt32;
               memo::AbstractDict{Tuple{Function,Vararg{UInt32}},UInt32}=LRU{Tuple{Function,Vararg{UInt32}},UInt32}(maxsize=3000000, by=sizeof)
              # memo::Dict{Tuple{Function,Vararg{UInt32}},UInt32}=Dict{Tuple{Function,Vararg{UInt32}},UInt32}())
              )

    function rec_app(u1)
        if haskey(memo, (op,u1))
            return memo[(op,u1)]
        elseif in(u1, (0,1))
            u = UInt32(op(Bool(u1)))
        else
            u = get_or_add(bddtab,
                           BDDNode(var(bddtab,u1),
                                   rec_app(lo(bddtab,u1)),
                                   rec_app(hi(bddtab,u1))
                                  )
                           )
        end
        memo[(op,u1)] = u
        return u
    end

    return rec_app(idx)
end

"""
Apply a binary operation `op` to two BDDs
"""
function apply(bddtab::ROBDDTable, op::Function, idx1::UInt32, idx2::UInt32;
               memo::AbstractDict{Tuple{Function,Vararg{UInt32}},UInt32}=LRU{Tuple{Function,Vararg{UInt32}},UInt32}(maxsize=3000000, by=sizeof)
              # memo::Dict{Tuple{Function,Vararg{UInt32}},UInt32}=Dict{Tuple{Function,Vararg{UInt32}},UInt32}()
              )

    function rec_app(u1, u2)
        if haskey(memo, (op,u1,u2))
            return memo[(op,u1,u2)]
        # Added some more cases to prune the recursion
        elseif (op == |) & (1 in (u1, u2))
            u = 1
        elseif (op == &) & (0 in (u1, u2))
            u = 0
        elseif in(u1, (0,1)) & in(u2, (0,1))
            u = UInt32(op(Bool(u1), Bool(u2)))
        elseif var(bddtab, u1) == var(bddtab, u2)
            u = get_or_add(bddtab,
                           BDDNode(var(bddtab,u1),
                                   rec_app(lo(bddtab,u1), lo(bddtab,u2)),
                                   rec_app(hi(bddtab,u1), hi(bddtab,u2))
                                   )
                           )
        elseif var(bddtab, u1) < var(bddtab, u2)
            u = get_or_add(bddtab,
                           BDDNode(var(bddtab,u1),
                                   rec_app(lo(bddtab, u1), u2),
                                   rec_app(hi(bddtab, u1), u2)
                                   )
                           )
        else
            u = get_or_add(bddtab,
                           BDDNode(var(bddtab,u2),
                                   rec_app(u1, lo(bddtab, u2)),
                                   rec_app(u1, hi(bddtab, u2))
                                   )
                           )
        end
        memo[(op,u1,u2)] = u
        return u
    end

    return rec_app(idx1, idx2)
end

"""
Build an ROBDD from a boolean expression `bool_expr`,
within the context defined by ROBDDTable `bddtab`.

Optional `memo` kwarg allows a persistent memoization cache
to be used by multiple calls to `build_robdd`.
"""
function build_robdd(bddtab::ROBDDTable, bool_expr::Union{Bool,Symbol,Expr};
                     memo::AbstractDict{Tuple{Function,Vararg{UInt32}},UInt32}=LRU{Tuple{Function,Vararg{UInt32}},UInt32}(maxsize=3000000, by=sizeof)
                    )

    function rec_build(my_expr)
        # Terminals
        if typeof(my_expr) == Bool
            return UInt32(my_expr)
        elseif typeof(my_expr) == Symbol
            u = get_or_add(bddtab,
                           BDDNode(bddtab.order_lookup[my_expr],0,1)
                           )
        # Boolean op nodes
        else
            u = -1
            op = eval(my_expr.args[1])
            sub_exprs = my_expr.args[2:end]
            sub_bdds = Vector{UInt32}(undef,length(sub_exprs))
            for (i,se) in enumerate(sub_exprs)
                sub_bdds[i] = rec_build(se)
                # Add some checks for lazy evaluation
                if (op == |) & (sub_bdds[i] == 1)
                    u = 1
                    break
                elseif (op == &) & (sub_bdds[i] == 0)
                    u = 0
                    break
                end
            end
            if u == -1
                u = apply(bddtab, op, sub_bdds...; memo=memo)
            end
        end
        return u
    end

    return rec_build(bool_expr)
end

"""
Restrict a ROBDD via `assignments`,
a dictionary of variable assignments.

Optional `memo` kwarg allows a persistent memoization cache
to be used by multiple calls to `restrict`.
"""
function restrict(bddtab::ROBDDTable, bdd_idx::UInt32, assignments::Dict{Symbol,Bool};
                  memo::AbstractDict{Tuple{UInt32,UInt32,Bool},UInt32}=LRU{Tuple{UInt32,UInt32,Bool},UInt32}(maxsize=3000000, by=sizeof)
                  )

    function rec_res(u, j, b)
        if haskey(memo, (u,j,b))
            return memo[(u,j,b)]
        elseif var(bddtab, u) > j
            return u
        elseif var(bddtab, u) < j
            u_new = get_or_add(bddtab, BDDNode(var(bddtab, u),
                                               rec_res(lo(bddtab, u), j, b),
                                               rec_res(hi(bddtab, u), j, b)
                                               )
                               )
        elseif !b
            u_new = rec_res(lo(bddtab,u), j, b)
        else
            u_new = rec_res(hi(bddtab,u), j, b)
        end
        memo[(u,j,b)] = u_new
        return u_new
    end

    for (j, b) in pairs(assignments)
        bdd_idx = rec_res(bdd_idx, bddtab.order_lookup[j], b)
    end

    return bdd_idx
end

"""
Count the satisfying assignments of an ROBDD.
"""
function satcount(bddtab::ROBDDTable, idx::UInt32;
                  memo::AbstractDict{UInt32,UInt32}=LRU{UInt32,UInt32}(maxsize=3000000, by=sizeof)
                  #memo::Dict{UInt32,UInt32}=Dict{UInt32,UInt32}())
                  )

    function rec_count(u)
        if haskey(memo, u)
            return memo[u]
        elseif u == 0
            count = 0
        elseif u == 1
            count = 1
        else
            l = lo(bddtab,u)
            h = hi(bddtab,u)
            lcount = rec_count(l)
            hcount = rec_count(h)
            res = lcount * 2^(Int(var(bddtab,l)) - Int(var(bddtab,u)) - 1) + hcount * 2^(Int(var(bddtab,r)) - Int(var(bddtab,u)) - 1)
        end
        return res
    end

    return rec_count(idx)
end

####################################################
# Helper functions for SAT iteration
####################################################
function state_to_assignment(bddtable::ROBDDTable,
                             state::Vector{Pair{UInt32,Bool}})
    assignment = [bddtable.order[var(bddtable,n)] => b for (n,b) in state]
    assignment = Dict{Symbol,Bool}(assignment)
    return assignment
end

function dfs_sat_first(bddtab::ROBDDTable, idx::UInt32)
    if idx == 0
        error("unsat")
    elseif idx == 1
        result = Vector{Pair{UInt32,Bool}}()
    elseif lo(bddtab, idx) == 0
        result = dfs_sat_first(bddtab, hi(bddtab,idx))
        pushfirst!(result, idx => true)
    else
        result = dfs_sat_first(bddtab, lo(bddtab,idx))
        pushfirst!(result, idx => false)
    end
    return result
end

function is_sat(bddtab::ROBDDTable, state)
    (idx,b) = state[end]
    if b & hi(bddtab, idx) == 1
        return true
    elseif !b & lo(bddtab, idx) == 1
        return true
    else
        return false
    end
end

function increment_ancestor(bddtab::ROBDDTable, state)
    n = length(state)
    for i = n:-1:1
        (idx,b) = pop!(state)
        if !b
            push!(state, idx => true)
            break
        end
    end
    return state
end

function dfs_next_sat(bddtab::ROBDDTable, state)

    while true
        (idx,b) = state[end]
        if !b & !in(lo(bddtab,idx), (0,1))
            # lo child not terminal --> add lo child
            push!(state, lo(bddtab,idx) => false)
        elseif b & !in(hi(bddtab,idx), (0,1))
            # hi child not terminal --> add hi child
            push!(state, hi(bddtab,idx) => false)
        else
            # change self or nearest ancestor from false -> true
            state = increment_ancestor(bddtab, state)
        end

        if length(state) == 0
            break
        elseif is_sat(bddtab, state)
            break
        end
    end
    return state
end

"""
Return an arbitrary satisfying assignment for an ROBDD.
The method is deterministic -- it will return the same value
when called multiple times.
"""
function anysat(bddtab::ROBDDTable, idx::UInt32)
    assignments = dfs_sat_first(bddtab, idx)
    assignments = [bddtab.order[var(bddtab,idx)] => b for (idx,b) in assignments]
    return Dict{Symbol,Bool}(assignments)
end

##########################################
# AllSat iterator
##########################################

"""
An iterator over the set of satisfying assignments.
Performs DFS to find all paths from the root node
to the (1) node.

Note that any unassigned variables may take arbitrary values.
Hence, an assignment with n unassigned variables actually
represents 2^n assignments.
"""
struct AllSat
    bddtable::ROBDDTable
    idx::UInt32
end

allsat(bddtab::ROBDDTable, idx::UInt32) = AllSat(bddtab,idx)

function iterate(iter::AllSat)
    try
        state = dfs_sat_first(iter.bddtable, iter.idx)
        soln = state_to_assignment(iter.bddtable, state)
        return (soln, state)
    catch
        return nothing
    end
end

function iterate(iter::AllSat, state::Vector{Pair{UInt32,Bool}})
    state = dfs_next_sat(iter.bddtable, state)
    if length(state) == 0
        return nothing
    else
        return (state_to_assignment(iter.bddtable, state), state)
    end
end

"""
Create a new ROBDDTable encoding the same ROBDD
as `bddtab[idx]`, but with all of the "unused" nodes
removed.

Returns a tuple: (new_table::ROBDDTable, new_idx::UInt32)
"""
function clean_table(bddtab::ROBDDTable, idx::UInt32)

    new_table = ROBDDTable(bddtab.order)
    old2new = Dict{UInt32,UInt32}(0=>0,1=>1)

    function rec_clean(old_u)
        if haskey(old2new, old_u)
            return old2new[old_u]
        else
            new_lo = rec_clean(lo(bddtab, old_u))
            new_hi = rec_clean(hi(bddtab, old_u))
            new_u = get_or_add(new_table,
                               BDDNode(var(bddtab, old_u),
                                       new_lo, new_hi
                                      )
                               )
            old2new[old_u] = new_u
            return new_u
        end
    end

    new_idx = rec_clean(idx)
    return new_table, new_idx
end

end # END MODULE


text:
using KCenters, KNearestCenters, TextSearch, TextClassification, SearchModels, UnicodePlots, StatsBase
using LIBLINEAR
using Distributed

const PROCS = parse(Int, get(ENV, "procs", "1"))
const isample = parse(Int, get(ENV, "isample", "64"))

addprocs(PROCS, exeflags="--project=.")

@everywhere begin
    include("utils.jl")
    include("commands.jl")
end

function main_search_model(nick, train, textconfig, textmodel, cls; score=:macrorecall)
    labelkey = get(ENV, "klass", "klass")
    textkey = get(ENV, "text", "text")
    bsize = parse(Int, get(ENV, "bsize", "4"))

    # search hyper-parameters
    search_kwargs = Dict(
        #:score => (name=:classrecall, label=1),
        :score => score, # :accuracy,
        #:cv => (kind=:folds, folds=5),
        #:cv => (kind=:montecarlo, repeat=15, ratio=0.5),
        :cv => (kind=:montecarlo, repeat=10, ratio=0.7),
        :initialpopulation => isample,
        :maxpopulation => 32,
        :bsize => bsize,
        :mutbsize => 64,
        :crossbsize => 0,
        :tol => 0.001,
        :maxiters => 20,
        :verbose => true,
        :parallel => (PROCS>1 ? :distributed : :none)
        #:parallel => :threads
    )

    space = MicroTC_ConfigSpace(textconfig=textconfig, textmodel=textmodel, cls=cls)
    outdir = nick
    !isdir(outdir) && mkdir(outdir)
    paramsfile = "$outdir/params"
    D = loadjson(train; textkey=textkey, labelkey=labelkey)
    @info "class distribution:" countmap(D.labels)
    run_params(D, paramsfile, space, search_kwargs)
end

if !isinteractive()
    textconfig = TextConfigSpace(
        del_diac=[true, false],
        del_dup=[true, false],
        del_punc=[true, false],
        group_num=[true, false],
        group_url=[true, false],
        group_usr=[true, false],
        group_emo=[true, false],
        lc=[true],
        qlist=[[3], [3, 5], [3, 7], []],
        nlist=[[1], [1, 2], [2], [1, 2, 3], []],
        slist=[[Skipgram(2,1)], []],
        # nlist_space = [1, 2, 3],
        # qlist_space = [3, 5, 7],
        # slist_space = []
    )

    #llspace = LiblinearConfigSpace()
    #knnspace = KnnClassifierConfigSpace()
    kncspace = KncPerClassConfigSpace{0.5}(
        centerselection=[TextCentroidSelection()],
        kernel=[k_(CosineDistance()) for k_ in [DirectKernel]]
    )
    llspace = LiblinearConfigSpace(scale_C=nothing, scale_eps=nothing)
    knnspace = KnnClassifierConfigSpace(k=[1, 3], scale_k=nothing)
    entspace = EntModelConfigSpace(
        weights=[:balance],
        #local_weighting=[TpWeighting()],
        #local_weighting=[BinaryLocalWeighting()],
        #scale_mindocs=nothing,
        #scale_smooth=nothing
    )
    vecspace = VectorModelConfigSpace()
    #classifiers = [llspace, knnspace]
    #classifiers = [knnspace]
    classifiers = [llspace]
    #classifiers = [kncspace]
    method = get(ENV, "method", "microtc")
    train = ENV["train"]
    nick = get(ENV, "nick", "_$(method)_" * replace(basename(train), ".json" => ""))
    score = Symbol(get(ENV, "score", "macrorecall"))

    if method == "entropy"
        main_search_model(nick, train, textconfig, entspace, classifiers; score)
    elseif method == "no-entropy"
        main_search_model(nick, train, textconfig, vecspace, classifiers; score)
    elseif method == "microtc"
        main_search_model(nick, train, textconfig, [vecspace, entspace], classifiers; score)
    else
        error("unknown method $method")
    end
end

ext: jl

max_stars_repo_name: sadit/text-classification-scripts

max_issues_repo_name: sadit/text-classification-scripts

max_forks_repo_name: sadit/text-classification-scripts


text:
"""
An abstract type for implementing secondary-fluorescence corrections.

    F(unk::FluorescenceCorrection, xray::CharXRay, θtoa::AbstractFloat)
"""
abstract type FluorescenceCorrection end

"""
    NullFluorescence

Implements Castaing's First Approximation (i.e. No correction F=1)
"""
struct NullFluorescence <: FluorescenceCorrection

    NullFluorescence(mat::Material, ashell::AtomicSubShell, e0::AbstractFloat) = new()
end

Base.show(io::IO, nc::NullFluorescence) = print(io, "Null[Fluor]")

F(nc::NullFluorescence, cxr::CharXRay, θtoa::AbstractFloat) = 1.0

"""
    fluorescence(fltype::Type{<:FluorescenceCorrection}, comp::Material, secondary::AtomicSubShell, e0::Float64)

Construct an instance of a fltype correction structure to compute the
secondary fluorescence in the specified material and beam energy.
"""
function fluorescencecorrection(
    fltype::Type{<:FluorescenceCorrection},
    comp::Material,
    secondary::AtomicSubShell,
    e0::Float64;
    eThresh = 2.5e3,
    wThresh = 0.01,
)
    test(cxr, ee, wt) =
        (energy(cxr) > ee) && (energy(cxr) < ee + eThresh) && (NeXLCore.edgeenergy(cxr) < e0) && (weight(NormalizeToUnity, cxr) > wt)
    char4elm(elm, wt) = characteristic(elm, alltransitions, cxr -> test(cxr, energy(secondary), wt / comp[elm]))
    primaries = mapreduce(elm -> char4elm(elm, wThresh), append!, keys(comp))
    return fluorescencecorrection(fltype, comp, primaries, secondary, e0)
end

fluorescencecorrection(
    fltype::Type{NullFluorescence},
    comp::Material,
    secondary::AtomicSubShell,
    e0::Float64;
    eThresh = 2.5e3,
    wThresh = 0.01,
) = NullFluorescence(comp, secondary, e0)

fluorescencecorrection(
    ::Type{NullFluorescence},
    comp::Material,
    primarys::Vector{CharXRay},
    secondary::AtomicSubShell,
    e0::Float64,
) = NullFluorescence(comp, secondary, e0)

max_stars_repo_name: NicholasWMRitchie/NeXLMatrixCorrection

max_issues_repo_name: NicholasWMRitchie/NeXLMatrixCorrection

max_forks_repo_name: NicholasWMRitchie/NeXLMatrixCorrection


text:
# This file was generated by the Julia Swagger Code Generator
# Do not modify this file directly. Modify the swagger specification instead.

struct AdmissionregistrationV1beta1Api <: SwaggerApi
    client::Swagger.Client
end

function _swaggerinternal_createAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "POST", IoK8sApiAdmissionregistrationV1beta1MutatingWebhookConfiguration, "/apis/admissionregistration.k8s.io/v1beta1/mutatingwebhookconfigurations", ["BearerToken"], body)
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "fieldManager", fieldManager)  # type String
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    return _ctx
end

"""

create a MutatingWebhookConfiguration
Param: body::IoK8sApiAdmissionregistrationV1beta1MutatingWebhookConfiguration (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Return: IoK8sApiAdmissionregistrationV1beta1MutatingWebhookConfiguration
"""
function createAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_createAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api, body; pretty=pretty, dryRun=dryRun, fieldManager=fieldManager, _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function createAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, response_stream::Channel, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_createAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api, body; pretty=pretty, dryRun=dryRun, fieldManager=fieldManager, _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

function _swaggerinternal_createAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "POST", IoK8sApiAdmissionregistrationV1beta1ValidatingWebhookConfiguration, "/apis/admissionregistration.k8s.io/v1beta1/validatingwebhookconfigurations", ["BearerToken"], body)
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "fieldManager", fieldManager)  # type String
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    return _ctx
end

"""

create a ValidatingWebhookConfiguration
Param: body::IoK8sApiAdmissionregistrationV1beta1ValidatingWebhookConfiguration (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Return: IoK8sApiAdmissionregistrationV1beta1ValidatingWebhookConfiguration
"""
function createAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_createAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api, body; pretty=pretty, dryRun=dryRun, fieldManager=fieldManager, _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function createAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, response_stream::Channel, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_createAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api, body; pretty=pretty, dryRun=dryRun, fieldManager=fieldManager, _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

function _swaggerinternal_deleteAdmissionregistrationV1beta1CollectionMutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api; pretty=nothing, allowWatchBookmarks=nothing, body=nothing, __continue__=nothing, dryRun=nothing, fieldSelector=nothing, gracePeriodSeconds=nothing, labelSelector=nothing, limit=nothing, orphanDependents=nothing, propagationPolicy=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "DELETE", IoK8sApimachineryPkgApisMetaV1Status, "/apis/admissionregistration.k8s.io/v1beta1/mutatingwebhookconfigurations", ["BearerToken"], body)
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "allowWatchBookmarks", allowWatchBookmarks)  # type Bool
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "gracePeriodSeconds", gracePeriodSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "orphanDependents", orphanDependents)  # type Bool
    Swagger.set_param(_ctx.query, "propagationPolicy", propagationPolicy)  # type String
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    return _ctx
end

"""

delete collection of MutatingWebhookConfiguration
Param: pretty::String
Param: allowWatchBookmarks::Bool
Param: body::IoK8sApimachineryPkgApisMetaV1DeleteOptions
Param: __continue__::String
Param: dryRun::String
Param: fieldSelector::String
Param: gracePeriodSeconds::Int32
Param: labelSelector::String
Param: limit::Int32
Param: orphanDependents::Bool
Param: propagationPolicy::String
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApimachineryPkgApisMetaV1Status
"""
function deleteAdmissionregistrationV1beta1CollectionMutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api; pretty=nothing, allowWatchBookmarks=nothing, body=nothing, __continue__=nothing, dryRun=nothing, fieldSelector=nothing, gracePeriodSeconds=nothing, labelSelector=nothing, limit=nothing, orphanDependents=nothing, propagationPolicy=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_deleteAdmissionregistrationV1beta1CollectionMutatingWebhookConfiguration(_api; pretty=pretty, allowWatchBookmarks=allowWatchBookmarks, body=body, __continue__=__continue__, dryRun=dryRun, fieldSelector=fieldSelector, gracePeriodSeconds=gracePeriodSeconds, labelSelector=labelSelector, limit=limit, orphanDependents=orphanDependents, propagationPolicy=propagationPolicy, resourceVersion=resourceVersion, timeoutSeconds=timeoutSeconds, watch=watch, _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function deleteAdmissionregistrationV1beta1CollectionMutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, response_stream::Channel; pretty=nothing, allowWatchBookmarks=nothing, body=nothing, __continue__=nothing, dryRun=nothing, fieldSelector=nothing, gracePeriodSeconds=nothing, labelSelector=nothing, limit=nothing, orphanDependents=nothing, propagationPolicy=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_deleteAdmissionregistrationV1beta1CollectionMutatingWebhookConfiguration(_api; pretty=pretty, allowWatchBookmarks=allowWatchBookmarks, body=body, __continue__=__continue__, dryRun=dryRun, fieldSelector=fieldSelector, gracePeriodSeconds=gracePeriodSeconds, labelSelector=labelSelector, limit=limit, orphanDependents=orphanDependents, propagationPolicy=propagationPolicy, resourceVersion=resourceVersion, timeoutSeconds=timeoutSeconds, watch=watch, _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

function _swaggerinternal_deleteAdmissionregistrationV1beta1CollectionValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api; pretty=nothing, allowWatchBookmarks=nothing, body=nothing, __continue__=nothing, dryRun=nothing, fieldSelector=nothing, gracePeriodSeconds=nothing, labelSelector=nothing, limit=nothing, orphanDependents=nothing, propagationPolicy=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "DELETE", IoK8sApimachineryPkgApisMetaV1Status, "/apis/admissionregistration.k8s.io/v1beta1/validatingwebhookconfigurations", ["BearerToken"], body)
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "allowWatchBookmarks", allowWatchBookmarks)  # type Bool
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "gracePeriodSeconds", gracePeriodSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "orphanDependents", orphanDependents)  # type Bool
    Swagger.set_param(_ctx.query, "propagationPolicy", propagationPolicy)  # type String
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    return _ctx
end

"""

delete collection of ValidatingWebhookConfiguration
Param: pretty::String
Param: allowWatchBookmarks::Bool
Param: body::IoK8sApimachineryPkgApisMetaV1DeleteOptions
Param: __continue__::String
Param: dryRun::String
Param: fieldSelector::String
Param: gracePeriodSeconds::Int32
Param: labelSelector::String
Param: limit::Int32
Param: orphanDependents::Bool
Param: propagationPolicy::String
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApimachineryPkgApisMetaV1Status
"""
function deleteAdmissionregistrationV1beta1CollectionValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api; pretty=nothing, allowWatchBookmarks=nothing, body=nothing, __continue__=nothing, dryRun=nothing, fieldSelector=nothing, gracePeriodSeconds=nothing, labelSelector=nothing, limit=nothing, orphanDependents=nothing, propagationPolicy=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_deleteAdmissionregistrationV1beta1CollectionValidatingWebhookConfiguration(_api; pretty=pretty, allowWatchBookmarks=allowWatchBookmarks, body=body, __continue__=__continue__, dryRun=dryRun, fieldSelector=fieldSelector, gracePeriodSeconds=gracePeriodSeconds, labelSelector=labelSelector, limit=limit, orphanDependents=orphanDependents, propagationPolicy=propagationPolicy, resourceVersion=resourceVersion, timeoutSeconds=timeoutSeconds, watch=watch, _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function deleteAdmissionregistrationV1beta1CollectionValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, response_stream::Channel; pretty=nothing, allowWatchBookmarks=nothing, body=nothing, __continue__=nothing, dryRun=nothing, fieldSelector=nothing, gracePeriodSeconds=nothing, labelSelector=nothing, limit=nothing, orphanDependents=nothing, propagationPolicy=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_deleteAdmissionregistrationV1beta1CollectionValidatingWebhookConfiguration(_api; pretty=pretty, allowWatchBookmarks=allowWatchBookmarks, body=body, __continue__=__continue__, dryRun=dryRun, fieldSelector=fieldSelector, gracePeriodSeconds=gracePeriodSeconds, labelSelector=labelSelector, limit=limit, orphanDependents=orphanDependents, propagationPolicy=propagationPolicy, resourceVersion=resourceVersion, timeoutSeconds=timeoutSeconds, watch=watch, _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

function _swaggerinternal_deleteAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, name::String; pretty=nothing, body=nothing, dryRun=nothing, gracePeriodSeconds=nothing, orphanDependents=nothing, propagationPolicy=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "DELETE", IoK8sApimachineryPkgApisMetaV1Status, "/apis/admissionregistration.k8s.io/v1beta1/mutatingwebhookconfigurations/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "gracePeriodSeconds", gracePeriodSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "orphanDependents", orphanDependents)  # type Bool
    Swagger.set_param(_ctx.query, "propagationPolicy", propagationPolicy)  # type String
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    return _ctx
end

"""

delete a MutatingWebhookConfiguration
Param: name::String (required)
Param: pretty::String
Param: body::IoK8sApimachineryPkgApisMetaV1DeleteOptions
Param: dryRun::String
Param: gracePeriodSeconds::Int32
Param: orphanDependents::Bool
Param: propagationPolicy::String
Return: IoK8sApimachineryPkgApisMetaV1Status
"""
function deleteAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, name::String; pretty=nothing, body=nothing, dryRun=nothing, gracePeriodSeconds=nothing, orphanDependents=nothing, propagationPolicy=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_deleteAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api, name; pretty=pretty, body=body, dryRun=dryRun, gracePeriodSeconds=gracePeriodSeconds, orphanDependents=orphanDependents, propagationPolicy=propagationPolicy, _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function deleteAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, response_stream::Channel, name::String; pretty=nothing, body=nothing, dryRun=nothing, gracePeriodSeconds=nothing, orphanDependents=nothing, propagationPolicy=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_deleteAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api, name; pretty=pretty, body=body, dryRun=dryRun, gracePeriodSeconds=gracePeriodSeconds, orphanDependents=orphanDependents, propagationPolicy=propagationPolicy, _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

function _swaggerinternal_deleteAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, name::String; pretty=nothing, body=nothing, dryRun=nothing, gracePeriodSeconds=nothing, orphanDependents=nothing, propagationPolicy=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "DELETE", IoK8sApimachineryPkgApisMetaV1Status, "/apis/admissionregistration.k8s.io/v1beta1/validatingwebhookconfigurations/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "gracePeriodSeconds", gracePeriodSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "orphanDependents", orphanDependents)  # type Bool
    Swagger.set_param(_ctx.query, "propagationPolicy", propagationPolicy)  # type String
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    return _ctx
end

"""

delete a ValidatingWebhookConfiguration
Param: name::String (required)
Param: pretty::String
Param: body::IoK8sApimachineryPkgApisMetaV1DeleteOptions
Param: dryRun::String
Param: gracePeriodSeconds::Int32
Param: orphanDependents::Bool
Param: propagationPolicy::String
Return: IoK8sApimachineryPkgApisMetaV1Status
"""
function deleteAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, name::String; pretty=nothing, body=nothing, dryRun=nothing, gracePeriodSeconds=nothing, orphanDependents=nothing, propagationPolicy=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_deleteAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api, name; pretty=pretty, body=body, dryRun=dryRun, gracePeriodSeconds=gracePeriodSeconds, orphanDependents=orphanDependents, propagationPolicy=propagationPolicy, _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function deleteAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, response_stream::Channel, name::String; pretty=nothing, body=nothing, dryRun=nothing, gracePeriodSeconds=nothing, orphanDependents=nothing, propagationPolicy=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_deleteAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api, name; pretty=pretty, body=body, dryRun=dryRun, gracePeriodSeconds=gracePeriodSeconds, orphanDependents=orphanDependents, propagationPolicy=propagationPolicy, _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

function _swaggerinternal_getAdmissionregistrationV1beta1APIResources(_api::AdmissionregistrationV1beta1Api; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApimachineryPkgApisMetaV1APIResourceList, "/apis/admissionregistration.k8s.io/v1beta1/", ["BearerToken"])
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"] : [_mediaType])
    return _ctx
end

"""

get available resources
Return: IoK8sApimachineryPkgApisMetaV1APIResourceList
"""
function getAdmissionregistrationV1beta1APIResources(_api::AdmissionregistrationV1beta1Api; _mediaType=nothing)
    _ctx = _swaggerinternal_getAdmissionregistrationV1beta1APIResources(_api; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function getAdmissionregistrationV1beta1APIResources(_api::AdmissionregistrationV1beta1Api, response_stream::Channel; _mediaType=nothing)
    _ctx = _swaggerinternal_getAdmissionregistrationV1beta1APIResources(_api; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

function _swaggerinternal_listAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api; pretty=nothing, allowWatchBookmarks=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiAdmissionregistrationV1beta1MutatingWebhookConfigurationList, "/apis/admissionregistration.k8s.io/v1beta1/mutatingwebhookconfigurations", ["BearerToken"])
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "allowWatchBookmarks", allowWatchBookmarks)  # type Bool
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf", "application/json;stream=watch", "application/vnd.kubernetes.protobuf;stream=watch"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    return _ctx
end

"""

list or watch objects of kind MutatingWebhookConfiguration
Param: pretty::String
Param: allowWatchBookmarks::Bool
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApiAdmissionregistrationV1beta1MutatingWebhookConfigurationList
"""
function listAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api; pretty=nothing, allowWatchBookmarks=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_listAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api; pretty=pretty, allowWatchBookmarks=allowWatchBookmarks, __continue__=__continue__, fieldSelector=fieldSelector, labelSelector=labelSelector, limit=limit, resourceVersion=resourceVersion, timeoutSeconds=timeoutSeconds, watch=watch, _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function listAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, response_stream::Channel; pretty=nothing, allowWatchBookmarks=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_listAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api; pretty=pretty, allowWatchBookmarks=allowWatchBookmarks, __continue__=__continue__, fieldSelector=fieldSelector, labelSelector=labelSelector, limit=limit, resourceVersion=resourceVersion, timeoutSeconds=timeoutSeconds, watch=watch, _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

function _swaggerinternal_listAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api; pretty=nothing, allowWatchBookmarks=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiAdmissionregistrationV1beta1ValidatingWebhookConfigurationList, "/apis/admissionregistration.k8s.io/v1beta1/validatingwebhookconfigurations", ["BearerToken"])
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "allowWatchBookmarks", allowWatchBookmarks)  # type Bool
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf", "application/json;stream=watch", "application/vnd.kubernetes.protobuf;stream=watch"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    return _ctx
end

"""

list or watch objects of kind ValidatingWebhookConfiguration
Param: pretty::String
Param: allowWatchBookmarks::Bool
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApiAdmissionregistrationV1beta1ValidatingWebhookConfigurationList
"""
function listAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api; pretty=nothing, allowWatchBookmarks=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_listAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api; pretty=pretty, allowWatchBookmarks=allowWatchBookmarks, __continue__=__continue__, fieldSelector=fieldSelector, labelSelector=labelSelector, limit=limit, resourceVersion=resourceVersion, timeoutSeconds=timeoutSeconds, watch=watch, _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function listAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, response_stream::Channel; pretty=nothing, allowWatchBookmarks=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_listAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api; pretty=pretty, allowWatchBookmarks=allowWatchBookmarks, __continue__=__continue__, fieldSelector=fieldSelector, labelSelector=labelSelector, limit=limit, resourceVersion=resourceVersion, timeoutSeconds=timeoutSeconds, watch=watch, _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

function _swaggerinternal_patchAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, force=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PATCH", IoK8sApiAdmissionregistrationV1beta1MutatingWebhookConfiguration, "/apis/admissionregistration.k8s.io/v1beta1/mutatingwebhookconfigurations/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "fieldManager", fieldManager)  # type String
    Swagger.set_param(_ctx.query, "force", force)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json-patch+json", "application/merge-patch+json", "application/strategic-merge-patch+json", "application/apply-patch+yaml"] : [_mediaType])
    return _ctx
end

"""

partially update the specified MutatingWebhookConfiguration
Param: name::String (required)
Param: body::IoK8sApimachineryPkgApisMetaV1Patch (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Param: force::Bool
Return: IoK8sApiAdmissionregistrationV1beta1MutatingWebhookConfiguration
"""
function patchAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, force=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_patchAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api, name, body; pretty=pretty, dryRun=dryRun, fieldManager=fieldManager, force=force, _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function patchAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, response_stream::Channel, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, force=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_patchAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api, name, body; pretty=pretty, dryRun=dryRun, fieldManager=fieldManager, force=force, _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

function _swaggerinternal_patchAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, force=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PATCH", IoK8sApiAdmissionregistrationV1beta1ValidatingWebhookConfiguration, "/apis/admissionregistration.k8s.io/v1beta1/validatingwebhookconfigurations/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "fieldManager", fieldManager)  # type String
    Swagger.set_param(_ctx.query, "force", force)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json-patch+json", "application/merge-patch+json", "application/strategic-merge-patch+json", "application/apply-patch+yaml"] : [_mediaType])
    return _ctx
end

"""

partially update the specified ValidatingWebhookConfiguration
Param: name::String (required)
Param: body::IoK8sApimachineryPkgApisMetaV1Patch (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Param: force::Bool
Return: IoK8sApiAdmissionregistrationV1beta1ValidatingWebhookConfiguration
"""
function patchAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, force=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_patchAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api, name, body; pretty=pretty, dryRun=dryRun, fieldManager=fieldManager, force=force, _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function patchAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, response_stream::Channel, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, force=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_patchAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api, name, body; pretty=pretty, dryRun=dryRun, fieldManager=fieldManager, force=force, _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

function _swaggerinternal_readAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, name::String; pretty=nothing, exact=nothing, __export__=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiAdmissionregistrationV1beta1MutatingWebhookConfiguration, "/apis/admissionregistration.k8s.io/v1beta1/mutatingwebhookconfigurations/{name}", ["BearerToken"])
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "exact", exact)  # type Bool
    Swagger.set_param(_ctx.query, "export", __export__)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    return _ctx
end

"""

read the specified MutatingWebhookConfiguration
Param: name::String (required)
Param: pretty::String
Param: exact::Bool
Param: __export__::Bool
Return: IoK8sApiAdmissionregistrationV1beta1MutatingWebhookConfiguration
"""
function readAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, name::String; pretty=nothing, exact=nothing, __export__=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_readAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api, name; pretty=pretty, exact=exact, __export__=__export__, _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function readAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, response_stream::Channel, name::String; pretty=nothing, exact=nothing, __export__=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_readAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api, name; pretty=pretty, exact=exact, __export__=__export__, _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

function _swaggerinternal_readAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, name::String; pretty=nothing, exact=nothing, __export__=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiAdmissionregistrationV1beta1ValidatingWebhookConfiguration, "/apis/admissionregistration.k8s.io/v1beta1/validatingwebhookconfigurations/{name}", ["BearerToken"])
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "exact", exact)  # type Bool
    Swagger.set_param(_ctx.query, "export", __export__)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    return _ctx
end

"""

read the specified ValidatingWebhookConfiguration
Param: name::String (required)
Param: pretty::String
Param: exact::Bool
Param: __export__::Bool
Return: IoK8sApiAdmissionregistrationV1beta1ValidatingWebhookConfiguration
"""
function readAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, name::String; pretty=nothing, exact=nothing, __export__=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_readAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api, name; pretty=pretty, exact=exact, __export__=__export__, _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function readAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, response_stream::Channel, name::String; pretty=nothing, exact=nothing, __export__=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_readAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api, name; pretty=pretty, exact=exact, __export__=__export__, _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

function _swaggerinternal_replaceAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PUT", IoK8sApiAdmissionregistrationV1beta1MutatingWebhookConfiguration, "/apis/admissionregistration.k8s.io/v1beta1/mutatingwebhookconfigurations/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "fieldManager", fieldManager)  # type String
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    return _ctx
end

"""

replace the specified MutatingWebhookConfiguration
Param: name::String (required)
Param: body::IoK8sApiAdmissionregistrationV1beta1MutatingWebhookConfiguration (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Return: IoK8sApiAdmissionregistrationV1beta1MutatingWebhookConfiguration
"""
function replaceAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_replaceAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api, name, body; pretty=pretty, dryRun=dryRun, fieldManager=fieldManager, _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function replaceAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, response_stream::Channel, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_replaceAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api, name, body; pretty=pretty, dryRun=dryRun, fieldManager=fieldManager, _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

function _swaggerinternal_replaceAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PUT", IoK8sApiAdmissionregistrationV1beta1ValidatingWebhookConfiguration, "/apis/admissionregistration.k8s.io/v1beta1/validatingwebhookconfigurations/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "fieldManager", fieldManager)  # type String
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    return _ctx
end

"""

replace the specified ValidatingWebhookConfiguration
Param: name::String (required)
Param: body::IoK8sApiAdmissionregistrationV1beta1ValidatingWebhookConfiguration (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Return: IoK8sApiAdmissionregistrationV1beta1ValidatingWebhookConfiguration
"""
function replaceAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_replaceAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api, name, body; pretty=pretty, dryRun=dryRun, fieldManager=fieldManager, _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function replaceAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, response_stream::Channel, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_replaceAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api, name, body; pretty=pretty, dryRun=dryRun, fieldManager=fieldManager, _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

function _swaggerinternal_watchAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, name::String; allowWatchBookmarks=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApimachineryPkgApisMetaV1WatchEvent, "/apis/admissionregistration.k8s.io/v1beta1/watch/mutatingwebhookconfigurations/{name}", ["BearerToken"])
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "allowWatchBookmarks", allowWatchBookmarks)  # type Bool
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf", "application/json;stream=watch", "application/vnd.kubernetes.protobuf;stream=watch"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    return _ctx
end

"""

watch changes to an object of kind MutatingWebhookConfiguration. deprecated: use the 'watch' parameter with a list operation instead, filtered to a single item with the 'fieldSelector' parameter.
Param: name::String (required)
Param: allowWatchBookmarks::Bool
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: pretty::String
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApimachineryPkgApisMetaV1WatchEvent
"""
function watchAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, name::String; allowWatchBookmarks=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_watchAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api, name; allowWatchBookmarks=allowWatchBookmarks, __continue__=__continue__, fieldSelector=fieldSelector, labelSelector=labelSelector, limit=limit, pretty=pretty, resourceVersion=resourceVersion, timeoutSeconds=timeoutSeconds, watch=watch, _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function watchAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, response_stream::Channel, name::String; allowWatchBookmarks=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_watchAdmissionregistrationV1beta1MutatingWebhookConfiguration(_api, name; allowWatchBookmarks=allowWatchBookmarks, __continue__=__continue__, fieldSelector=fieldSelector, labelSelector=labelSelector, limit=limit, pretty=pretty, resourceVersion=resourceVersion, timeoutSeconds=timeoutSeconds, watch=watch, _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

function _swaggerinternal_watchAdmissionregistrationV1beta1MutatingWebhookConfigurationList(_api::AdmissionregistrationV1beta1Api; allowWatchBookmarks=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApimachineryPkgApisMetaV1WatchEvent, "/apis/admissionregistration.k8s.io/v1beta1/watch/mutatingwebhookconfigurations", ["BearerToken"])
    Swagger.set_param(_ctx.query, "allowWatchBookmarks", allowWatchBookmarks)  # type Bool
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf", "application/json;stream=watch", "application/vnd.kubernetes.protobuf;stream=watch"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    return _ctx
end

"""

watch individual changes to a list of MutatingWebhookConfiguration. deprecated: use the 'watch' parameter with a list operation instead.
Param: allowWatchBookmarks::Bool
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: pretty::String
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApimachineryPkgApisMetaV1WatchEvent
"""
function watchAdmissionregistrationV1beta1MutatingWebhookConfigurationList(_api::AdmissionregistrationV1beta1Api; allowWatchBookmarks=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_watchAdmissionregistrationV1beta1MutatingWebhookConfigurationList(_api; allowWatchBookmarks=allowWatchBookmarks, __continue__=__continue__, fieldSelector=fieldSelector, labelSelector=labelSelector, limit=limit, pretty=pretty, resourceVersion=resourceVersion, timeoutSeconds=timeoutSeconds, watch=watch, _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function watchAdmissionregistrationV1beta1MutatingWebhookConfigurationList(_api::AdmissionregistrationV1beta1Api, response_stream::Channel; allowWatchBookmarks=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_watchAdmissionregistrationV1beta1MutatingWebhookConfigurationList(_api; allowWatchBookmarks=allowWatchBookmarks, __continue__=__continue__, fieldSelector=fieldSelector, labelSelector=labelSelector, limit=limit, pretty=pretty, resourceVersion=resourceVersion, timeoutSeconds=timeoutSeconds, watch=watch, _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

function _swaggerinternal_watchAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, name::String; allowWatchBookmarks=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApimachineryPkgApisMetaV1WatchEvent, "/apis/admissionregistration.k8s.io/v1beta1/watch/validatingwebhookconfigurations/{name}", ["BearerToken"])
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "allowWatchBookmarks", allowWatchBookmarks)  # type Bool
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf", "application/json;stream=watch", "application/vnd.kubernetes.protobuf;stream=watch"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    return _ctx
end

"""

watch changes to an object of kind ValidatingWebhookConfiguration. deprecated: use the 'watch' parameter with a list operation instead, filtered to a single item with the 'fieldSelector' parameter.
Param: name::String (required)
Param: allowWatchBookmarks::Bool
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: pretty::String
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApimachineryPkgApisMetaV1WatchEvent
"""
function watchAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, name::String; allowWatchBookmarks=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_watchAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api, name; allowWatchBookmarks=allowWatchBookmarks, __continue__=__continue__, fieldSelector=fieldSelector, labelSelector=labelSelector, limit=limit, pretty=pretty, resourceVersion=resourceVersion, timeoutSeconds=timeoutSeconds, watch=watch, _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function watchAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api::AdmissionregistrationV1beta1Api, response_stream::Channel, name::String; allowWatchBookmarks=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_watchAdmissionregistrationV1beta1ValidatingWebhookConfiguration(_api, name; allowWatchBookmarks=allowWatchBookmarks, __continue__=__continue__, fieldSelector=fieldSelector, labelSelector=labelSelector, limit=limit, pretty=pretty, resourceVersion=resourceVersion, timeoutSeconds=timeoutSeconds, watch=watch, _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

function _swaggerinternal_watchAdmissionregistrationV1beta1ValidatingWebhookConfigurationList(_api::AdmissionregistrationV1beta1Api; allowWatchBookmarks=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApimachineryPkgApisMetaV1WatchEvent, "/apis/admissionregistration.k8s.io/v1beta1/watch/validatingwebhookconfigurations", ["BearerToken"])
    Swagger.set_param(_ctx.query, "allowWatchBookmarks", allowWatchBookmarks)  # type Bool
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf", "application/json;stream=watch", "application/vnd.kubernetes.protobuf;stream=watch"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    return _ctx
end

"""

watch individual changes to a list of ValidatingWebhookConfiguration. deprecated: use the 'watch' parameter with a list operation instead.
Param: allowWatchBookmarks::Bool
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: pretty::String
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApimachineryPkgApisMetaV1WatchEvent
"""
function watchAdmissionregistrationV1beta1ValidatingWebhookConfigurationList(_api::AdmissionregistrationV1beta1Api; allowWatchBookmarks=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_watchAdmissionregistrationV1beta1ValidatingWebhookConfigurationList(_api; allowWatchBookmarks=allowWatchBookmarks, __continue__=__continue__, fieldSelector=fieldSelector, labelSelector=labelSelector, limit=limit, pretty=pretty, resourceVersion=resourceVersion, timeoutSeconds=timeoutSeconds, watch=watch, _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function watchAdmissionregistrationV1beta1ValidatingWebhookConfigurationList(_api::AdmissionregistrationV1beta1Api, response_stream::Channel; allowWatchBookmarks=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_watchAdmissionregistrationV1beta1ValidatingWebhookConfigurationList(_api; allowWatchBookmarks=allowWatchBookmarks, __continue__=__continue__, fieldSelector=fieldSelector, labelSelector=labelSelector, limit=limit, pretty=pretty, resourceVersion=resourceVersion, timeoutSeconds=timeoutSeconds, watch=watch, _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

export createAdmissionregistrationV1beta1MutatingWebhookConfiguration, createAdmissionregistrationV1beta1ValidatingWebhookConfiguration, deleteAdmissionregistrationV1beta1CollectionMutatingWebhookConfiguration, deleteAdmissionregistrationV1beta1CollectionValidatingWebhookConfiguration, deleteAdmissionregistrationV1beta1MutatingWebhookConfiguration, deleteAdmissionregistrationV1beta1ValidatingWebhookConfiguration, getAdmissionregistrationV1beta1APIResources, listAdmissionregistrationV1beta1MutatingWebhookConfiguration, listAdmissionregistrationV1beta1ValidatingWebhookConfiguration, patchAdmissionregistrationV1beta1MutatingWebhookConfiguration, patchAdmissionregistrationV1beta1ValidatingWebhookConfiguration, readAdmissionregistrationV1beta1MutatingWebhookConfiguration, readAdmissionregistrationV1beta1ValidatingWebhookConfiguration, replaceAdmissionregistrationV1beta1MutatingWebhookConfiguration, replaceAdmissionregistrationV1beta1ValidatingWebhookConfiguration, watchAdmissionregistrationV1beta1MutatingWebhookConfiguration, watchAdmissionregistrationV1beta1MutatingWebhookConfigurationList, watchAdmissionregistrationV1beta1ValidatingWebhookConfiguration, watchAdmissionregistrationV1beta1ValidatingWebhookConfigurationList


text:
# Loads all files
module EffectiveWaves

# Here are the main exported functions and types. Note there are other exported functions and types in files such as "effective_wave/export.jl" and "discrete_wave/export.jl"
export  EffectivePlaneWaveMode, EffectiveRegularWaveMode, ScatteringCoefficientsField

export  DiscretePlaneWaveMode
export  MatchPlaneWaveMode # a combination of the Discrete and Effective modes
export  Material, Specie, Species, SetupSymmetry, number_density, volume_fraction
export  hole_correction_pair_correlation, gls_pair_radial_fun, pair_radial_fun, smooth_pair_corr_distance

# for MatchPlaneWaveMode
export  match_error, x_mesh_match

# for effective waves
export wavenumbers, wavenumber, asymptotic_monopole_wavenumbers, eigenvectors, convert_eigenvector_basis, eigenvector_length
export WaveModes, WaveMode, wavemode_wienerhopf
export solve_boundary_condition, scattering_field, material_scattering_coefficients, material_scattered_waves

export dispersion_equation, dispersion_complex, eigensystem # supplies a matrix used for the disperision equation and effective eignvectors

export scattering_amplitudes_average

export  reflection_coefficient, reflection_coefficients, reflection_transmission_coefficients, planewave_amplitudes
export  effective_medium

# List of shorthand for some materials
export  Brick, IronArmco, LeadAnnealed, RubberGum, FusedSilica, GlassPyrex,
        ClayRock, WaterDistilled, Glycerol, Hexadecane, Acetone, Benzene,
        Nitrobenzene, OliveOil, SodiumNitrate, AirDry,
        LimeStone, Clay, Calcite, SilicaQuartz

import Base.isequal, Base.(==), Base.zero
import SpecialFunctions: besselj, hankelh1
import StaticArrays: SVector
import Statistics: mean, std

import IterTools: groupby

using Reexport
@reexport using MultipleScattering

import MultipleScattering: RegularSource, Acoustic

using RecipesBase, OffsetArrays, LinearAlgebra

# Heavy package
using Optim: optimize, Optim, FixedParameters, Options, LBFGS, Fminbox, NelderMead
# Below doesn't work on Julia 1.1
# @reexport using Optim: optimize, FixedParameters, Options, LBFGS, Fminbox, NelderMead
import Optim: simplexer

# Heavy package
# using ApproxFun: ApproxFun.(..), Fun, Segment, Domain, Chebyshev, DefiniteIntegral, LowRankFun, Interval

using Interpolations: interpolate, BSpline, Cubic, Line, OnGrid, scale
using HCubature: hcubature, hquadrature
using ClassicalOrthogonalPolynomials: Legendre

using MDBM

include("material_types.jl")
include("statistics.jl")
include("wave_types.jl")
include("specialfunctions.jl")

include("effective_wave/export.jl")
include("acoustics/export.jl")

include("match_waves/match_waves.jl")
include("match_waves/match_arrays.jl")
include("match_waves/reflection.jl")

include("../plot/graphics.jl")
include("../plot/plot.jl")

end # module


text:
# Author: Ali Siahkoohi, alisk@gatech.edu
# Date: September 2020
# Copyright: Georgia Institute of Technology, 2020

export update!, pSGLD

import Flux.Optimise: update!
using Flux: Params

const ϵ = 1e-8

    """
    pSGLD(η = 0.001, ρ = 0.99)

    Optimizer using the [pSGLD](ttps://arxiv.org/pdf/1512.07666.pdf) algorithm.
    Built on the Flux RMSprop implementation at:
    https://github.com/FluxML/Flux.jl/blob/master/src/optimise/optimisers.jl#L137)

 *Input*:

 - Learning rate (`η`): Amount by which gradients are discounted before updating
                        the weights.
 - `Momentum (`ρ`): Controls the acceleration of gradient descent in the
                    prominent direction, in effect dampening oscillations.
    """

mutable struct pSGLD
  eta::Float64
  rho::Float64
  acc::IdDict
end

pSGLD(η = 0.001, ρ = 0.99) = pSGLD(η, ρ, IdDict())

function apply!(o::pSGLD, x, Δ)
    η, ρ = o.eta, o.rho
    acc = get!(o.acc, x, zero(x))::typeof(x)
    @. acc = ρ * acc + (1 - ρ) * Δ^2
    @. Δ *= η / (√acc + ϵ)
    n = randn(size(Δ))
    if typeof(n) == Array{Float64,0} || typeof(n) == Array{Float32,0}
        n = n[1]
    end
    @. Δ += convert(typeof(Δ), n).*√(2*η / (√acc + ϵ))
    return @. Δ
end

function update!(opt::pSGLD, x, x̄)
    x .-= apply!(opt, x, x̄)
end

function update!(opt::pSGLD, xs::Params, gs)
    for x in xs
        gs[x] == nothing && continue
        update!(opt, x, gs[x])
    end
end


text:
const adjectives = [
	"groundbreaking"
	"important"
	"novel"
	"fun"
	"interesting"
	"fascinating"
	"surprising"
	"remarkable"
	"wonderful"
	"stunning"
]

const nouns = [
	"discovery"
	"experiment"
	"story"
	"journal"
	"notebook"
	"revelation"
	"computation"
	"creation"
	"analysis"
	"invention"
	"blueprint"
	"report"
]

function cutename()
    titlecase(rand(adjectives)) * " " * rand(nouns)
end

"""
Return `base` * `suffix` if the file does not exist yet.

If it does, return `base * sep * string(n) * suffix`, where `n` is the smallest natural number such that the file is new. (no 0 is not a natural number you snake)
"""
function numbered_until_new(base::AbstractString; sep=" ", suffix=".jl", create_file=true)
    chosen = base * suffix
    n = 1
    while isfile(chosen)
        n += 1
        chosen = base * sep * string(n) * suffix
	end
	if create_file
		touch(chosen)
	end
    chosen
end

"Like `cp` except we create the file manually (to fix permission issues). (It's not plagiarism if you use this function to copy homework.)"
function readwrite(from::AbstractString, to::AbstractString)
    write(to, read(from, String))
end

function tryexpanduser(path)
	try
		expanduser(path)
	catch ex
		path
	end
end

tamepath = abspath ∘ tryexpanduser


text:
tests = [
         "basic"]

for t in tests
    test_fn = joinpath("test", "$t.jl")
    println(" * $test_fn")
    include(test_fn)
end


text:
function miuntesTillNext(a_now::Int, busId::Int)
    #println(a_now, ", " , busId)
    timeSinceLast = a_now % busId
    #println("timeSinceLast=", timeSinceLast)
    a_lastDep = (a_now ÷ busId) * busId
    #println("a_lastDep=", a_lastDep)
    a_nextDep = a_lastDep + busId
    #println("a_nextDep=", a_nextDep)
    tillNext = a_nextDep - a_now
    #println("tillNext=", tillNext)
    return tillNext
end

function findEarliest(inputfile)
    lines = readlines(inputfile)
    now::Int = parse(Int,lines[1])
    idsStirng = lines[2]
    ids:: Vector{Int} = []
    for idSubString in split(idsStirng, ',')
        idString = String(idSubString)
        if idString != "x"
            push!(ids, parse(Int, idString))
        end
    end
    candidates = Dict()
    for id in ids
        candidates[id] = miuntesTillNext(now, id)
    end
    min = findmin(candidates)
    println(min, " " , min[1]*min[2])
end

findEarliest("data.txt")


text:
# File used for plot the posterior dist for MCWM DA and ADA

using Plots
using PyPlot
using KernelDensity
using Distributions
using DataFrames

remove_missing_values(x) = reshape(collect(skipmissing(x)),7,:)

# load data for MCWM

problem = "real data"
problem = "sim data small problem"

if problem == "real data"

  jobname_mcwm = "gp_training_7_par_lunarc_new_data_4_coresnew_data"
  jobname_da = "_dagpest7new_datada_gp_mcmc"
  jobname_ada = "_dagpest7new_dataada_gp_mcmc_dt"

else# problem == "sim data small problem"

  jobname_mcwm = "gp_training_7_par_lunarc_simdata_4_coressimdata"
  jobname_da = "_dagpest7simdatada_gp_mcmc"
  jobname_ada = "_dagpest7simdataada_gp_mcmc_dt"

end

if problem == "real data"
    plot_theta_true = false
else
    plot_theta_true = true
end

data_res = convert(Array,readtable("DWPSDE model/Results/"*problem*"/output_res"*jobname_mcwm*".csv"))

M, N = size(data_res)

data_param = convert(Array,readtable("DWPSDE model/Results/"*problem*"/output_param"*jobname_mcwm*".csv"))

theta_true = data_param[1:N-2]
burn_in = Int64(data_param[N-2+1])

data_prior_dist = convert(Array,readtable("DWPSDE model/Results/"*problem*"/output_prior_dist"*jobname_mcwm*".csv"))

data_prior_dist_type = convert(Array,readtable("DWPSDE model/Results/"*problem*"/output_prior_dist_type"*jobname_mcwm*".csv"))
data_prior_dist_type = data_prior_dist_type[2]

Z = convert(Array,readtable("DWPSDE model/Results/"*problem*"/data_used"*jobname_mcwm*".csv"))
Z = Z[:,1]

Theta_mcwm = remove_missing_values(data_res[burn_in:end,1:N-2]') # stor data in column-major order

burn_in = 1

data_res = convert(Array,readtable("DWPSDE model/Results/"*problem*"/output_res"*jobname_da*".csv"))
M, N = size(data_res)
Theta_da = remove_missing_values(data_res[burn_in:end,1:N-2]') # stor data in column-major order

data_res = convert(Array,readtable("DWPSDE model/Results/"*problem*"/output_res"*jobname_ada*".csv"))
M, N = size(data_res)
Theta_ada = remove_missing_values(data_res[burn_in:end,1:N-2]') # stor data in column-major order

if N == 6
    title_vec_log = [ L"$\log \kappa$"; L"$\log \gamma$"; L"$\log c$"; L"$\log d$"]
    title_vec = [ L"$\kappa$"; L"Gamma"; "c"; "d"]
elseif N == 4
    title_vec_log = [ L"$\log c$"; L"$\log d$" ]
    title_vec = [ "c"; "d" ];
elseif N == 5
    title_vec_log = [ L"$\log A$";L"$\log c$"; L"$\log d$" ]
    title_vec = [ "A";"c"; "d" ]
elseif N == 8
    title_vec_log = [ L"$\log A$"; L"$\log c$"; L"$\log d$"; L"$\log p_1$"; L"$\log p_2$"; L"$\log sigma$"]
    title_vec = [  "A    "; "c    "; "d    "; "p_1  "; "p_1  "; "sigma"]
elseif N == 7
    title_vec_log = [ L"$\log \kappa$"; L"$\log Gamma$"; L"$\log c$"; L"$\log d$"; L"$\log sigma$"];
    title_vec = [ L"$\kappa$"; "Gamma"; "c"; "d"; "sigma"]
elseif N == 9
    title_vec_log = [ L"$\log \kappa$"; L"$\log \gamma$"; L"$\log c$"; L"$\log d$"; L"$\log p_1$"; L"$\log p_2$"; L"$\log \sigma$"]
    title_vec = [  L"$\kappa$"; L"$\gamma$"; L"$c$"; L"$d$"; L"$p_1$"; L"$p_1$"; L"$\sigma$"]
else
    title_vec_log = [ L"$\log \kappa$"; L"$\log Gamma$"; L"$\log A$"; L"$\log c$"; L"$\log d$"; L"$\log g$"; L"$\log p_1$"; L"$\log p_2$"; L"$\log sigma$"]
    title_vec = [ L"$\kappa$"; "Gamma"; "A"; "c"; "d"; "g"; "p_1"; "p_1"; "sigma"]
end

# text and lable size
text_size = 25
label_size = 20

(1:N-2)[1]

# plot posterior
#PyPlot.figure()
for i = (1:N-2) # (1:N-2)[j] to only plot figure j
    #PyPlot.subplot(N-2,1,i)
    PyPlot.figure(figsize=(10,10))
    ax = axes()
    h_mcwm = kde(Theta_mcwm[i,:])
    PyPlot.plot(h_mcwm.x,h_mcwm.density, "b")
    h_da = kde(Theta_da[i,:])
    PyPlot.plot(h_da.x,h_da.density, "r")
    h_ada = kde(Theta_ada[i,:])
    PyPlot.plot(h_ada.x,h_ada.density, "r--")

    if plot_theta_true
        PyPlot.plot((theta_true[i], theta_true[i]), (0, maximum([maximum(h_mcwm.density);maximum(h_da.density); maximum(h_ada.density)])), "k")
    end

    if data_prior_dist_type == "Uniform"
        error("Uniform priors are not not implemented.")
    elseif data_prior_dist_type == "Normal"
        #x_grid = (data_prior_dist[i,1]-3*data_prior_dist[i,2]):0.001:(data_prior_dist[i,1]+3*data_prior_dist[i,2])
        x_grid = (minimum(h_mcwm.x)-0.1*data_prior_dist[i,2]):0.001:(maximum(h_mcwm.x)+0.1*data_prior_dist[i,2])

        PyPlot.plot(x_grid, pdf(Normal(data_prior_dist[i,1],data_prior_dist[i,2]), x_grid) ,"g")
    end

    #PyPlot.xlabel(title_vec_log[i],fontsize=text_size)
    #PyPlot.ylabel(L"Density",fontsize=text_size)
    ax[:tick_params]("both",labelsize = label_size)

end

# plot data
PyPlot.figure(figsize=(12,10))
ax = axes()
PyPlot.plot(1:length(Z),Z)
#PyPlot.xlabel("Index")
ax[:tick_params]("both",labelsize = label_size)

# plot hist of data
PyPlot.figure(figsize=(10,10))
ax = axes()
PyPlot.plt[:hist](Z,50)
#PyPlot.ylabel("Freq.", fontsize=text_size)
ax[:tick_params]("both",labelsize = label_size)

max_stars_repo_name: SamuelWiqvist/adamcmcpaper

max_issues_repo_name: SamuelWiqvist/adamcmcpaper

max_forks_repo_name: SamuelWiqvist/adamcmcpaper


text:
for (T, N) ∈ ((:MPO, 4), (:MPS, 3))
    CuT = Symbol(:Cu, T)
    AT = Symbol(:Abstract, T)
    @eval begin
        export $CuT, $T

        struct $CuT{T <: Number} <: $AT{T}
            tensors::Vector{CuArray{T, $N}}
        end

        $CuT(::Type{T}, L::Int) where {T} = $CuT(Vector{CuArray{T, $N}}(undef, L))
        $CuT(L::Int) = $CuT(Float32, L)

        Base.copy(a::$CuT) = $CuT(copy(a.tensors))

        $T(A::$CuT) = $T([Array(arr) for arr in A.tensors])
        $CuT(A::$T) = $CuT([cu(arr) for arr in A.tensors])
    end
end
@inline CuMPS(A::AbstractArray) = CuMPS(cu(A), :right)
@inline CuMPS(A::AbstractArray, s::Symbol, args...) = CuMPS(cu(A), Val(s), typemax(Int), args...)
@inline CuMPS(A::AbstractArray, s::Symbol, Dcut::Int, args...) = CuMPS(cu(A), Val(s), Dcut, args...)
@inline CuMPS(A::AbstractArray, ::Val{:right}, Dcut::Int, args...) = _left_sweep_SVD(CuMPS, cu(A), Dcut, args...)
@inline CuMPS(A::AbstractArray, ::Val{:left}, Dcut::Int, args...) = _right_sweep_SVD(CuMPS, cu(A), Dcut, args...)

function CUDA.randn(::Type{CuMPS{T}}, L::Int, D::Int, d::Int) where {T}
    ψ = CuMPS(L)
    ψ[1] = CUDA.randn(T, 1, d, D)
    for i ∈ 2:(L-1)
        ψ[i] = CUDA.randn(T, D, d, D)
    end
    ψ[end] = CUDA.randn(T, D, d, 1)
    ψ
end

CUDA.randn(::Type{CuMPS}, args...) = CUDA.randn(CuMPS{Float32}, args...)

function CUDA.randn(::Type{CuMPO{T}}, L::Int, D::Int, d::Int) where {T}
    ψ = CUDA.randn(CuMPS{T}, L, D, d^2)
    CuMPO(ψ)
end

CUDA.randn(::Type{CuMPO}, args...) = CUDA.randn(CuMPO{Float32}, args...)

CuMPS(states::Vector{CuVector{T}}) where {T <: Number} = CuMPS(
    [reshape(copy(v), (1, length(v), 1)) for v ∈ states]
)

function is_left_normalized(ψ::CuMPS)
    for i ∈ eachindex(ψ)
        A = ψ[i]
        DD = size(A, 3)

        @cutensor Id[x, y] := conj(A[α, σ, x]) * A[α, σ, y] order = (α, σ)
        if norm(cu(I(DD)) - Id) > 1e-6 return false end
    end
    true
end

function is_right_normalized(ϕ::CuMPS)
    for i ∈ eachindex(ϕ)
        B = ϕ[i]
        DD = size(B, 1)

        @cutensor Id[x, y] := B[x, σ, α] * conj(B[y, σ, α]) order = (α, σ)
        if norm(cu(I(DD)) - Id) > 1e-6 return false end
    end
    true
end

function _truncate_svd(F::CuSVD, Dcut::Int)
    U, Σ, V = F
    c = min(Dcut, size(U, 2))
    U = U[:, 1:c]
    Σ = Σ[1:c]
    V = V[:, 1:c]
    U, Σ, V
end

function _truncate_qr(F::CuQR, Dcut::Int)
    Q, R = F
    Q = CuMatrix(Q)
    c = min(Dcut, size(Q, 2))
    Q = Q[:, 1:c]
    R = R[1:c, :]
    _qr_fix!(Q, R)
end

LinearAlgebra.svd(M::CuMatrix, Dcut::Int, args...) = _truncate_svd(CUDA.svd(M), Dcut)


text:
include("godunov_new.jl")
using .Godunov
using Plots
fig = Plots.plot()

# Physical parameters:
α = 1.0
ν = 1.0
s = 0.001

# Other params:
Nc = 40 # no of cells
tmax = 1.0e2 # max time
dt = 3.0e1 # how often to plot
tp = 0.0e0#5000 # when to start plotting

r=Godunov.ring(Nc, (α,ν,s))
Godunov.step!(r)

xh = r.Ls["Lcrit"]
x_ = (r.X_[1:end-1]+r.X_[2:end])/2.0
x2_ = 2*r.X_[end].-reverse(x_)
xx_ = cat(x_,x2_,dims=1)

#for i in 1:10
for tt in 0.0:dt:tmax
    tx = r.t; X_ = r.X_; Σ_ = r.Σ_; Φ_ = r.Φ_
    if tx ≥ tp
        ΣΣ_ = cat(Σ_,reverse(Σ_),dims=1)
        ΦΦ_ = cat(Φ_,-reverse(Φ_),dims=1)
        Plots.plot!(xx_,ΣΣ_,label="t: $tx",legend=false)#,xlim=(0,3))#:bottomright)#,title="Σ")#;legend=false)
        display(fig)
        print("time: $tx\n")
#        Plots.plot!(xx_,ΦΦ_,label=false,linestyle=:dash)#,label="t: $t",legend=:topleft)#,title="J")#;legend=false)
#        display(fig)
    end
#    for j in 1:800
        Godunov.step!(r)#,dt)
#    end
    Godunov.tstep!(r,dt)
end

tf=r.t
print("Done at t= $tf\n")

max_stars_repo_name: diakosmos/razor

max_issues_repo_name: diakosmos/razor

max_forks_repo_name: diakosmos/razor


text:
module Draw
import Plots
using Plots

function draw(_x::Array, _y::Array, _phi::Array, fig_name::Union{SubString{String},String,Nothing} = nothing)
    # s = plot(_x, _y, _phi, st = :wireframe)
    # p = contour(_x, _y, _phi)
    # q = surface(_x, _y, _phi)
    # r = plot(_x, _y, _phi, st = :heatmap)
    s = plot(_x, _y, _phi, st = :wireframe, title = "wireframe")
    p = contour(_x, _y, _phi, title = "contour")
    q = surface(_x, _y, _phi, title = "surface")
    r = plot(_x, _y, _phi, st = :heatmap, title = "heatmap")
    plot(s, p, q, r, layout = (4, 1), size = (500, 1200))
    if fig_name !== nothing
        savefig("test/image/" * fig_name * ".png")
        # savefig("test/image/double_circle_signed_distance.png")
    else
        savefig("image/tmp_signed_distance.png")
    end
end
precompile(draw, (Array, Array, Array, Union{SubString{String},Nothing}))

function draw2x2(_x::Array, _y::Array, _phi::Array, fig_name::Union{SubString{String},String,Nothing} = nothing)
    s = plot(_x, _y, _phi, st = :wireframe, title = "wireframe")
    p = contour(_x, _y, _phi, title = "contour")
    q = surface(_x, _y, _phi, title = "surface")
    r = plot(_x, _y, _phi, st = :heatmap, title = "heatmap")
    plot(s, p, q, r, layout = (2, 2), size = (1100, 800))
    if fig_name !== nothing
        savefig("test/image/2x2" * fig_name * ".png")
    else
        savefig("image/2x2tmp_signed_distance.png")
    end
end
precompile(draw2x2, (Array, Array, Array, Union{SubString{String},Nothing}))

"""
"""
function parformance_graphs(N::Array, exe_num::Array, fig_name::Union{String,Nothing} = nothing, label_name::Union{Array,Nothing} = nothing)
    (row, col) = size(exe_num)
    println(row, col)
    plot(N, exe_num[:, 1], title = "Benchmarks", label = label_name[1], legend = :topleft)
    for i = 2:col
        # plot(N, exe_num[:,i],title = "Benchmarks", label = label_name[1], legend = :topleft)
        plot!(N, exe_num[:, i], label = label_name[i])
    end
    xlabel!("Splits of fields")
    ylabel!("Processing time(sec.)")
    if fig_name !== nothing
        savefig("test/image/" * fig_name * "_performance.png")
    else
        savefig("test/image/performance.png")
    end
end
precompile(parformance_graphs, (Array, Array))
export draw, draw2x2, parformance_graphs
end

max_stars_repo_name: jabelic/senior-thesis-julia

max_issues_repo_name: jabelic/senior-thesis-julia

max_forks_repo_name: jabelic/senior-thesis-julia


text:
using Images,PyPlot

#GoL = rand(Bool,500,500)
#GoL = rand([0.0, 1.0], 500, 500)
function runGoL(GoL=nothing; runs=100, sleepTime=0.01, safeToDisk=false, showOnConsole=true, unsafe=false)
    if unsafe
        Mfilt = [1.0 for x in 1:3, y in 1:3]
    else
        Mfilt = [true true  true; true  false  true; true true true]
    end

    if GoL == nothing
        if unsafe
            GoL = rand([0.0, 1.0], 500, 500)
        else
            GoL = rand(Bool,500,500)
        end
    end

    plt[:axis]("off")
    im = plt[:imshow](GoL, interpolation="none")
    for i_gen = 1:runs
        if unsafe
	    #NOTE: convert to array of double again?
            convGoL = imfilter(GoL, Mfilt, "circular") # much, much faster! And circular :)
	    GoL = GoL .== 1.0 # convert to bool matrix
            lives2 = convGoL .== 2.0
            lives3 = convGoL .== 3.0

            twoLiveNeig =    (GoL & lives2)
            GoL = twoLiveNeig | lives3
        else
            convGoL = conv2(GoL, Mfilt)
            lives2 = convGoL .== 2
            lives3 = convGoL .== 3

            twoLiveNeig = (GoL & lives2[2:end-1,2:end-1])
            GoL = twoLiveNeig | lives3[2:end-1,2:end-1]
        end

        if safeToDisk
            imgplot = imshow(GoL, interpolation="none")
            savefig("GoLpics/gen$i_gen.png")
        end

        if showOnConsole
            im[:set_data](GoL)
            plt[:draw]()
            sleep(sleepTime)
        end
    end
end

# at the command prompt of where the files are stored
# ffmpeg -r 15 -f image2 -s 800x600 -i gen%d.png -vcodec libx264 -crf 20 CGoL.mp4

runGoL(nothing, unsafe=true)

max_stars_repo_name: Xentrics/Game-Of-Life-Julia

max_issues_repo_name: Xentrics/Game-Of-Life-Julia

max_forks_repo_name: Xentrics/Game-Of-Life-Julia


text:
function generator()
    # the Channel() function is a constructor for a channel. First it creates the channel
    # since no capacity is defined, the default is one character
    # the do-end defines an anonymous function that is scheduled by the constructor
    Channel() do channel
        # the for loop defines the task scheduled:
        # Characters are placed in the channel when it is empty. There is only room for 1 characters
        # so the task is blocked until someones takes the character from the channel
        for i in 0:5
            println("putting ",
                    Char('A' + i),
                    " into the channel\n")
            put!(channel, Char('A' + i))
        end
    end
end
# Example
# when you create generator, it puts first letter A in the channel.
# when you take A, the channel empties out and it puts B etc.
# julia> g = generator()
# putting A into the channel
# Channel{Any}(0) (1 item available)
# julia> take!(g)
# putting B' into the channel
# A
# ': ASCII/Unicode U+0041 (category Lu: Letter, uppercase)
# julia> take!(g)
# putting C' into the channel
# B
# ': ASCII/Unicode U+0042 (category Lu: Letter, uppercase)
# As the collect iterates over the channel, it pulls a letter into the array,
# and the generator puts another one into the empty channel
# julia> g = generator()

# putting A into the channel

# Channel{Any}(0) (1 item available)
# julia> collect(g)
# putting B into the channel

# putting C into the channel

# putting D into the channel

# putting E into the channel

# putting F into the channel

# 6-element Vector{Any}:
#  'A': ASCII/Unicode U+0041 (category Lu: Letter, uppercase)
#  'B': ASCII/Unicode U+0042 (category Lu: Letter, uppercase)
#  'C': ASCII/Unicode U+0043 (category Lu: Letter, uppercase)
#  'D': ASCII/Unicode U+0044 (category Lu: Letter, uppercase)
#  'E': ASCII/Unicode U+0045 (category Lu: Letter, uppercase)
#  'F': ASCII/Unicode U+0046 (category Lu: Letter, uppercase)

# server side
# copy and run in Julia terminal
# using Sockets

# @async begin
     # this is the first task which listens on port 2001
#    server = listen(2001)

#    while true
         # this waits for connection and so blocks server task
#        sock = accept(server)
         # When the client connects we block on the readline since the client hasn't written anything
#        @async while isopen(sock)
             # when the client writes to the socket this task is scheduled
            # it reads the line sent
#           line = readline(sock, keep=true)
            # uppercases read line, and sends it back to client
#           write(sock, uppercase(line))
#        end
#    end
# end

# client side
# copy and run in another Julia terminal
# julia> using Sockets
# connect to server post
# julia> clientside = connect(2001)
# TCPSocket(RawFD(22) open, 0 bytes waiting)
# we create another asnchronous task to read from the server
# since there is nothing written to the server it blocks oon readline
# julia> @async while isopen(clientside)
#            line = readline(clientside, keep=true)
#            write(stdout, line)
#        end
# Task (runnable) @0x000000011438ca90
# while the task is blocked we can write to the server
# julia> println(clientside, "Hello World")
# the readline task is now scheduled, reads the line that the server has converted to uppercase and prints in on terminal
# julia> HELLO WORLD
# julia>
# lets write another line
# julia> println(clientside, "This is cool")
# the unblocked readline task above brings us back the response
# julia> THIS IS COOL

max_stars_repo_name: FourMInfo/JuliaforBeginners

max_issues_repo_name: FourMInfo/JuliaforBeginners

max_forks_repo_name: FourMInfo/JuliaforBeginners


text:
using Documenter
using CalibrationErrors
using Literate

# define directories
const EXAMPLES = joinpath(@__DIR__, "..", "examples")
const OUTPUT = joinpath(@__DIR__, "src", "generated")

# recreate output directory
rm(OUTPUT; force=true, recursive=true)
mkpath(OUTPUT)

# generate Markdown and Jupyter notebook
for file in readdir(EXAMPLES)
    endswith(file, ".jl") || continue

    fullpath = joinpath(EXAMPLES, file)

    Literate.markdown(fullpath, OUTPUT)
    Literate.notebook(fullpath, OUTPUT)
end

makedocs(
    sitename = "CalibrationErrors.jl",
        pages = [
            "Home" => "index.md",
            "Background" => "background.md",
            "Calibration" => "calibration.md",
            "Estimators" => "estimators.md",
            "Examples" => [
                "Distribution" => "generated/distribution.md"
            ]
        ]
)

deploydocs(
    repo = "github.com/devmotion/CalibrationErrors.jl.git",
)