text:
#
#--------------------------------------#
export restrict, restrictUpper, restrictLower
#--------------------------------------#
"""
 R * u = u[2:end-1]
 R'* u = [0,u,0]
"""
function restrict(n::Integer)
    Id = sparse(I,n,n)
    R  = Id[2:n-1,:]
    return R
end
"""
 R * u = u[2:end]
 R'* u = [0,u]
"""
function restrictUpper(n::Integer)
    Id = sparse(I,n,n)
    R  = Id[2:n,:]
    return R
end
"""
 R * u = u[1:end-1]
 R'* u = [u,0]
"""
function restrictLower(n::Integer)
    Id = sparse(I,n,n)
    R  = Id[1:n-1,:]
    return R
end
#--------------------------------------#
export Tdg
#--------------------------------------#
"""
 Adjointable tridiagonal functor
"""
struct Tdg
    dl::AbstractVector # lower diag
    dd::AbstractVector # main  diag
    du::AbstractVector # upper diag
end

Flux.@functor Tdg

function (T::Tdg)(u::AbstractArray)
    n  = length(T.dd)

    Ru,Rl = Zygote.ignore() do
        Ru = restrictUpper(n)
        Rl = restrictLower(n)
        return Ru,Rl
    end

    v  = u .* T.dd              # main  diag
    v += Rl' * (T.du .* (Ru*u)) # upper diag
    v += Ru' * (T.dl .* (Rl*u)) # lower diag

    return v
end

Base.:*(T::Tdg,u::AbstractArray) = T(u)
Base.:adjoint(T::Tdg) = Tdg(T.du,T.dd,T.dl)
#--------------------------------------#
export lsq
#--------------------------------------#
function lsq(u,A)  # target data, linear function

    x = A \ u

#   AA = Matrix{Float32}(A)
#   uu = vec(u')
#   x,stat = Krylov.cgls(AA,uu)

    return x
end
#--------------------------------------#
#


text:
using Test
using TypeClasses
using Dictionaries

# MonoidAlternative
# =================

@test neutral(Dictionary) == Dictionary()
@test neutral(Dictionary{String, Int}) == Dictionary{String, Int}()

# we can combine any Dict where elements can be combined
d1 = dictionary([:a => "3", :b => "1"])
d2 = dictionary([:a => "5", :b => "9", :c => "15"])

@test d1 ⊕ d2 == dictionary([:a => "35", :b => "19", :c => "15"])

@test d1 ⊘ d2 == dictionary([:a => "3", :b => "1", :c => "15"])

dict1 = Dictionary([:a, :b, :c], ["1", "2", "3"])
dict2 = Dictionary([:b, :c, :d], ["4", "5", "6"])
@test dict1 ⊕ dict2 == Dictionary([:a, :b, :c, :d], ["1", "24", "35", "6"])

dict1 = Dictionary(["a", "b", "c"], [1, 2, 3])
dict2 = Dictionary(["b", "c", "d"], [2, 3, 4])
@test mapn(+, dict1, dict2) == Dictionary(["b", "c"], [4, 6])

dict = Dictionary(["a", "b", "c"], [1, 2, 3])
create_dictionary(x) = Dictionary(["b", "c", "d"], [10x, 20x, 30x])

@test flatmap(create_dictionary, dict) == Dictionary(["b", "c"], [20, 60])

d1 = dictionary([:a => Option(1), :b => Option(2)])
@test flip_types(d1) == Identity(Dictionary([:a, :b], [1, 2]))

d2 = dictionary([:a => Option(1), :b => Option()])
@test flip_types(d2) == Const(nothing)

@test flip_types(dictionary((:a => [1,2], :b => [3, 4]))) == [
    dictionary([:a => 1, :b => 3]),
    dictionary([:a => 1, :b => 4]),
    dictionary([:a => 2, :b => 3]),
    dictionary([:a => 2, :b => 4]),
]
@test flip_types([
    dictionary((:a => 1, :b => 2)),
    dictionary((:a => 10, :b => 20)),
    dictionary((:b => 200, :c => 300))
]) == dictionary([:b => [2, 20, 200]])

ext: jl


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

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

"""

Creates or updates a load balancer inbound nat rule.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: inboundNatRuleName::String (required)
Param: inboundNatRuleParameters::InboundNatRule (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: InboundNatRule
"""
function _swaggerinternal_inboundNatRulesCreateOrUpdate(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, inboundNatRuleName::String, inboundNatRuleParameters, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PUT", InboundNatRule, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/inboundNatRules/{inboundNatRuleName}", ["azure_auth"], inboundNatRuleParameters)
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "inboundNatRuleName", inboundNatRuleName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function inboundNatRulesCreateOrUpdate(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, inboundNatRuleName::String, inboundNatRuleParameters, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_inboundNatRulesCreateOrUpdate(_api, resourceGroupName, loadBalancerName, inboundNatRuleName, inboundNatRuleParameters, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function inboundNatRulesCreateOrUpdate(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, inboundNatRuleName::String, inboundNatRuleParameters, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_inboundNatRulesCreateOrUpdate(_api, resourceGroupName, loadBalancerName, inboundNatRuleName, inboundNatRuleParameters, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Deletes the specified load balancer inbound nat rule.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: inboundNatRuleName::String (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: Nothing
"""
function _swaggerinternal_inboundNatRulesDelete(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, inboundNatRuleName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "DELETE", Nothing, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/inboundNatRules/{inboundNatRuleName}", ["azure_auth"])
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "inboundNatRuleName", inboundNatRuleName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function inboundNatRulesDelete(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, inboundNatRuleName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_inboundNatRulesDelete(_api, resourceGroupName, loadBalancerName, inboundNatRuleName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function inboundNatRulesDelete(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, inboundNatRuleName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_inboundNatRulesDelete(_api, resourceGroupName, loadBalancerName, inboundNatRuleName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Gets the specified load balancer inbound nat rule.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: inboundNatRuleName::String (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Param: expand::String
Return: InboundNatRule
"""
function _swaggerinternal_inboundNatRulesGet(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, inboundNatRuleName::String, api_version::String, subscriptionId::String; expand=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", InboundNatRule, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/inboundNatRules/{inboundNatRuleName}", ["azure_auth"])
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "inboundNatRuleName", inboundNatRuleName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_param(_ctx.query, "\$expand", expand)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function inboundNatRulesGet(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, inboundNatRuleName::String, api_version::String, subscriptionId::String; expand=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_inboundNatRulesGet(_api, resourceGroupName, loadBalancerName, inboundNatRuleName, api_version, subscriptionId; expand=expand, _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function inboundNatRulesGet(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, inboundNatRuleName::String, api_version::String, subscriptionId::String; expand=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_inboundNatRulesGet(_api, resourceGroupName, loadBalancerName, inboundNatRuleName, api_version, subscriptionId; expand=expand, _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Gets all the inbound nat rules in a load balancer.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: InboundNatRuleListResult
"""
function _swaggerinternal_inboundNatRulesList(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", InboundNatRuleListResult, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/inboundNatRules", ["azure_auth"])
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function inboundNatRulesList(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_inboundNatRulesList(_api, resourceGroupName, loadBalancerName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function inboundNatRulesList(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_inboundNatRulesList(_api, resourceGroupName, loadBalancerName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Creates or updates a load balancer backend address pool.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: backendAddressPoolName::String (required)
Param: parameters::BackendAddressPool (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: BackendAddressPool
"""
function _swaggerinternal_loadBalancerBackendAddressPoolsCreateOrUpdate(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, backendAddressPoolName::String, parameters, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PUT", BackendAddressPool, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/backendAddressPools/{backendAddressPoolName}", ["azure_auth"], parameters)
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "backendAddressPoolName", backendAddressPoolName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function loadBalancerBackendAddressPoolsCreateOrUpdate(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, backendAddressPoolName::String, parameters, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerBackendAddressPoolsCreateOrUpdate(_api, resourceGroupName, loadBalancerName, backendAddressPoolName, parameters, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function loadBalancerBackendAddressPoolsCreateOrUpdate(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, backendAddressPoolName::String, parameters, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerBackendAddressPoolsCreateOrUpdate(_api, resourceGroupName, loadBalancerName, backendAddressPoolName, parameters, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Deletes the specified load balancer backend address pool.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: backendAddressPoolName::String (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: Nothing
"""
function _swaggerinternal_loadBalancerBackendAddressPoolsDelete(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, backendAddressPoolName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "DELETE", Nothing, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/backendAddressPools/{backendAddressPoolName}", ["azure_auth"])
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "backendAddressPoolName", backendAddressPoolName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function loadBalancerBackendAddressPoolsDelete(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, backendAddressPoolName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerBackendAddressPoolsDelete(_api, resourceGroupName, loadBalancerName, backendAddressPoolName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function loadBalancerBackendAddressPoolsDelete(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, backendAddressPoolName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerBackendAddressPoolsDelete(_api, resourceGroupName, loadBalancerName, backendAddressPoolName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Gets load balancer backend address pool.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: backendAddressPoolName::String (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: BackendAddressPool
"""
function _swaggerinternal_loadBalancerBackendAddressPoolsGet(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, backendAddressPoolName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", BackendAddressPool, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/backendAddressPools/{backendAddressPoolName}", ["azure_auth"])
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "backendAddressPoolName", backendAddressPoolName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function loadBalancerBackendAddressPoolsGet(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, backendAddressPoolName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerBackendAddressPoolsGet(_api, resourceGroupName, loadBalancerName, backendAddressPoolName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function loadBalancerBackendAddressPoolsGet(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, backendAddressPoolName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerBackendAddressPoolsGet(_api, resourceGroupName, loadBalancerName, backendAddressPoolName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Gets all the load balancer backed address pools.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: LoadBalancerBackendAddressPoolListResult
"""
function _swaggerinternal_loadBalancerBackendAddressPoolsList(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", LoadBalancerBackendAddressPoolListResult, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/backendAddressPools", ["azure_auth"])
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function loadBalancerBackendAddressPoolsList(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerBackendAddressPoolsList(_api, resourceGroupName, loadBalancerName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function loadBalancerBackendAddressPoolsList(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerBackendAddressPoolsList(_api, resourceGroupName, loadBalancerName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Gets load balancer frontend IP configuration.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: frontendIPConfigurationName::String (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: FrontendIPConfiguration
"""
function _swaggerinternal_loadBalancerFrontendIPConfigurationsGet(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, frontendIPConfigurationName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", FrontendIPConfiguration, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/frontendIPConfigurations/{frontendIPConfigurationName}", ["azure_auth"])
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "frontendIPConfigurationName", frontendIPConfigurationName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function loadBalancerFrontendIPConfigurationsGet(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, frontendIPConfigurationName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerFrontendIPConfigurationsGet(_api, resourceGroupName, loadBalancerName, frontendIPConfigurationName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function loadBalancerFrontendIPConfigurationsGet(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, frontendIPConfigurationName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerFrontendIPConfigurationsGet(_api, resourceGroupName, loadBalancerName, frontendIPConfigurationName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Gets all the load balancer frontend IP configurations.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: LoadBalancerFrontendIPConfigurationListResult
"""
function _swaggerinternal_loadBalancerFrontendIPConfigurationsList(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", LoadBalancerFrontendIPConfigurationListResult, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/frontendIPConfigurations", ["azure_auth"])
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function loadBalancerFrontendIPConfigurationsList(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerFrontendIPConfigurationsList(_api, resourceGroupName, loadBalancerName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function loadBalancerFrontendIPConfigurationsList(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerFrontendIPConfigurationsList(_api, resourceGroupName, loadBalancerName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Gets the specified load balancer load balancing rule.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: loadBalancingRuleName::String (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: LoadBalancingRule
"""
function _swaggerinternal_loadBalancerLoadBalancingRulesGet(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, loadBalancingRuleName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", LoadBalancingRule, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/loadBalancingRules/{loadBalancingRuleName}", ["azure_auth"])
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancingRuleName", loadBalancingRuleName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function loadBalancerLoadBalancingRulesGet(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, loadBalancingRuleName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerLoadBalancingRulesGet(_api, resourceGroupName, loadBalancerName, loadBalancingRuleName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function loadBalancerLoadBalancingRulesGet(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, loadBalancingRuleName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerLoadBalancingRulesGet(_api, resourceGroupName, loadBalancerName, loadBalancingRuleName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Gets all the load balancing rules in a load balancer.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: LoadBalancerLoadBalancingRuleListResult
"""
function _swaggerinternal_loadBalancerLoadBalancingRulesList(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", LoadBalancerLoadBalancingRuleListResult, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/loadBalancingRules", ["azure_auth"])
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function loadBalancerLoadBalancingRulesList(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerLoadBalancingRulesList(_api, resourceGroupName, loadBalancerName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function loadBalancerLoadBalancingRulesList(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerLoadBalancingRulesList(_api, resourceGroupName, loadBalancerName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Gets associated load balancer network interfaces.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: NetworkInterfaceListResult
"""
function _swaggerinternal_loadBalancerNetworkInterfacesList(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", NetworkInterfaceListResult, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/networkInterfaces", ["azure_auth"])
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function loadBalancerNetworkInterfacesList(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerNetworkInterfacesList(_api, resourceGroupName, loadBalancerName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function loadBalancerNetworkInterfacesList(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerNetworkInterfacesList(_api, resourceGroupName, loadBalancerName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Gets the specified load balancer outbound rule.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: outboundRuleName::String (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: OutboundRule
"""
function _swaggerinternal_loadBalancerOutboundRulesGet(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, outboundRuleName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", OutboundRule, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/outboundRules/{outboundRuleName}", ["azure_auth"])
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "outboundRuleName", outboundRuleName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function loadBalancerOutboundRulesGet(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, outboundRuleName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerOutboundRulesGet(_api, resourceGroupName, loadBalancerName, outboundRuleName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function loadBalancerOutboundRulesGet(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, outboundRuleName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerOutboundRulesGet(_api, resourceGroupName, loadBalancerName, outboundRuleName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Gets all the outbound rules in a load balancer.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: LoadBalancerOutboundRuleListResult
"""
function _swaggerinternal_loadBalancerOutboundRulesList(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", LoadBalancerOutboundRuleListResult, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/outboundRules", ["azure_auth"])
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function loadBalancerOutboundRulesList(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerOutboundRulesList(_api, resourceGroupName, loadBalancerName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function loadBalancerOutboundRulesList(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerOutboundRulesList(_api, resourceGroupName, loadBalancerName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Gets load balancer probe.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: probeName::String (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: Probe
"""
function _swaggerinternal_loadBalancerProbesGet(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, probeName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", Probe, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}", ["azure_auth"])
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "probeName", probeName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function loadBalancerProbesGet(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, probeName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerProbesGet(_api, resourceGroupName, loadBalancerName, probeName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function loadBalancerProbesGet(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, probeName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerProbesGet(_api, resourceGroupName, loadBalancerName, probeName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Gets all the load balancer probes.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: LoadBalancerProbeListResult
"""
function _swaggerinternal_loadBalancerProbesList(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", LoadBalancerProbeListResult, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes", ["azure_auth"])
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function loadBalancerProbesList(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerProbesList(_api, resourceGroupName, loadBalancerName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function loadBalancerProbesList(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancerProbesList(_api, resourceGroupName, loadBalancerName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Creates or updates a load balancer.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: parameters::LoadBalancer (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: LoadBalancer
"""
function _swaggerinternal_loadBalancersCreateOrUpdate(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, parameters, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PUT", LoadBalancer, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}", ["azure_auth"], parameters)
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function loadBalancersCreateOrUpdate(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, parameters, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancersCreateOrUpdate(_api, resourceGroupName, loadBalancerName, parameters, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function loadBalancersCreateOrUpdate(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, parameters, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancersCreateOrUpdate(_api, resourceGroupName, loadBalancerName, parameters, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Deletes the specified load balancer.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: Nothing
"""
function _swaggerinternal_loadBalancersDelete(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "DELETE", Nothing, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}", ["azure_auth"])
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function loadBalancersDelete(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancersDelete(_api, resourceGroupName, loadBalancerName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function loadBalancersDelete(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancersDelete(_api, resourceGroupName, loadBalancerName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Gets the specified load balancer.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Param: expand::String
Return: LoadBalancer
"""
function _swaggerinternal_loadBalancersGet(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; expand=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", LoadBalancer, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}", ["azure_auth"])
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_param(_ctx.query, "\$expand", expand)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function loadBalancersGet(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; expand=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancersGet(_api, resourceGroupName, loadBalancerName, api_version, subscriptionId; expand=expand, _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function loadBalancersGet(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, api_version::String, subscriptionId::String; expand=nothing, _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancersGet(_api, resourceGroupName, loadBalancerName, api_version, subscriptionId; expand=expand, _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Gets all the load balancers in a resource group.
Param: resourceGroupName::String (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: LoadBalancerListResult
"""
function _swaggerinternal_loadBalancersList(_api::LoadBalancersApi, resourceGroupName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", LoadBalancerListResult, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers", ["azure_auth"])
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function loadBalancersList(_api::LoadBalancersApi, resourceGroupName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancersList(_api, resourceGroupName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function loadBalancersList(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancersList(_api, resourceGroupName, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Gets all the load balancers in a subscription.
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: LoadBalancerListResult
"""
function _swaggerinternal_loadBalancersListAll(_api::LoadBalancersApi, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", LoadBalancerListResult, "/subscriptions/{subscriptionId}/providers/Microsoft.Network/loadBalancers", ["azure_auth"])
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function loadBalancersListAll(_api::LoadBalancersApi, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancersListAll(_api, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function loadBalancersListAll(_api::LoadBalancersApi, response_stream::Channel, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancersListAll(_api, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Updates a load balancer tags.
Param: resourceGroupName::String (required)
Param: loadBalancerName::String (required)
Param: parameters::TagsObject (required)
Param: api_version::String (required)
Param: subscriptionId::String (required)
Return: LoadBalancer
"""
function _swaggerinternal_loadBalancersUpdateTags(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, parameters, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PATCH", LoadBalancer, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}", ["azure_auth"], parameters)
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "loadBalancerName", loadBalancerName)  # type String
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function loadBalancersUpdateTags(_api::LoadBalancersApi, resourceGroupName::String, loadBalancerName::String, parameters, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancersUpdateTags(_api, resourceGroupName, loadBalancerName, parameters, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function loadBalancersUpdateTags(_api::LoadBalancersApi, response_stream::Channel, resourceGroupName::String, loadBalancerName::String, parameters, api_version::String, subscriptionId::String; _mediaType=nothing)
    _ctx = _swaggerinternal_loadBalancersUpdateTags(_api, resourceGroupName, loadBalancerName, parameters, api_version, subscriptionId; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

export inboundNatRulesCreateOrUpdate, inboundNatRulesDelete, inboundNatRulesGet, inboundNatRulesList, loadBalancerBackendAddressPoolsCreateOrUpdate, loadBalancerBackendAddressPoolsDelete, loadBalancerBackendAddressPoolsGet, loadBalancerBackendAddressPoolsList, loadBalancerFrontendIPConfigurationsGet, loadBalancerFrontendIPConfigurationsList, loadBalancerLoadBalancingRulesGet, loadBalancerLoadBalancingRulesList, loadBalancerNetworkInterfacesList, loadBalancerOutboundRulesGet, loadBalancerOutboundRulesList, loadBalancerProbesGet, loadBalancerProbesList, loadBalancersCreateOrUpdate, loadBalancersDelete, loadBalancersGet, loadBalancersList, loadBalancersListAll, loadBalancersUpdateTags


text:
# From the PyPlot Github Repo
# https://github.com/JuliaPy/PyPlot.jl
using PyPlot    # importing the library

# creating x range from 0 to 2pi
x = range(0; stop=2*pi, length=1000);
# creating y range working on x
y = sin.(3 * x + 4 * cos.(2 * x));

# plotting out the relation with blue dashed effect
plot(x, y, color="blue", linewidth=2.0, linestyle="--")
title("A sinusoidally modulated sinusoid")

max_stars_repo_name: nunesmelo/djs-office-hours

max_issues_repo_name: nunesmelo/djs-office-hours

max_forks_repo_name: nunesmelo/djs-office-hours


text:
"""
    updateParticlesField!(particles::Particles, alg::BruteForce; lambda)

Evaluate and update the space charge field experienced by each particle in `beam` using
`alg` method.
"""
function updateParticlesField!(particles::Particles{T}, alg::BruteForce; lambda) where {T}
    q = particles.charge
    npar = particles.npar
    @inbounds for i in 1:npar
        particles.self_efields[i] = SVector(0.0, 0.0, 0.0)
        particles.self_bfields[i] = SVector(0.0, 0.0, 0.0)
        xi = particles.positions[i]
        amp = 2.8179403699772166e-15 * q / lambda
        for j in 1:npar
            xj = particles.positions[j]
            pj = particles.momentums[j]
            K = kernel_relativity(xi, xj, pj)
            particles.self_efields[i] += amp * sqrt(1.0 + dot(pj, pj)) * K
            particles.self_bfields[i] += amp * cross(pj, K)
        end
    end
end

function updateParticlesField!(particles::Particles{T}, alg::TreecodeStretch{T}; lambda) where {T}
    (;n, N0, eta) = alg

    q = particles.charge
    p_avg = sum(particles.momentums) / particles.npar
    g_avg = sqrt(1.0 + dot(p_avg, p_avg))
    stretch = SVector(1.0,1.0,g_avg)

    ct = ClusterTree(particles; n=n, threshold=N0, stretch=stretch)
    amp = 2.8179403699772166e-15 * q / lambda
    @inbounds for i in 1:particles.npar
        x = particles.positions[i]
        (efield, bfield) = cluster2p(x, ct.root, particles, ct.parindices; p_kernel=p_avg, n=n, eta=eta, stretch=stretch)
        particles.self_efields[i] = amp * efield
        particles.self_bfields[i] = amp * bfield
    end
end

function updateParticlesField!(particles::Particles{T}, alg::TreecodeUniform{T}; lambda) where {T}
    (;n, N0, eta) = alg

    q = particles.charge
    p_avg = sum(particles.momentums) / particles.npar

    ct = ClusterTree(particles; n=n, threshold=N0)
    amp = 2.8179403699772166e-15 * q / lambda
    @inbounds for i in 1:particles.npar
        x = particles.positions[i]
        (efield, bfield) = cluster2p(x, ct.root, particles, ct.parindices; p_kernel=p_avg, n=n, eta=eta)
        particles.self_efields[i] = amp * efield
        particles.self_bfields[i] = amp * bfield
    end
end

function updateParticlesField!(particles::Particles{T}, alg::TreecodeAvgRestFrame{T}; lambda) where {T}
    (;n, N0, eta) = alg

    q = particles.charge
    p_avg = sum(particles.momentums) / particles.npar
    g_avg = sqrt(1.0 + dot(p_avg, p_avg))

    # transform particles to rest-frame
    boostParticlesPosition!(particles, p_avg, g_avg)
    transformParticlesMomentum!(particles, p_avg)

    # evaluate particles field in the rest-frame
    ct = ClusterTree(particles; n=n, threshold=N0)
    amp = 2.8179403699772166e-15 * q / lambda
    @inbounds for i in 1:particles.npar
        x = particles.positions[i]
        (efield, bfield) = cluster2p(x, ct.root, particles, ct.parindices; p_kernel=SVector(0.0,0.0,0.0), n=n, eta=eta)
        particles.self_efields[i] = amp * efield
        particles.self_bfields[i] = amp * bfield
    end

    # transform particle distribution and field back to the lab-frame
    # deboost particles position
    boostParticlesPosition!(particles, -p_avg, 1.0/g_avg)
    transformParticlesMomentum!(particles, -p_avg)
    transformParticlesField!(particles, -p_avg)
end


text:
mutable struct MyStruct a end
x = MyStruct(2)
1.a = 3

max_stars_repo_name: gabriel-doriath-dohler/pjulia

max_issues_repo_name: gabriel-doriath-dohler/pjulia

max_forks_repo_name: gabriel-doriath-dohler/pjulia


text:
using Knet
include("readdata.jl")

# Copy of VGG model A: http://arxiv.org/pdf/1409.1556v6.pdf

@knet function model04(x; T=51, D=4, W=3, o...)
    c1 = cbfp73(x;  o..., out=64, pwindow=T)
    c2 = cbfp73(c1; o..., out=128, pwindow=T)
    c3 = cbf73(c2; o..., out=256)
    c4 = cbfp73(c3; o..., out=256, pwindow=T)
    c5 = cbf73(c4; o..., out=512)
    c6 = cbfp73(c5; o..., out=512, pwindow=T)
    c7 = cbf73(c6; o..., out=512)
    c8 = cbfp73(c7; o..., out=512, pwindow=T)
    f1 = wbf73(c8; o..., out=4096)
    f2 = wbf73(f1; o..., out=4096)
    return wbf73(f2; o..., out=2, f=:soft)
end

function train04(; N=2^13, lr=0.001, adam=true, nbatch=128, o...)
    global f = compile(:model04; o...)
    setp(f, lr=lr, adam=adam)
    global d = GulayseData(nbatch)
    sloss = zloss = -1; n = nextn = 1
    for (x,ygold) in d
        ypred = forw(f, x)
        sl = softloss(ypred,ygold); sloss = (n==1 ? sl : 0.99 * sloss + 0.01 * sl)
        zl = zeroone(ypred,ygold);  zloss = (n==1 ? zl : 0.99 * zloss + 0.01 * zl)
        n==nextn && (println((n,sloss,1-zloss)); nextn*=2)
        back(f, ygold, softloss)
        update!(f)
        (n += 1) > N && break
    end
end

train04()

max_stars_repo_name: JuliaTagBot/BindingPrediction

max_issues_repo_name: JuliaTagBot/BindingPrediction

max_forks_repo_name: JuliaTagBot/BindingPrediction


text:
# Define the AbstractGP type and its API.

"""
    abstract type AbstractGP end

Supertype for various Gaussian process (GP) types. A common interface is provided for
interacting with each of these objects. See [1] for an overview of GPs.

[1] - C. E. Rasmussen and C. Williams. "Gaussian processes for machine learning".
MIT Press. 2006.
"""
abstract type AbstractGP end

"""
    mean(f::AbstractGP, x::AbstractVector)

Computes the mean vector of the multivariate Normal `f(x)`.
"""
Statistics.mean(::AbstractGP, ::AbstractVector)

"""
    cov(f::AbstractGP, x::AbstractVector)

Compute the `length(x)` by `length(x)` covariance matrix of the multivariate Normal `f(x)`.
"""
Statistics.cov(::AbstractGP, x::AbstractVector)

"""
    cov_diag(f::AbstractGP, x::AbstractVector)

Compute only the diagonal elements of `cov(f(x))`.
"""
cov_diag(::AbstractGP, ::AbstractVector)

"""
    cov(f::AbstractGP, x::AbstractVector, y::AbstractVector)

Compute the `length(x)` by `length(y)` cross-covariance matrix between `f(x)` and `f(y)`.
"""
Statistics.cov(::AbstractGP, x::AbstractVector, y::AbstractVector)

"""
    mean_and_cov(f::AbstractGP, x::AbstractVector)

Compute both `mean(f(x))` and `cov(f(x))`. Sometimes more efficient than separately
computation, particularly for posteriors.
"""
mean_and_cov(f::AbstractGP, x::AbstractVector) = (mean(f, x), cov(f, x))

"""
    mean_and_cov_diag(f::AbstractGP, x::AbstractVector)

Compute both `mean(f(x))` and the diagonal elements of `cov(f(x))`. Sometimes more efficient
than separately computation, particularly for posteriors.
"""
mean_and_cov_diag(f::AbstractGP, x::AbstractVector) = (mean(f, x), cov_diag(f, x))


text:
"""
    srgb2linear(u)

Convert pixel `u` from sRGB to linear color space.
"""
@inline srgb2linear(u::Number) = Colors.invert_srgb_compand(u)
@inline srgb2linear(u::Gray) = typeof(u)(srgb2linear(gray(u)))
@inline srgb2linear(u::Bool) = u

"""
    upscale(img, scale)

Upscale image by repeating individual pixels `scale` times.
"""
upscale(img, scale) = repeat(img; inner=(scale, scale))

if VERSION >= v"1.7"
    _closest_color_idx(px, cs, metric) = argmin(colordiff(px, c; metric=metric) for c in cs)
else
    function _closest_color_idx(px, cs, metric)
        return argmin([colordiff(px, c; metric=metric) for c in cs])
    end
end


text:
# Use baremodule to shave off a few KB from the serialized `.ji` file
baremodule Birch_jll
using Base
using Base: UUID
import JLLWrappers

JLLWrappers.@generate_main_file_header("Birch")
JLLWrappers.@generate_main_file("Birch", UUID("f446a8d3-3ce2-58d3-82fb-4f82d1c6300c"))
end  # module Birch_jll


text:
using LinearAlgebra: lmul!, rmul!, Diagonal

"""
    optimaltransportation(M::AbstractArray;
            [a, b, λ=1, ϵ=1e-10, maxiter=100])

Performs optimal transportation on an ecological network. Here, `M` is treated
as an utility matrix, quantifying the preference the species of the two throphic
levels have for interacting with another. One can fix both, one or none of the
species abundances by given `a` (row sums, corresponding to top species) and/or
`b` (column sums, corresponding to bottom species). The strengh of entropic
regularisation is set by `λ`, where higher values indicate more utitlity and lower
values more entropy.

ϵ and `maxiter` control the number of Sinkhorn iterations. You likely won't need
to change these.

This version works on arrays.

Stock, M., Poisot, T., & De Baets, B. (2021). « Optimal transportation theory for
species interaction networks. » Ecology and Evolution, 00(1), ece3.7254.
https://doi.org/10.1002/ece3.7254
"""
function optimaltransportation(M::AbstractArray;
        a=nothing, b=nothing, λ::Number=1, ϵ=1e-10, maxiter=100)
    Q = ot(M, a, b; λ=λ, ϵ=ϵ, maxiter=maxiter)
    return Q
end

"""
    optimaltransportation(M::AbstractBipartiteNetwork;
            [a, b, λ=1, ϵ=1e-10, maxiter=100])

Performs optimal transportation on an ecological network. Here, `M` is treated
as an utility matrix, quantifying the preference the species of the two throphic
levels have for interacting with another. One can fix both, one or none of the
species abundances by given `a` (row sums, corresponding to top species) and/or
`b` (column sums, corresponding to bottom species). The strengh of entropic
regularisation is set by `λ`, where higher values indicate more utitlity and lower
values more entropy.

ϵ and `maxiter` control the number of Sinkhorn iterations. You likely won't need
to change these.

Stock, M., Poisot, T., & De Baets, B. (2021). « Optimal transportation theory for
species interaction networks. » Ecology and Evolution, 00(1), ece3.7254.
https://doi.org/10.1002/ece3.7254
"""
function optimaltransportation(M::AbstractBipartiteNetwork;
    a=nothing, b=nothing, λ::Number=1, ϵ=1e-10, maxiter=100)
    Q = ot(M.edges, a, b; λ=λ, ϵ=ϵ, maxiter=maxiter)
    return BipartiteQuantitativeNetwork(Q, species(M, dims=1), species(M, dims=2))
end

# optimal transportation fixing both marginals
function ot(M::AbstractMatrix, a::AbstractVector, b::AbstractVector; λ, ϵ, maxiter)
    @assert size(M) == (length(a), length(b))
    @assert all(a .> 0) "all values of `a` have to be greater than 0"
    @assert all(b .> 0) "all values of `b` have to be greater than 0"
    @assert sum(a) ≈ sum(b) "`a` and `b` have to have the same sums"
    Q = exp.(λ * M)
    iter = 0
    for iter in 1:maxiter
        iter += 1
        lmul!(Diagonal(a ./ sum(Q, dims=2)[:]), Q)  # normalize rows
        rmul!(Q, Diagonal(b ./ sum(Q, dims=1)[:]))  # normalize columns
        maximum(abs.(sum(Q, dims=2)[:] - a)) < ϵ && break
    end
    return Q
end

# optimal transportation fixing a
function ot(M::AbstractMatrix, a::AbstractVector, b::Nothing; λ, ϵ, maxiter)
    @assert size(M, 1) == length(a) && all(a .> 0)
    Q = exp.(λ * M)
    lmul!(Diagonal(a ./ sum(Q, dims=2)[:]), Q)
    return Q
end

# optimal transportation fixing b
function ot(M::AbstractMatrix, a::Nothing, b::AbstractVector; λ, ϵ, maxiter)
    @assert size(M, 2) == length(b) && all(b .> 0)
    Q = exp.(λ * M)
    rmul!(Q, Diagonal(b ./ sum(Q, dims=1)[:]))
    return Q
end

# optimal transportation free
function ot(M::AbstractMatrix, a::Nothing, b::Nothing; λ, ϵ, maxiter)
    Q = exp.(λ * M)
    Q ./= sum(Q)
    return Q
end


text:
module FirstFinDiffPlans

using LinearAlgebra: dot
using StaticArrays: SVector

using ..PoincareInvariants: FirstPoincareInvariant, getpointnum, getform

import ..PoincareInvariants: compute!, getpoints, getpointspec

struct FirstFinDiffPlan{T, D} end

FirstFinDiffPlan{T, D}(θ, N) where {T, D} = FirstFinDiffPlan{T, D}()

function compute!(
    pinv::FirstPoincareInvariant{T, D, <:Any, <:FirstFinDiffPlan}, t, p
) where {T, D}
    zs = pinv.points
    N = getpointnum(pinv)
    θ = getform(pinv)
    I = zero(T)

    dzi = Vector{T}(undef, D)

    for i in 2:N-1
        zi = view(zs, i, :)
        dzi .= @views (zs[i+1, :] .- zs[i-1, :]) ./ 2
        I += dot(θ(zi, t, p), dzi)
    end

    # special cases i = 1
    z1 = view(zs, 1, :)
    dzi .= @views (zs[2, :] .- zs[N, :]) ./ 2
    I += dot(θ(z1, t, p), dzi)

    # special cases i = N
    zN = view(zs, N, :)
    dzi .= @views (zs[1, :] .- zs[N-1, :]) ./ 2
    I += dot(θ(zN, t, p), dzi)

    return I
end

## getpoints and getpointspec ##

# must be even to work with simpson weights
function getpointspec(N::Integer, ::Type{<:FirstFinDiffPlan})::Int
    if N < 2
        return 2
    elseif isodd(N)
        return N + 1
    else
        return N
    end
end

function getpoints(f, ::Type{T}, N::Integer, ::Type{<:FirstFinDiffPlan}) where T
    D = length(f(zero(T)))
    out = Matrix{T}(undef, N, D)

    for (i, x) in enumerate(range(0, 1, length=N+1)[1:end-1])
        out[i, :] .= f(x)
    end

    # Should return vector instead of matrix in 1D case
    return D == 1 ? vec(out) : out
end

end  # module FirstFinDiffPlans


text:
@defcomp impactagriculture begin
    regions = Index()

    gdp90 = Parameter(index=[regions])
    income = Parameter(index=[time,regions])
    pop90 = Parameter(index=[regions])
    population = Parameter(index=[time,regions])

    agrish = Variable(index=[time,regions])
    agrish0 = Parameter(index=[regions])
    agel = Parameter(default = 0.31)

    agrate = Variable(index=[time,regions])
    aglevel = Variable(index=[time,regions])
    agco2 = Variable(index=[time,regions])
    agcost = Variable(index=[time,regions])

    agrbm = Parameter(index=[regions])
    agtime = Parameter(index=[regions])
    agnl = Parameter(default = 2)

    aglparl = Parameter(index=[regions])
    aglparq = Parameter(index=[regions])

    agcbm = Parameter(index=[regions])
    co2pre = Parameter(default = 275.0)

    temp = Parameter(index=[time,regions])
    acco2 = Parameter(index=[time])

    function run_timestep(p, v, d, t)

        DBsT = 0.04     # base case yearly warming

        if is_first(t)
            for r in d.regions
                v.agrate[t, r] = p.agrbm[r] * (0.005 / DBsT)^p.agnl * p.agtime[r]
            end
        else
            for r in d.regions
                ypc = p.income[t, r] / p.population[t, r] * 1000.0
                ypc90 = p.gdp90[r] / p.pop90[r] * 1000.0

                v.agrish[t, r] = p.agrish0[r] * (ypc / ypc90)^(-p.agel)
            end

            for r in d.regions
                dtemp = abs(p.temp[t, r] - p.temp[t - 1, r])

                if isnan((dtemp / 0.04)^p.agnl)
                    v.agrate[t, r] = 0.0
                else
                    v.agrate[t, r] = p.agrbm[r] * (dtemp / 0.04)^p.agnl + (1.0 - 1.0 / p.agtime[r]) * v.agrate[t - 1, r]
                end
            end

            for r in d.regions
                v.aglevel[t, r] = p.aglparl[r] * p.temp[t, r] + p.aglparq[r] * p.temp[t, r]^2.0
            end

            for r in d.regions
                v.agco2[t, r] = p.agcbm[r] / log(2.0) * log(p.acco2[t - 1] / p.co2pre)
            end

            for r in d.regions
                v.agcost[t, r] = min(1.0, v.agrate[t, r] + v.aglevel[t, r] + v.agco2[t, r]) * v.agrish[t, r] * p.income[t, r]
            end
        end
    end
end


text:
# Use
#    @warnpcfail precompile(args...)
# if you want to be warned when a precompile directive fails
macro warnpcfail(ex::Expr)
    modl = __module__
    file = __source__.file === nothing ? "?" : String(__source__.file)
    line = __source__.line
    quote
        $(esc(ex)) || @warn """precompile directive
     $($(Expr(:quote, ex)))
 failed. Please report an issue in $($modl) (after checking for duplicates) or remove this directive.""" _file=$file _line=$line
    end
end

const __bodyfunction__ = Dict{Method,Any}()

# Find keyword "body functions" (the function that contains the body
# as written by the developer, called after all missing keyword-arguments
# have been assigned values), in a manner that doesn't depend on
# gensymmed names.
# `mnokw` is the method that gets called when you invoke it without
# supplying any keywords.
function __lookup_kwbody__(mnokw::Method)
    function getsym(arg)
        isa(arg, Symbol) && return arg
        @assert isa(arg, GlobalRef)
        return arg.name
    end

    f = get(__bodyfunction__, mnokw, nothing)
    if f === nothing
        fmod = mnokw.module
        # The lowered code for `mnokw` should look like
        #   %1 = mkw(kwvalues..., #self#, args...)
        #        return %1
        # where `mkw` is the name of the "active" keyword body-function.
        ast = Base.uncompressed_ast(mnokw)
        if isa(ast, Core.CodeInfo) && length(ast.code) >= 2
            callexpr = ast.code[end-1]
            if isa(callexpr, Expr) && callexpr.head == :call
                fsym = callexpr.args[1]
                if isa(fsym, Symbol)
                    f = getfield(fmod, fsym)
                elseif isa(fsym, GlobalRef)
                    if fsym.mod === Core && fsym.name === :_apply
                        f = getfield(mnokw.module, getsym(callexpr.args[2]))
                    elseif fsym.mod === Core && fsym.name === :_apply_iterate
                        f = getfield(mnokw.module, getsym(callexpr.args[3]))
                    else
                        f = getfield(fsym.mod, fsym.name)
                    end
                else
                    f = missing
                end
            else
                f = missing
            end
        else
            f = missing
        end
        __bodyfunction__[mnokw] = f
    end
    return f
end

function _precompile_()
    ccall(:jl_generating_output, Cint, ()) == 1 || return nothing
    Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:name, :study_id), Tuple{Nothing, Nothing}},Type{FBPScanner{G, D} where {G, D}},FanBeamGeometry{Float64, DefaultTomograph},CTImageMat{Float64}})
    Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:name, :study_id), Tuple{Nothing, Nothing}},Type{FBPScanner{G, D} where {G, D}},ParallelBeamGeometry{Float32, DefaultTomograph},CTImageMat{Float32}})
    Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:name, :study_id), Tuple{Nothing, Nothing}},Type{FBPScanner{G, D} where {G, D}},ParallelBeamGeometry{Float64, DefaultTomograph},CTImageMat{Float64}})
    Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:nϕ,), Tuple{Int64}},Type{FanBeamGeometry},CircleImage{Float32}})
    Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:nϕ,), Tuple{Int64}},Type{FanBeamGeometry},CircleImage{Float64}})
    Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:nϕ,), Tuple{Int64}},Type{ParallelBeamGeometry},CircleImage{Float32}})
    Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:nϕ,), Tuple{Int64}},Type{ParallelBeamGeometry},CircleImage{Float64}})
    Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:width, :height), Tuple{Int64, Int64}},Type{ParallelBeamGeometry},Type{Float32}})
    Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:width,), Tuple{Int64}},Type{CircleImage},Type{Float32}})
    Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:width,), Tuple{Int64}},Type{CircleImage},Type{Float64}})
    Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:width,), Tuple{Int64}},Type{GrayScaleLine},Type{Float32}})
    Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:width,), Tuple{Int64}},Type{GrayScaleLine},Type{Float64}})
    Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:width,), Tuple{Int64}},Type{GrayScalePyramid},Type{Float32}})
    Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:width,), Tuple{Int64}},Type{GrayScalePyramid},Type{Float64}})
    Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:width,), Tuple{Int64}},Type{SquareImage},Type{Float32}})
    Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:width,), Tuple{Int64}},Type{SquareImage},Type{Float64}})
    Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:width,), Tuple{Int64}},Type{WhiteRect},Type{Float32}})
    Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:width,), Tuple{Int64}},Type{WhiteRect},Type{Float64}})
    Base.precompile(Tuple{Core.kwftype(typeof(circle_image)),NamedTuple{(:radius, :calibration_value, :background, :rows), Tuple{Int64, Float32, Float32, Int64}},typeof(circle_image),Type{Float32}})
    Base.precompile(Tuple{Core.kwftype(typeof(circle_image)),NamedTuple{(:radius, :calibration_value, :background, :rows), Tuple{Int64, Float64, Float64, Int64}},typeof(circle_image),Type{Float64}})
    Base.precompile(Tuple{Core.kwftype(typeof(gray_scale_image)),NamedTuple{(:swidth, :sheight, :gray_scale, :background), Tuple{Int64, Int64, IntervalSets.ClosedInterval{Float32}, Float32}},typeof(gray_scale_image),Type{Float32}})
    Base.precompile(Tuple{Core.kwftype(typeof(gray_scale_image)),NamedTuple{(:swidth, :sheight, :gray_scale, :background), Tuple{Int64, Int64, IntervalSets.ClosedInterval{Float64}, Float64}},typeof(gray_scale_image),Type{Float64}})
    Base.precompile(Tuple{MartaCT.CTImages.var"#181#threadsfor_fun#13"{Float32, StepRangeLen{Float32, Float64, Float64}, StepRangeLen{Float32, Float64, Float64}, Matrix{Float32}, Vector{Tuple{Int64, Int64}}, MartaCT.Interpolation.var"#1#2"{Matrix{Float32}, MartaCT.Interpolation.BilinearInterpolation}, Float32, Float32, Base.OneTo{Int64}}})
    Base.precompile(Tuple{MartaCT.CTImages.var"#181#threadsfor_fun#13"{Float32, StepRangeLen{Float32, Float64, Float64}, StepRangeLen{Float32, Float64, Float64}, Matrix{Float32}, Vector{Tuple{Int64, Int64}}, MartaCT.Interpolation.var"#1#2"{Matrix{Float32}, MartaCT.Interpolation.NoInterpolation}, Float32, Float32, Base.OneTo{Int64}}})
    Base.precompile(Tuple{MartaCT.CTImages.var"#181#threadsfor_fun#13"{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}, Matrix{Float64}, Vector{Tuple{Int64, Int64}}, MartaCT.Interpolation.var"#1#2"{Matrix{Float64}, MartaCT.Interpolation.BilinearInterpolation}, Float64, Float64, Base.OneTo{Int64}}})
    Base.precompile(Tuple{MartaCT.CTImages.var"#181#threadsfor_fun#13"{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}, Matrix{Float64}, Vector{Tuple{Int64, Int64}}, MartaCT.Interpolation.var"#1#2"{Matrix{Float64}, MartaCT.Interpolation.NoInterpolation}, Float64, Float64, Base.OneTo{Int64}}})
    Base.precompile(Tuple{MartaCT.FanBeam.var"#211#threadsfor_fun#3"{Float32, MartaCT.FanBeam.var"#compute_value#2"{Float32, Float32, MartaCT.Interpolation.var"#1#2"{CTSinogMat{Float32}, MartaCT.Interpolation.BilinearInterpolation}, Float32, Float32, Float32, Int64, Int64}, CTSinogMat{Float32}, StepRangeLen{Float32, Float64, Float64}, StepRangeLen{Float32, Float64, Float64}, Float32, Int64, UnitRange{Int64}}})
    Base.precompile(Tuple{MartaCT.FanBeam.var"#211#threadsfor_fun#3"{Float64, MartaCT.FanBeam.var"#compute_value#2"{Float64, Float64, MartaCT.Interpolation.var"#1#2"{CTSinogMat{Float64}, MartaCT.Interpolation.BilinearInterpolation}, Float64, Float64, Float64, Int64, Int64}, CTSinogMat{Float64}, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}, Float64, Int64, UnitRange{Int64}}})
    Base.precompile(Tuple{MartaCT.FanBeam.var"#234#threadsfor_fun#10"{Float32, MartaCT.FanBeam.var"#compute_value#9"{Float32, Float32, MartaCT.Interpolation.var"#1#2"{CTSinogMat{Float32}, MartaCT.Interpolation.BilinearInterpolation}, Float32, Float32, Float32, Int64, Int64}, CTSinogMat{Float32}, StepRangeLen{Float32, Float64, Float64}, Float32, StepRangeLen{Float32, Float64, Float64}, Float32, Int64, UnitRange{Int64}}})
    Base.precompile(Tuple{MartaCT.FanBeam.var"#234#threadsfor_fun#10"{Float64, MartaCT.FanBeam.var"#compute_value#9"{Float64, Float64, MartaCT.Interpolation.var"#1#2"{CTSinogMat{Float64}, MartaCT.Interpolation.BilinearInterpolation}, Float64, Float64, Float64, Int64, Int64}, CTSinogMat{Float64}, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}, Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}, Float64, Int64, UnitRange{Int64}}})
    Base.precompile(Tuple{Type{FBPScanner{G, D} where {G, D}},CircleImage{Float32}})
    Base.precompile(Tuple{Type{FBPScanner{G, D} where {G, D}},CircleImage{Float64}})
    Base.precompile(Tuple{Type{FBPScanner{G, D} where {G, D}},FanBeamGeometry{Float32, DefaultTomograph},CircleImage{Float32}})
    Base.precompile(Tuple{Type{FBPScanner{G, D} where {G, D}},GrayScaleLine{Float32}})
    Base.precompile(Tuple{Type{FBPScanner{G, D} where {G, D}},GrayScaleLine{Float64}})
    Base.precompile(Tuple{Type{FBPScanner{G, D} where {G, D}},GrayScalePyramid{Float32}})
    Base.precompile(Tuple{Type{FBPScanner{G, D} where {G, D}},GrayScalePyramid{Float64}})
    Base.precompile(Tuple{Type{FBPScanner{G, D} where {G, D}},SquareImage{Float32}})
    Base.precompile(Tuple{Type{FBPScanner{G, D} where {G, D}},SquareImage{Float64}})
    Base.precompile(Tuple{Type{FBPScanner{G, D} where {G, D}},WhiteRect{Float32}})
    Base.precompile(Tuple{Type{FBPScanner{G, D} where {G, D}},WhiteRect{Float64}})
    Base.precompile(Tuple{typeof(MartaCT.Utils._wrap_angle),Float32,Int64})
    Base.precompile(Tuple{typeof(MartaCT.Utils._wrap_angle),Float64,Int64})
    Base.precompile(Tuple{typeof(calibrate_tomogram),CTScanner{FBPInfo{ParallelBeamGeometry{Float32, DefaultTomograph}, FBP{MartaCT.RadonAlgorithm.Filters.RamLak}}, MartaCT.CTScan.CTImageData.CTData{Float32, Matrix{Float32}}},CircleImage{Float32}})
    Base.precompile(Tuple{typeof(calibrate_tomogram),CTScanner{FBPInfo{ParallelBeamGeometry{Float32, DefaultTomograph}, FBP{MartaCT.RadonAlgorithm.Filters.RamLak}}, MartaCT.CTScan.CTImageData.CTData{Float32, Matrix{Float32}}},CircleParams{Float32}})
    Base.precompile(Tuple{typeof(calibrate_tomogram),CTScanner{FBPInfo{ParallelBeamGeometry{Float32, DefaultTomograph}, FBP{MartaCT.RadonAlgorithm.Filters.RamLak}}, MartaCT.CTScan.CTImageData.CTData{Float32, Matrix{Float32}}},GrayScalePyramid{Float32}})
    Base.precompile(Tuple{typeof(calibrate_tomogram),CTScanner{FBPInfo{ParallelBeamGeometry{Float32, DefaultTomograph}, FBP{MartaCT.RadonAlgorithm.Filters.RamLak}}, MartaCT.CTScan.CTImageData.CTData{Float32, Matrix{Float32}}},ImageParams{Float32}})
    Base.precompile(Tuple{typeof(calibrate_tomogram),CTScanner{FBPInfo{ParallelBeamGeometry{Float32, DefaultTomograph}, FBP{MartaCT.RadonAlgorithm.Filters.RamLak}}, MartaCT.CTScan.CTImageData.CTData{Float32, Matrix{Float32}}},MartaCT.TestImages.SquareParams{Float32}})
    Base.precompile(Tuple{typeof(calibrate_tomogram),CTScanner{FBPInfo{ParallelBeamGeometry{Float32, DefaultTomograph}, FBP{MartaCT.RadonAlgorithm.Filters.RamLak}}, MartaCT.CTScan.CTImageData.CTData{Float32, Matrix{Float32}}},WhiteRect{Float32}})
    Base.precompile(Tuple{typeof(calibrate_tomogram),CTScanner{FBPInfo{ParallelBeamGeometry{Float64, DefaultTomograph}, FBP{MartaCT.RadonAlgorithm.Filters.RamLak}}, MartaCT.CTScan.CTImageData.CTData{Float64, Matrix{Float64}}},CircleImage{Float64}})
    Base.precompile(Tuple{typeof(calibrate_tomogram),CTScanner{FBPInfo{ParallelBeamGeometry{Float64, DefaultTomograph}, FBP{MartaCT.RadonAlgorithm.Filters.RamLak}}, MartaCT.CTScan.CTImageData.CTData{Float64, Matrix{Float64}}},CircleParams{Float64}})
    Base.precompile(Tuple{typeof(calibrate_tomogram),CTScanner{FBPInfo{ParallelBeamGeometry{Float64, DefaultTomograph}, FBP{MartaCT.RadonAlgorithm.Filters.RamLak}}, MartaCT.CTScan.CTImageData.CTData{Float64, Matrix{Float64}}},ImageParams{Float64}})
    Base.precompile(Tuple{typeof(calibrate_tomogram),CTScanner{FBPInfo{ParallelBeamGeometry{Float64, DefaultTomograph}, FBP{MartaCT.RadonAlgorithm.Filters.RamLak}}, MartaCT.CTScan.CTImageData.CTData{Float64, Matrix{Float64}}},MartaCT.TestImages.SquareParams{Float64}})
    Base.precompile(Tuple{typeof(calibrate_tomogram),CTScanner{FBPInfo{ParallelBeamGeometry{Float64, DefaultTomograph}, FBP{MartaCT.RadonAlgorithm.Filters.RamLak}}, MartaCT.CTScan.CTImageData.CTData{Float64, Matrix{Float64}}},SquareImage{Float64}})
    Base.precompile(Tuple{typeof(combine_images),ImageParams{Float32},Matrix{Float32},Matrix{Float32}})
    Base.precompile(Tuple{typeof(combine_images),ImageParams{Float64},Matrix{Float64},Matrix{Float64}})
    let fbody = try __lookup_kwbody__(which(FBPScanner, (ParallelBeamGeometry{Float64, DefaultTomograph},CircleImage{Float64},))) catch missing end
        if !ismissing(fbody)
            precompile(fbody, (Nothing,Nothing,Type{FBPScanner{G, D} where {G, D}},ParallelBeamGeometry{Float64, DefaultTomograph},CircleImage{Float64},))
        end
    end
end


text:
function read_string_vec(io::IO, u::Array{UInt8,1})
  b = read(io, UInt8)
  S = String[]
  if b == 0x00
    N = read(io, Int64)
    p = pointer(u)
    L = read!(io, Array{UInt16,1}(undef, N))
    i = 0
    while i < N
      i = i + 1
      l = getindex(L, i)
      unsafe_read(io, p, l)
      push!(S, unsafe_string(p, l))
    end
  end
  return S
end

function read_misc(io::IO, u::Array{UInt8,1})
  D = Dict{String,Any}()
  L = read(io, Int64)
  if L != zero(Int64)
    n     = zero(Int64)
    dims  = Array{Int64, 1}(undef, 3)
    p     = pointer(u)
    K     = read_string_vec(io, u)
    for k in K
      t = read(io, UInt8)
      T = code2typ(t)

      # String array
      if t == 0x81
        nd = read(io, Int64)
        checkbuf_strict!(dims, nd)
        read!(io, dims)
        if dims == [0]
          D[k] = String[]
        else
          S = String[]
          i = 0
          N = prod(dims)
          L = read!(io, Array{UInt16,1}(undef, N))
          while i < N
            i = i + 1
            l = getindex(L, i)
            unsafe_read(io, p, l)
            push!(S, unsafe_string(p, l))
          end
          D[k] = reshape(S, dims...)
        end

      # Numeric or Char array
      elseif T <: AbstractArray
        nd = read(io, Int64)
        if nd == 1
          D[k] = read!(io, T(undef, read(io, Int64)))
        else
          checkbuf_strict!(dims, nd)
          read!(io, dims)
          D[k] = read!(io, T(undef, dims...))
        end

      # String
      elseif T == String
        n = read(io, UInt16)
        unsafe_read(io, p, n)
        D[k] = unsafe_string(p, n)

      # Bits type
      else
        D[k] = read(io, T)
      end
    end
  end
  return D
end

# ============================================================================
# Write functions
function write_string_vec(io::IO, v::Array{String,1})
  b = isempty(v)
  write(io, b)
  if b == false
    write(io, Int64(length(v)))
    for s in v
      write(io, UInt16(sizeof(s)))
    end
    for s in v
      write(io, s)
    end
  end
  return nothing
end

function write_misc(io::IO, D::Dict{String,Any})
  L = Int64(length(D))
  write(io, L)
  if L != zero(Int64)
    K = keys(D)
    write_string_vec(io, collect(K))
    for v in values(D)
      T = typeof(v)
      t = typ2code(T)
      write(io, t)

      # String array
      if t == 0x81
        dims = Int64.(size(v))
        write(io, Int64(length(dims)))
        for i in dims
          write(io, i)
        end
        if dims != (0,)
          for s in v
            write(io, UInt16(sizeof(s)))
          end
          for s in v
            write(io, s)
          end
        end

      elseif T <: AbstractArray
        dims = Int64.(size(v))
        write(io, Int64(length(dims)))
        for i in dims
          write(io, i)
        end
        write(io, v)

      elseif T == String
        write(io, UInt16(sizeof(v)))
        write(io, v)

      elseif T <: Union{Char, AbstractFloat, Complex, Integer}
        write(io, v)
      end
    end
  end
  return nothing
end


text:
import DistributedFactorGraphs: getVariableType

"""
    CliqStatus
Clique status message enumerated type with status.
"""
@enum CliqStatus NULL NO_INIT INITIALIZED UPSOLVED MARGINALIZED DOWNSOLVED UPRECYCLED ERROR_STATUS

# Used for UPWARD_DIFFERENTIAL, UPWARD_COMMON, DOWNWARD_COMMON marginalized types
abstract type MessagePassDirection end
struct UpwardPass <: MessagePassDirection end
struct DownwardPass <: MessagePassDirection end

abstract type MessageType end
struct NonparametricMessage <: MessageType end
struct ParametricMessage <: MessageType end

const SamplableBelief = Union{Distributions.Distribution, KernelDensityEstimate.BallTreeDensity, AliasingScalarSampler, FluxModelsDistribution}

abstract type PackedSamplableBelief end

#Supported types for parametric
const ParametricTypes = Union{Normal, MvNormal}

"""
    $TYPEDEF

INTERMEDIATE DATA STRUCTURE DURING REFACTORING.

Representation of the belief of a single variable.

Notes:
- we want to send the joint, this is just to resolve consolidation #459 first.
- Long term objective is single joint definition, likely called `LikelihoodMessage`.
"""
struct TreeBelief{T <: InferenceVariable}
  val::Array{Float64,2}
  bw::Array{Float64,2}
  inferdim::Float64
  # see DFG #603, variableType defines the domain and manifold as well as group operations for a variable in the factor graph
  variableType::T
  # TODO -- DEPRECATE
  manifolds::Tuple{Vararg{Symbol}} # NOTE added during #459 effort
  # only populated during up as solvableDims for each variable in clique, #910
  solvableDim::Float64
end
TreeBelief( p::BallTreeDensity,
            inferdim::Real=0,
            variableType::T=ContinuousScalar(),
            manifolds=getManifolds(variableType),
            solvableDim::Real=0) where {T <: InferenceVariable} = TreeBelief{T}(getPoints(p), getBW(p), inferdim, variableType, manifolds, solvableDim)

TreeBelief( val::Array{Float64,2},
            bw::Array{Float64,2},
            inferdim::Real=0,
            variableType::T=ContinuousScalar(),
            manifolds=getManifolds(variableType),
            solvableDim::Real=0) where {T <: InferenceVariable} = TreeBelief{T}(val, bw, inferdim, variableType, manifolds, solvableDim)

function TreeBelief(vnd::VariableNodeData, solvDim::Real=0)
  TreeBelief( vnd.val, vnd.bw, vnd.inferdim, getVariableType(vnd), getManifolds(vnd), solvDim )
end

TreeBelief(vari::DFGVariable, solveKey::Symbol=:default; solvableDim::Real=0) = TreeBelief( getSolverData(vari, solveKey) , solvableDim)

getVariableType(tb::TreeBelief) = tb.variableType

getManifolds(treeb::TreeBelief) = getManifolds(treeb.variableType)

function compare(t1::TreeBelief, t2::TreeBelief)
  TP = true
  TP = TP && norm(t1.val - t2.val) < 1e-5
  TP = TP && norm(t1.bw - t2.bw) < 1e-5
  TP = TP && abs(t1.inferdim - t2.inferdim) < 1e-5
  TP = TP && t1.variableType == t2.variableType
  TP = TP && abs(t1.solvableDim - t2.solvableDim) < 1e-5
  return TP
end

#


text:
function fprop!(t::Convexity, g::DAT, b::VexityCache)
end

max_stars_repo_name: PSORLab/RSActivationFunctions

max_issues_repo_name: PSORLab/RSActivationFunctions

max_forks_repo_name: PSORLab/RSActivationFunctions


text:
abstract type AbstractSubOptimizer end

"""
sense 0.5 x'Qx + c'x + μ (s1 + s2)
subject to
c_lb <= Ax + b + s1 - s2 + s <= c_ub
v_lb <= x + x_k <= v_ub
-Δ <= x <= Δ
s1 + max(0,s) >= 0
s2 - min(0,s) >= 0
"""
struct QpData{T,Tv<:AbstractArray{T},Tm<:AbstractMatrix{T}}
    sense::MOI.OptimizationSense
    Q::Union{Nothing,Tm}
    c::Tv
    A::Tm
    b::Tv
    c_lb::Tv
    c_ub::Tv
    v_lb::Tv
    v_ub::Tv
    num_linear_constraints::Int
end

SubModel = Union{
    MOI.AbstractOptimizer,
    JuMP.AbstractModel,
}

include("subproblem_MOI.jl")
include("subproblem_JuMP.jl")


text:
using Regression
import Regression: solve, Options

# Data

k = 3
d = 5
n = 1000

W = randn(k, d+1)
X = randn(d, n)
U = (W[:,1:d] * X .+ W[:,d+1]) + 0.2 * randn(k, n)
y = vec(mapslices(indmax, U, 1))

# Solve

ret = solve(mlogisticreg(X, y, k; bias=1.0);
            reg=SqrL2Reg(1.0e-3),
            options=Options(verbosity=:iter, ftol=1.0e-5 * n))

println()

# Print results

W_est = ret.sol

@show size(W_est)
U_r = predict(MvAffinePred(d, k), W_est, X)
y_r = vec(mapslices(indmax, U_r, 1))

@printf("correct rate = %.4f\n", countnz(y .== y_r) / n)


text:
export RandomIdGenerator

using Random

"""
Customized id generators must implement the following two methods:

  - `generate_span_id(::AbstractIdGenerator)`
  - `generate_trace_id(::AbstractIdGenerator)`
"""
abstract type AbstractIdGenerator end

"""
    RandomIdGenerator(rng=Random.GLOBAL_RNG)

Use the `rng` to generate a random trace id or span id.
"""
Base.@kwdef struct RandomIdGenerator{R} <: AbstractIdGenerator
    rng::R = Random.GLOBAL_RNG
end

generate_trace_id(rng::RandomIdGenerator) = rand(rng.rng, TraceIdType)
generate_span_id(rng::RandomIdGenerator) = rand(rng.rng, SpanIdType)


text:
using Documenter, ItemGraphs

makedocs(
    format = Documenter.HTML(
		prettyurls = get(ENV, "CI", nothing) == "true",
	),
	sitename = "ItemGraphs.jl",
	authors = "Helge Eichhorn and the ItemGraphs.jl contributors",
	pages = [
		"Home" => "index.md",
		"API" => "api.md",
	],
)

deploydocs(
    repo = "github.com/helgee/ItemGraphs.jl.git",
    target = "build",
)


text:
using BenchmarkTools
using JuLIP
using JuLIP: AbstractAtoms, AbstractCalculator

function perfbm(id::AbstractString, at::AbstractAtoms, calc::AbstractCalculator;
                e = true, elist = true, f = true, flist = true)
   println("--------------------------------------------------------------------------")
   println(id)
   if e
      print("Energy Assembly (without nlist): ")
      @btime energy($calc, $at)
   end
   if elist
      print("Energy Assembly (with nlist):    ")
      @btime energy($calc,  rattle!($at, 0.001))
   end
   if f
      print("Force Assembly (without nlist):  ")
      @btime forces($calc, $at)
   end
   if flist
      print("Force Assembly (with nlist):     ")
      @btime forces($calc,  rattle!($at, 0.001))
   end
end

println()
println("≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡")
println("   JuLIP Performance Regression Tests")
println("≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡")
println()

perfbm("LENNARD-JONES",
         bulk(:Al, cubic=true) * (10,10,8),
         lennardjones(r0=rnn(:Al)) )

test_pots = joinpath(datadep"JuLIP_testpots", "JuLIP_data") * "/"
perfbm("EAM (Splines)",
         bulk(:Fe, cubic=true) * (12,12,8),
         EAM(test_pots * "pfe.plt", test_pots * "ffe.plt", test_pots * "F_fe.plt") )

perfbm("STILLINGER-WEBER",
         bulk(:Si, cubic=true) * (12,15,12),
         StillingerWeber())

##
using BenchmarkTools
using JuLIP
using JuLIP: AbstractAtoms, AbstractCalculator

at = bulk(:Al, cubic=true) * (10,10,8)
calc = lennardjones(r0=rnn(:Al))
tmp = JuLIP.alloc_temp(calc, at)
JuLIP.energy!(tmp, calc, at)

# Performance prior to restructuring
# TODO: fix performance of PairPotentials
# --------------------------------------------------------------------------
# LENNARD-JONES
# Energy Assembly (without nlist):   66.695 ms (41653 allocations: 47.65 MiB)
# Energy Assembly (with nlist):      68.778 ms (41675 allocations: 41.52 MiB)
# Force Assembly (without nlist):    73.158 ms (41657 allocations: 43.40 MiB)
# Force Assembly (with nlist):       72.561 ms (41677 allocations: 41.59 MiB)
# --------------------------------------------------------------------------
# EAM (Splines)
# Energy Assembly (without nlist):   69.074 ms (71535 allocations: 43.47 MiB)
# Energy Assembly (with nlist):      74.438 ms (71558 allocations: 44.49 MiB)
# Force Assembly (without nlist):    83.091 ms (69237 allocations: 44.23 MiB)
# Force Assembly (with nlist):       87.327 ms (69257 allocations: 44.51 MiB)
# --------------------------------------------------------------------------
# STILLINGER-WEBER
# Energy Assembly (without nlist):   78.205 ms (402680 allocations: 65.56 MiB)
# Energy Assembly (with nlist):      86.708 ms (410401 allocations: 69.01 MiB)
# Force Assembly (without nlist):    87.153 ms (411005 allocations: 67.34 MiB)
# Force Assembly (with nlist):       91.166 ms (410672 allocations: 69.42 MiB)

#= Performance after EAM changes.
--------------------------------------------------------------------------
LENNARD-JONES
Energy Assembly (without nlist):   3.146 ms (6 allocations: 2.28 KiB)
Energy Assembly (with nlist):      48.740 ms (57127 allocations: 36.55 MiB)
Force Assembly (without nlist):    5.892 ms (7 allocations: 79.31 KiB)
Force Assembly (with nlist):       51.531 ms (57139 allocations: 36.63 MiB)
--------------------------------------------------------------------------
EAM (Splines)
Energy Assembly (without nlist):   217.549 ms (4 allocations: 1.69 KiB)
Energy Assembly (with nlist):      238.427 ms (40496 allocations: 17.47 MiB)
Force Assembly (without nlist):    1.357 s (7 allocations: 57.22 KiB)
Force Assembly (with nlist):       1.398 s (40528 allocations: 18.23 MiB)
--------------------------------------------------------------------------
STILLINGER-WEBER
Energy Assembly (without nlist):   2.526 ms (6 allocations: 592 bytes)
Energy Assembly (with nlist):      36.546 ms (304948 allocations: 32.84 MiB)
Force Assembly (without nlist):    7.245 ms (14 allocations: 406.56 KiB)
Force Assembly (with nlist):       41.252 ms (304844 allocations: 33.23 MiB
=#


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

mutable struct AclStatus <: SwaggerModel
    entries::Any # spec type: Union{ Nothing, Vector{String} } # spec name: entries
    group::Any # spec type: Union{ Nothing, String } # spec name: group
    owner::Any # spec type: Union{ Nothing, String } # spec name: owner
    permission::Any # spec type: Union{ Nothing, Int32 } # spec name: permission
    stickyBit::Any # spec type: Union{ Nothing, Bool } # spec name: stickyBit

    function AclStatus(;entries=nothing, group=nothing, owner=nothing, permission=nothing, stickyBit=nothing)
        o = new()
        validate_property(AclStatus, Symbol("entries"), entries)
        setfield!(o, Symbol("entries"), entries)
        validate_property(AclStatus, Symbol("group"), group)
        setfield!(o, Symbol("group"), group)
        validate_property(AclStatus, Symbol("owner"), owner)
        setfield!(o, Symbol("owner"), owner)
        validate_property(AclStatus, Symbol("permission"), permission)
        setfield!(o, Symbol("permission"), permission)
        validate_property(AclStatus, Symbol("stickyBit"), stickyBit)
        setfield!(o, Symbol("stickyBit"), stickyBit)
        o
    end
end # type AclStatus

const _property_map_AclStatus = Dict{Symbol,Symbol}(Symbol("entries")=>Symbol("entries"), Symbol("group")=>Symbol("group"), Symbol("owner")=>Symbol("owner"), Symbol("permission")=>Symbol("permission"), Symbol("stickyBit")=>Symbol("stickyBit"))
const _property_types_AclStatus = Dict{Symbol,String}(Symbol("entries")=>"Vector{String}", Symbol("group")=>"String", Symbol("owner")=>"String", Symbol("permission")=>"Int32", Symbol("stickyBit")=>"Bool")
Base.propertynames(::Type{ AclStatus }) = collect(keys(_property_map_AclStatus))
Swagger.property_type(::Type{ AclStatus }, name::Symbol) = Union{Nothing,eval(Meta.parse(_property_types_AclStatus[name]))}
Swagger.field_name(::Type{ AclStatus }, property_name::Symbol) =  _property_map_AclStatus[property_name]

function check_required(o::AclStatus)
    true
end

function validate_property(::Type{ AclStatus }, name::Symbol, val)
end


text:
using LogCompose, Test, Logging, LogRoller, LogRollerCompose

function test()
    config = joinpath(@__DIR__, "testapp.toml")
    rotated_logfile = "testapp.log"
    rotated_tee_logfile = "testapptee.log"
    rotated_plain_logfile = "testplain.log"
    rm(rotated_logfile; force=true)
    rm(rotated_tee_logfile; force=true)
    rm(rotated_plain_logfile; force=true)

    let logger = LogCompose.logger(config, "testapp"; section="loggers")
        with_logger(logger) do
            @info("testroller")
        end
        @test isfile(rotated_logfile)
    end

    let logger = LogCompose.logger(config, "testapptee"; section="loggers")
        julia = joinpath(Sys.BINDIR, "julia")
        cmd = pipeline(`$julia -e 'println("testteefilewriter"); flush(stdout)'`; stdout=logger, stderr=logger)
        run(cmd)
    end

    let logger = LogCompose.logger(config, "plainfile"; section="loggers")
        julia = joinpath(Sys.BINDIR, "julia")
        cmd = pipeline(`$julia -e 'println("testplainfilewriter"); flush(stdout)'`; stdout=logger, stderr=logger)
        run(cmd)
    end

    log_file_contents = readlines(rotated_logfile)
    @test findfirst("testroller", log_file_contents[1]) !== nothing
    @test findfirst("testteefilewriter", log_file_contents[3]) !== nothing

    log_file_contents = readlines(rotated_tee_logfile)
    @test "testteefilewriter" == log_file_contents[1]

    log_file_contents = readlines(rotated_plain_logfile)
    @test "testplainfilewriter" == log_file_contents[1]

    try
        rm(rotated_logfile; force=true)
        rm(rotated_tee_logfile; force=true)
        rm(rotated_plain_logfile; force=true)
    catch ex
        # ignore errors due to file handles being busy on Windows
    end
end

test()


text:
using FractionalDim
using Base.Test

include("test_bbox_split.jl")
include("test_bbox_collisions.jl")
include("test_point_inside.jl")
include("test_param_eval.jl")
include("test_segment_collisions.jl")

include("test_counting_2d.jl")

max_stars_repo_name: MiroK/fractional-dim


text:
p = BigInt(2) ^ 1000
s = sum(map(x -> parse(Int, x), split(string(p), "")))
println(s)

max_stars_repo_name: sujimodern/project-euler-jl

max_issues_repo_name: sujimodern/project-euler-jl

max_forks_repo_name: sujimodern/project-euler-jl