text:
# syntax: proto3
using ProtoBuf
import ProtoBuf.meta

const ConnectionRequest_Type = (;[
    Symbol("RPC") => Int32(0),
    Symbol("STREAM") => Int32(1),
]...)

mutable struct ConnectionRequest <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function ConnectionRequest(; kwargs...)
        obj = new(meta(ConnectionRequest), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct ConnectionRequest
const __meta_ConnectionRequest = Ref{ProtoMeta}()
function meta(::Type{ConnectionRequest})
    ProtoBuf.metalock() do
        if !isassigned(__meta_ConnectionRequest)
            __meta_ConnectionRequest[] = target = ProtoMeta(ConnectionRequest)
            allflds = Pair{Symbol,Union{Type,String}}[:_type => Int32, :client_name => AbstractString, :client_identifier => Vector{UInt8}]
            meta(target, ConnectionRequest, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_ConnectionRequest[]
    end
end
function Base.getproperty(obj::ConnectionRequest, name::Symbol)
    if name === :_type
        return (obj.__protobuf_jl_internal_values[name])::Int32
    elseif name === :client_name
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    elseif name === :client_identifier
        return (obj.__protobuf_jl_internal_values[name])::Vector{UInt8}
    else
        getfield(obj, name)
    end
end

const ConnectionResponse_Status = (;[
    Symbol("OK") => Int32(0),
    Symbol("MALFORMED_MESSAGE") => Int32(1),
    Symbol("TIMEOUT") => Int32(2),
    Symbol("WRONG_TYPE") => Int32(3),
]...)

mutable struct ConnectionResponse <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function ConnectionResponse(; kwargs...)
        obj = new(meta(ConnectionResponse), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct ConnectionResponse
const __meta_ConnectionResponse = Ref{ProtoMeta}()
function meta(::Type{ConnectionResponse})
    ProtoBuf.metalock() do
        if !isassigned(__meta_ConnectionResponse)
            __meta_ConnectionResponse[] = target = ProtoMeta(ConnectionResponse)
            allflds = Pair{Symbol,Union{Type,String}}[:status => Int32, :message => AbstractString, :client_identifier => Vector{UInt8}]
            meta(target, ConnectionResponse, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_ConnectionResponse[]
    end
end
function Base.getproperty(obj::ConnectionResponse, name::Symbol)
    if name === :status
        return (obj.__protobuf_jl_internal_values[name])::Int32
    elseif name === :message
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    elseif name === :client_identifier
        return (obj.__protobuf_jl_internal_values[name])::Vector{UInt8}
    else
        getfield(obj, name)
    end
end

mutable struct Argument <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function Argument(; kwargs...)
        obj = new(meta(Argument), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct Argument
const __meta_Argument = Ref{ProtoMeta}()
function meta(::Type{Argument})
    ProtoBuf.metalock() do
        if !isassigned(__meta_Argument)
            __meta_Argument[] = target = ProtoMeta(Argument)
            allflds = Pair{Symbol,Union{Type,String}}[:position => UInt32, :value => Vector{UInt8}]
            meta(target, Argument, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_Argument[]
    end
end
function Base.getproperty(obj::Argument, name::Symbol)
    if name === :position
        return (obj.__protobuf_jl_internal_values[name])::UInt32
    elseif name === :value
        return (obj.__protobuf_jl_internal_values[name])::Vector{UInt8}
    else
        getfield(obj, name)
    end
end

mutable struct ProcedureCall <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function ProcedureCall(; kwargs...)
        obj = new(meta(ProcedureCall), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct ProcedureCall
const __meta_ProcedureCall = Ref{ProtoMeta}()
function meta(::Type{ProcedureCall})
    ProtoBuf.metalock() do
        if !isassigned(__meta_ProcedureCall)
            __meta_ProcedureCall[] = target = ProtoMeta(ProcedureCall)
            fnum = Int[1,2,4,5,3]
            allflds = Pair{Symbol,Union{Type,String}}[:service => AbstractString, :procedure => AbstractString, :service_id => UInt32, :procedure_id => UInt32, :arguments => Base.Vector{Argument}]
            meta(target, ProcedureCall, allflds, ProtoBuf.DEF_REQ, fnum, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_ProcedureCall[]
    end
end
function Base.getproperty(obj::ProcedureCall, name::Symbol)
    if name === :service
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    elseif name === :procedure
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    elseif name === :service_id
        return (obj.__protobuf_jl_internal_values[name])::UInt32
    elseif name === :procedure_id
        return (obj.__protobuf_jl_internal_values[name])::UInt32
    elseif name === :arguments
        return (obj.__protobuf_jl_internal_values[name])::Base.Vector{Argument}
    else
        getfield(obj, name)
    end
end

mutable struct Request <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function Request(; kwargs...)
        obj = new(meta(Request), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct Request
const __meta_Request = Ref{ProtoMeta}()
function meta(::Type{Request})
    ProtoBuf.metalock() do
        if !isassigned(__meta_Request)
            __meta_Request[] = target = ProtoMeta(Request)
            allflds = Pair{Symbol,Union{Type,String}}[:calls => Base.Vector{ProcedureCall}]
            meta(target, Request, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_Request[]
    end
end
function Base.getproperty(obj::Request, name::Symbol)
    if name === :calls
        return (obj.__protobuf_jl_internal_values[name])::Base.Vector{ProcedureCall}
    else
        getfield(obj, name)
    end
end

mutable struct Error <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function Error(; kwargs...)
        obj = new(meta(Error), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct Error
const __meta_Error = Ref{ProtoMeta}()
function meta(::Type{Error})
    ProtoBuf.metalock() do
        if !isassigned(__meta_Error)
            __meta_Error[] = target = ProtoMeta(Error)
            allflds = Pair{Symbol,Union{Type,String}}[:service => AbstractString, :name => AbstractString, :description => AbstractString, :stack_trace => AbstractString]
            meta(target, Error, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_Error[]
    end
end
function Base.getproperty(obj::Error, name::Symbol)
    if name === :service
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    elseif name === :name
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    elseif name === :description
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    elseif name === :stack_trace
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    else
        getfield(obj, name)
    end
end

mutable struct ProcedureResult <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function ProcedureResult(; kwargs...)
        obj = new(meta(ProcedureResult), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct ProcedureResult
const __meta_ProcedureResult = Ref{ProtoMeta}()
function meta(::Type{ProcedureResult})
    ProtoBuf.metalock() do
        if !isassigned(__meta_ProcedureResult)
            __meta_ProcedureResult[] = target = ProtoMeta(ProcedureResult)
            allflds = Pair{Symbol,Union{Type,String}}[:error => Error, :value => Vector{UInt8}]
            meta(target, ProcedureResult, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_ProcedureResult[]
    end
end
function Base.getproperty(obj::ProcedureResult, name::Symbol)
    if name === :error
        return (obj.__protobuf_jl_internal_values[name])::Error
    elseif name === :value
        return (obj.__protobuf_jl_internal_values[name])::Vector{UInt8}
    else
        getfield(obj, name)
    end
end

mutable struct Response <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function Response(; kwargs...)
        obj = new(meta(Response), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct Response
const __meta_Response = Ref{ProtoMeta}()
function meta(::Type{Response})
    ProtoBuf.metalock() do
        if !isassigned(__meta_Response)
            __meta_Response[] = target = ProtoMeta(Response)
            allflds = Pair{Symbol,Union{Type,String}}[:error => Error, :results => Base.Vector{ProcedureResult}]
            meta(target, Response, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_Response[]
    end
end
function Base.getproperty(obj::Response, name::Symbol)
    if name === :error
        return (obj.__protobuf_jl_internal_values[name])::Error
    elseif name === :results
        return (obj.__protobuf_jl_internal_values[name])::Base.Vector{ProcedureResult}
    else
        getfield(obj, name)
    end
end

mutable struct StreamResult <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function StreamResult(; kwargs...)
        obj = new(meta(StreamResult), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct StreamResult
const __meta_StreamResult = Ref{ProtoMeta}()
function meta(::Type{StreamResult})
    ProtoBuf.metalock() do
        if !isassigned(__meta_StreamResult)
            __meta_StreamResult[] = target = ProtoMeta(StreamResult)
            allflds = Pair{Symbol,Union{Type,String}}[:id => UInt64, :result => ProcedureResult]
            meta(target, StreamResult, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_StreamResult[]
    end
end
function Base.getproperty(obj::StreamResult, name::Symbol)
    if name === :id
        return (obj.__protobuf_jl_internal_values[name])::UInt64
    elseif name === :result
        return (obj.__protobuf_jl_internal_values[name])::ProcedureResult
    else
        getfield(obj, name)
    end
end

mutable struct StreamUpdate <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function StreamUpdate(; kwargs...)
        obj = new(meta(StreamUpdate), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct StreamUpdate
const __meta_StreamUpdate = Ref{ProtoMeta}()
function meta(::Type{StreamUpdate})
    ProtoBuf.metalock() do
        if !isassigned(__meta_StreamUpdate)
            __meta_StreamUpdate[] = target = ProtoMeta(StreamUpdate)
            allflds = Pair{Symbol,Union{Type,String}}[:results => Base.Vector{StreamResult}]
            meta(target, StreamUpdate, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_StreamUpdate[]
    end
end
function Base.getproperty(obj::StreamUpdate, name::Symbol)
    if name === :results
        return (obj.__protobuf_jl_internal_values[name])::Base.Vector{StreamResult}
    else
        getfield(obj, name)
    end
end

mutable struct Class <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function Class(; kwargs...)
        obj = new(meta(Class), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct Class
const __meta_Class = Ref{ProtoMeta}()
function meta(::Type{Class})
    ProtoBuf.metalock() do
        if !isassigned(__meta_Class)
            __meta_Class[] = target = ProtoMeta(Class)
            allflds = Pair{Symbol,Union{Type,String}}[:name => AbstractString, :documentation => AbstractString]
            meta(target, Class, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_Class[]
    end
end
function Base.getproperty(obj::Class, name::Symbol)
    if name === :name
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    elseif name === :documentation
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    else
        getfield(obj, name)
    end
end

mutable struct EnumerationValue <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function EnumerationValue(; kwargs...)
        obj = new(meta(EnumerationValue), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct EnumerationValue
const __meta_EnumerationValue = Ref{ProtoMeta}()
function meta(::Type{EnumerationValue})
    ProtoBuf.metalock() do
        if !isassigned(__meta_EnumerationValue)
            __meta_EnumerationValue[] = target = ProtoMeta(EnumerationValue)
            allflds = Pair{Symbol,Union{Type,String}}[:name => AbstractString, :value => Int32, :documentation => AbstractString]
            meta(target, EnumerationValue, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_EnumerationValue[]
    end
end
function Base.getproperty(obj::EnumerationValue, name::Symbol)
    if name === :name
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    elseif name === :value
        return (obj.__protobuf_jl_internal_values[name])::Int32
    elseif name === :documentation
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    else
        getfield(obj, name)
    end
end

mutable struct Enumeration <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function Enumeration(; kwargs...)
        obj = new(meta(Enumeration), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct Enumeration
const __meta_Enumeration = Ref{ProtoMeta}()
function meta(::Type{Enumeration})
    ProtoBuf.metalock() do
        if !isassigned(__meta_Enumeration)
            __meta_Enumeration[] = target = ProtoMeta(Enumeration)
            allflds = Pair{Symbol,Union{Type,String}}[:name => AbstractString, :values => Base.Vector{EnumerationValue}, :documentation => AbstractString]
            meta(target, Enumeration, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_Enumeration[]
    end
end
function Base.getproperty(obj::Enumeration, name::Symbol)
    if name === :name
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    elseif name === :values
        return (obj.__protobuf_jl_internal_values[name])::Base.Vector{EnumerationValue}
    elseif name === :documentation
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    else
        getfield(obj, name)
    end
end

mutable struct Exception <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function Exception(; kwargs...)
        obj = new(meta(Exception), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct Exception
const __meta_Exception = Ref{ProtoMeta}()
function meta(::Type{Exception})
    ProtoBuf.metalock() do
        if !isassigned(__meta_Exception)
            __meta_Exception[] = target = ProtoMeta(Exception)
            allflds = Pair{Symbol,Union{Type,String}}[:name => AbstractString, :documentation => AbstractString]
            meta(target, Exception, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_Exception[]
    end
end
function Base.getproperty(obj::Exception, name::Symbol)
    if name === :name
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    elseif name === :documentation
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    else
        getfield(obj, name)
    end
end

const Type_TypeCode = (;[
    Symbol("NONE") => Int32(0),
    Symbol("DOUBLE") => Int32(1),
    Symbol("FLOAT") => Int32(2),
    Symbol("SINT32") => Int32(3),
    Symbol("SINT64") => Int32(4),
    Symbol("UINT32") => Int32(5),
    Symbol("UINT64") => Int32(6),
    Symbol("BOOL") => Int32(7),
    Symbol("STRING") => Int32(8),
    Symbol("BYTES") => Int32(9),
    Symbol("CLASS") => Int32(100),
    Symbol("ENUMERATION") => Int32(101),
    Symbol("EVENT") => Int32(200),
    Symbol("PROCEDURE_CALL") => Int32(201),
    Symbol("STREAM") => Int32(202),
    Symbol("STATUS") => Int32(203),
    Symbol("SERVICES") => Int32(204),
    Symbol("TUPLE") => Int32(300),
    Symbol("LIST") => Int32(301),
    Symbol("SET") => Int32(302),
    Symbol("DICTIONARY") => Int32(303),
]...)

mutable struct _Type <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function _Type(; kwargs...)
        obj = new(meta(_Type), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct _Type
const __meta__Type = Ref{ProtoMeta}()
function meta(::Type{_Type})
    ProtoBuf.metalock() do
        if !isassigned(__meta__Type)
            __meta__Type[] = target = ProtoMeta(_Type)
            allflds = Pair{Symbol,Union{Type,String}}[:code => Int32, :service => AbstractString, :name => AbstractString, :types => Base.Vector{_Type}]
            meta(target, _Type, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta__Type[]
    end
end
function Base.getproperty(obj::_Type, name::Symbol)
    if name === :code
        return (obj.__protobuf_jl_internal_values[name])::Int32
    elseif name === :service
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    elseif name === :name
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    elseif name === :types
        return (obj.__protobuf_jl_internal_values[name])::Base.Vector{_Type}
    else
        getfield(obj, name)
    end
end

mutable struct Parameter <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function Parameter(; kwargs...)
        obj = new(meta(Parameter), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct Parameter
const __meta_Parameter = Ref{ProtoMeta}()
function meta(::Type{Parameter})
    ProtoBuf.metalock() do
        if !isassigned(__meta_Parameter)
            __meta_Parameter[] = target = ProtoMeta(Parameter)
            allflds = Pair{Symbol,Union{Type,String}}[:name => AbstractString, :_type => _Type, :default_value => Vector{UInt8}]
            meta(target, Parameter, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_Parameter[]
    end
end
function Base.getproperty(obj::Parameter, name::Symbol)
    if name === :name
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    elseif name === :_type
        return (obj.__protobuf_jl_internal_values[name])::_Type
    elseif name === :default_value
        return (obj.__protobuf_jl_internal_values[name])::Vector{UInt8}
    else
        getfield(obj, name)
    end
end

const Procedure_GameScene = (;[
    Symbol("SPACE_CENTER") => Int32(0),
    Symbol("FLIGHT") => Int32(1),
    Symbol("TRACKING_STATION") => Int32(2),
    Symbol("EDITOR_VAB") => Int32(3),
    Symbol("EDITOR_SPH") => Int32(4),
    Symbol("MISSION_BUILDER") => Int32(5),
]...)

mutable struct Procedure <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function Procedure(; kwargs...)
        obj = new(meta(Procedure), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct Procedure
const __meta_Procedure = Ref{ProtoMeta}()
function meta(::Type{Procedure})
    ProtoBuf.metalock() do
        if !isassigned(__meta_Procedure)
            __meta_Procedure[] = target = ProtoMeta(Procedure)
            fnum = Int[1,2,3,4,6,5]
            pack = Symbol[:game_scenes]
            allflds = Pair{Symbol,Union{Type,String}}[:name => AbstractString, :parameters => Base.Vector{Parameter}, :return_type => _Type, :return_is_nullable => Bool, :game_scenes => Base.Vector{Int32}, :documentation => AbstractString]
            meta(target, Procedure, allflds, ProtoBuf.DEF_REQ, fnum, ProtoBuf.DEF_VAL, pack, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_Procedure[]
    end
end
function Base.getproperty(obj::Procedure, name::Symbol)
    if name === :name
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    elseif name === :parameters
        return (obj.__protobuf_jl_internal_values[name])::Base.Vector{Parameter}
    elseif name === :return_type
        return (obj.__protobuf_jl_internal_values[name])::_Type
    elseif name === :return_is_nullable
        return (obj.__protobuf_jl_internal_values[name])::Bool
    elseif name === :game_scenes
        return (obj.__protobuf_jl_internal_values[name])::Base.Vector{Int32}
    elseif name === :documentation
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    else
        getfield(obj, name)
    end
end

mutable struct Service <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function Service(; kwargs...)
        obj = new(meta(Service), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct Service
const __meta_Service = Ref{ProtoMeta}()
function meta(::Type{Service})
    ProtoBuf.metalock() do
        if !isassigned(__meta_Service)
            __meta_Service[] = target = ProtoMeta(Service)
            allflds = Pair{Symbol,Union{Type,String}}[:name => AbstractString, :procedures => Base.Vector{Procedure}, :classes => Base.Vector{Class}, :enumerations => Base.Vector{Enumeration}, :exceptions => Base.Vector{Exception}, :documentation => AbstractString]
            meta(target, Service, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_Service[]
    end
end
function Base.getproperty(obj::Service, name::Symbol)
    if name === :name
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    elseif name === :procedures
        return (obj.__protobuf_jl_internal_values[name])::Base.Vector{Procedure}
    elseif name === :classes
        return (obj.__protobuf_jl_internal_values[name])::Base.Vector{Class}
    elseif name === :enumerations
        return (obj.__protobuf_jl_internal_values[name])::Base.Vector{Enumeration}
    elseif name === :exceptions
        return (obj.__protobuf_jl_internal_values[name])::Base.Vector{Exception}
    elseif name === :documentation
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    else
        getfield(obj, name)
    end
end

mutable struct Services <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function Services(; kwargs...)
        obj = new(meta(Services), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct Services
const __meta_Services = Ref{ProtoMeta}()
function meta(::Type{Services})
    ProtoBuf.metalock() do
        if !isassigned(__meta_Services)
            __meta_Services[] = target = ProtoMeta(Services)
            allflds = Pair{Symbol,Union{Type,String}}[:services => Base.Vector{Service}]
            meta(target, Services, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_Services[]
    end
end
function Base.getproperty(obj::Services, name::Symbol)
    if name === :services
        return (obj.__protobuf_jl_internal_values[name])::Base.Vector{Service}
    else
        getfield(obj, name)
    end
end

mutable struct Tuple <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function Tuple(; kwargs...)
        obj = new(meta(Tuple), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct Tuple
const __meta_Tuple = Ref{ProtoMeta}()
function meta(::Type{Tuple})
    ProtoBuf.metalock() do
        if !isassigned(__meta_Tuple)
            __meta_Tuple[] = target = ProtoMeta(Tuple)
            allflds = Pair{Symbol,Union{Type,String}}[:items => Base.Vector{Vector{UInt8}}]
            meta(target, Tuple, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_Tuple[]
    end
end
function Base.getproperty(obj::Tuple, name::Symbol)
    if name === :items
        return (obj.__protobuf_jl_internal_values[name])::Base.Vector{Vector{UInt8}}
    else
        getfield(obj, name)
    end
end

mutable struct List <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function List(; kwargs...)
        obj = new(meta(List), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct List
const __meta_List = Ref{ProtoMeta}()
function meta(::Type{List})
    ProtoBuf.metalock() do
        if !isassigned(__meta_List)
            __meta_List[] = target = ProtoMeta(List)
            allflds = Pair{Symbol,Union{Type,String}}[:items => Base.Vector{Vector{UInt8}}]
            meta(target, List, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_List[]
    end
end
function Base.getproperty(obj::List, name::Symbol)
    if name === :items
        return (obj.__protobuf_jl_internal_values[name])::Base.Vector{Vector{UInt8}}
    else
        getfield(obj, name)
    end
end

mutable struct _Set <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function _Set(; kwargs...)
        obj = new(meta(_Set), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct _Set
const __meta__Set = Ref{ProtoMeta}()
function meta(::Type{_Set})
    ProtoBuf.metalock() do
        if !isassigned(__meta__Set)
            __meta__Set[] = target = ProtoMeta(_Set)
            allflds = Pair{Symbol,Union{Type,String}}[:items => Base.Vector{Vector{UInt8}}]
            meta(target, _Set, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta__Set[]
    end
end
function Base.getproperty(obj::_Set, name::Symbol)
    if name === :items
        return (obj.__protobuf_jl_internal_values[name])::Base.Vector{Vector{UInt8}}
    else
        getfield(obj, name)
    end
end

mutable struct DictionaryEntry <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function DictionaryEntry(; kwargs...)
        obj = new(meta(DictionaryEntry), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct DictionaryEntry
const __meta_DictionaryEntry = Ref{ProtoMeta}()
function meta(::Type{DictionaryEntry})
    ProtoBuf.metalock() do
        if !isassigned(__meta_DictionaryEntry)
            __meta_DictionaryEntry[] = target = ProtoMeta(DictionaryEntry)
            allflds = Pair{Symbol,Union{Type,String}}[:key => Vector{UInt8}, :value => Vector{UInt8}]
            meta(target, DictionaryEntry, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_DictionaryEntry[]
    end
end
function Base.getproperty(obj::DictionaryEntry, name::Symbol)
    if name === :key
        return (obj.__protobuf_jl_internal_values[name])::Vector{UInt8}
    elseif name === :value
        return (obj.__protobuf_jl_internal_values[name])::Vector{UInt8}
    else
        getfield(obj, name)
    end
end

mutable struct Dictionary <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function Dictionary(; kwargs...)
        obj = new(meta(Dictionary), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct Dictionary
const __meta_Dictionary = Ref{ProtoMeta}()
function meta(::Type{Dictionary})
    ProtoBuf.metalock() do
        if !isassigned(__meta_Dictionary)
            __meta_Dictionary[] = target = ProtoMeta(Dictionary)
            allflds = Pair{Symbol,Union{Type,String}}[:entries => Base.Vector{DictionaryEntry}]
            meta(target, Dictionary, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_Dictionary[]
    end
end
function Base.getproperty(obj::Dictionary, name::Symbol)
    if name === :entries
        return (obj.__protobuf_jl_internal_values[name])::Base.Vector{DictionaryEntry}
    else
        getfield(obj, name)
    end
end

mutable struct Stream <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function Stream(; kwargs...)
        obj = new(meta(Stream), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct Stream
const __meta_Stream = Ref{ProtoMeta}()
function meta(::Type{Stream})
    ProtoBuf.metalock() do
        if !isassigned(__meta_Stream)
            __meta_Stream[] = target = ProtoMeta(Stream)
            allflds = Pair{Symbol,Union{Type,String}}[:id => UInt64]
            meta(target, Stream, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_Stream[]
    end
end
function Base.getproperty(obj::Stream, name::Symbol)
    if name === :id
        return (obj.__protobuf_jl_internal_values[name])::UInt64
    else
        getfield(obj, name)
    end
end

mutable struct Event <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function Event(; kwargs...)
        obj = new(meta(Event), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct Event
const __meta_Event = Ref{ProtoMeta}()
function meta(::Type{Event})
    ProtoBuf.metalock() do
        if !isassigned(__meta_Event)
            __meta_Event[] = target = ProtoMeta(Event)
            allflds = Pair{Symbol,Union{Type,String}}[:stream => Stream]
            meta(target, Event, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_Event[]
    end
end
function Base.getproperty(obj::Event, name::Symbol)
    if name === :stream
        return (obj.__protobuf_jl_internal_values[name])::Stream
    else
        getfield(obj, name)
    end
end

mutable struct Status <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function Status(; kwargs...)
        obj = new(meta(Status), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct Status
const __meta_Status = Ref{ProtoMeta}()
function meta(::Type{Status})
    ProtoBuf.metalock() do
        if !isassigned(__meta_Status)
            __meta_Status[] = target = ProtoMeta(Status)
            allflds = Pair{Symbol,Union{Type,String}}[:version => AbstractString, :bytes_read => UInt64, :bytes_written => UInt64, :bytes_read_rate => Float32, :bytes_written_rate => Float32, :rpcs_executed => UInt64, :rpc_rate => Float32, :one_rpc_per_update => Bool, :max_time_per_update => UInt32, :adaptive_rate_control => Bool, :blocking_recv => Bool, :recv_timeout => UInt32, :time_per_rpc_update => Float32, :poll_time_per_rpc_update => Float32, :exec_time_per_rpc_update => Float32, :stream_rpcs => UInt32, :stream_rpcs_executed => UInt64, :stream_rpc_rate => Float32, :time_per_stream_update => Float32]
            meta(target, Status, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_Status[]
    end
end
function Base.getproperty(obj::Status, name::Symbol)
    if name === :version
        return (obj.__protobuf_jl_internal_values[name])::AbstractString
    elseif name === :bytes_read
        return (obj.__protobuf_jl_internal_values[name])::UInt64
    elseif name === :bytes_written
        return (obj.__protobuf_jl_internal_values[name])::UInt64
    elseif name === :bytes_read_rate
        return (obj.__protobuf_jl_internal_values[name])::Float32
    elseif name === :bytes_written_rate
        return (obj.__protobuf_jl_internal_values[name])::Float32
    elseif name === :rpcs_executed
        return (obj.__protobuf_jl_internal_values[name])::UInt64
    elseif name === :rpc_rate
        return (obj.__protobuf_jl_internal_values[name])::Float32
    elseif name === :one_rpc_per_update
        return (obj.__protobuf_jl_internal_values[name])::Bool
    elseif name === :max_time_per_update
        return (obj.__protobuf_jl_internal_values[name])::UInt32
    elseif name === :adaptive_rate_control
        return (obj.__protobuf_jl_internal_values[name])::Bool
    elseif name === :blocking_recv
        return (obj.__protobuf_jl_internal_values[name])::Bool
    elseif name === :recv_timeout
        return (obj.__protobuf_jl_internal_values[name])::UInt32
    elseif name === :time_per_rpc_update
        return (obj.__protobuf_jl_internal_values[name])::Float32
    elseif name === :poll_time_per_rpc_update
        return (obj.__protobuf_jl_internal_values[name])::Float32
    elseif name === :exec_time_per_rpc_update
        return (obj.__protobuf_jl_internal_values[name])::Float32
    elseif name === :stream_rpcs
        return (obj.__protobuf_jl_internal_values[name])::UInt32
    elseif name === :stream_rpcs_executed
        return (obj.__protobuf_jl_internal_values[name])::UInt64
    elseif name === :stream_rpc_rate
        return (obj.__protobuf_jl_internal_values[name])::Float32
    elseif name === :time_per_stream_update
        return (obj.__protobuf_jl_internal_values[name])::Float32
    else
        getfield(obj, name)
    end
end

mutable struct MultiplexedRequest <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function MultiplexedRequest(; kwargs...)
        obj = new(meta(MultiplexedRequest), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct MultiplexedRequest
const __meta_MultiplexedRequest = Ref{ProtoMeta}()
function meta(::Type{MultiplexedRequest})
    ProtoBuf.metalock() do
        if !isassigned(__meta_MultiplexedRequest)
            __meta_MultiplexedRequest[] = target = ProtoMeta(MultiplexedRequest)
            allflds = Pair{Symbol,Union{Type,String}}[:connection_request => ConnectionRequest, :request => Request]
            meta(target, MultiplexedRequest, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_MultiplexedRequest[]
    end
end
function Base.getproperty(obj::MultiplexedRequest, name::Symbol)
    if name === :connection_request
        return (obj.__protobuf_jl_internal_values[name])::ConnectionRequest
    elseif name === :request
        return (obj.__protobuf_jl_internal_values[name])::Request
    else
        getfield(obj, name)
    end
end

mutable struct MultiplexedResponse <: ProtoType
    __protobuf_jl_internal_meta::ProtoMeta
    __protobuf_jl_internal_values::Dict{Symbol,Any}
    __protobuf_jl_internal_defaultset::Set{Symbol}

    function MultiplexedResponse(; kwargs...)
        obj = new(meta(MultiplexedResponse), Dict{Symbol,Any}(), Set{Symbol}())
        values = obj.__protobuf_jl_internal_values
        symdict = obj.__protobuf_jl_internal_meta.symdict
        for nv in kwargs
            fldname, fldval = nv
            fldtype = symdict[fldname].jtyp
            (fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
            if fldval !== nothing
                values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
            end
        end
        obj
    end
end # mutable struct MultiplexedResponse
const __meta_MultiplexedResponse = Ref{ProtoMeta}()
function meta(::Type{MultiplexedResponse})
    ProtoBuf.metalock() do
        if !isassigned(__meta_MultiplexedResponse)
            __meta_MultiplexedResponse[] = target = ProtoMeta(MultiplexedResponse)
            allflds = Pair{Symbol,Union{Type,String}}[:response => Response, :stream_update => StreamUpdate]
            meta(target, MultiplexedResponse, allflds, ProtoBuf.DEF_REQ, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES)
        end
        __meta_MultiplexedResponse[]
    end
end
function Base.getproperty(obj::MultiplexedResponse, name::Symbol)
    if name === :response
        return (obj.__protobuf_jl_internal_values[name])::Response
    elseif name === :stream_update
        return (obj.__protobuf_jl_internal_values[name])::StreamUpdate
    else
        getfield(obj, name)
    end
end

export ConnectionRequest_Type, ConnectionRequest, ConnectionResponse_Status, ConnectionResponse, Request, ProcedureCall, Argument, Response, ProcedureResult, Error, StreamUpdate, StreamResult, Services, Service, Procedure_GameScene, Procedure, Parameter, Class, Enumeration, EnumerationValue, Exception, Type_TypeCode, _Type, Tuple, List, _Set, Dictionary, DictionaryEntry, Stream, Event, Status, MultiplexedRequest, MultiplexedResponse


text:
function update_product_stress!(
    qpstress,
    basis,
    stiffness,
    transfstress,
    theta0,
    celldisp,
    points,
    jac,
    vectosymmconverter,
)
    dim = CutCell.dimension(basis)
    lambda, mu = CutCell.lame_coefficients(stiffness, +1)
    nump = size(points)[2]

    for qpidx = 1:nump
        p = points[:, qpidx]
        grad = CutCell.transform_gradient(gradient(basis, p), jac)
        NK = sum([CutCell.make_row_matrix(vectosymmconverter[k], grad[:, k]) for k = 1:dim])
        symmdispgrad = NK * celldisp

        inplanestress = (stiffness[+1] * symmdispgrad) - transfstress
        s33 = lambda * (symmdispgrad[1] + symmdispgrad[2]) - (lambda + 2mu / 3) * theta0

        numericalstress = vcat(inplanestress, s33)

        append!(qpstress, numericalstress)
    end
end

function update_parent_stress!(
    qpstress,
    basis,
    stiffness,
    celldisp,
    points,
    jac,
    vectosymmconverter,
)

    dim = CutCell.dimension(basis)
    lambda, mu = CutCell.lame_coefficients(stiffness, -1)
    nump = size(points)[2]
    for qpidx = 1:nump
        p = points[:, qpidx]
        grad = CutCell.transform_gradient(gradient(basis, p), jac)
        NK = sum([CutCell.make_row_matrix(vectosymmconverter[k], grad[:, k]) for k = 1:dim])
        symmdispgrad = NK * celldisp

        inplanestress = stiffness[-1] * symmdispgrad
        s33 = lambda * (symmdispgrad[1] + symmdispgrad[2])

        numericalstress = vcat(inplanestress, s33)

        append!(qpstress, numericalstress)
    end
end

function compute_stress_at_quadrature_points(
    nodaldisplacement,
    basis,
    stiffness,
    transfstress,
    theta0,
    cellquads,
    cutmesh,
)

    dim = CutCell.dimension(basis)
    ncells = CutCell.number_of_cells(cutmesh)
    qpstress = zeros(0)
    jac = CutCell.jacobian(cutmesh)
    vectosymmconverter = CutCell.vector_to_symmetric_matrix_converter()

    for cellid = 1:ncells
        s = CutCell.cell_sign(cutmesh, cellid)
        @assert s == -1 || s == 0 || s == +1
        if s == +1 || s == 0
            nodeids = CutCell.nodal_connectivity(cutmesh, +1, cellid)
            celldofs = CutCell.element_dofs(nodeids, dim)
            celldisp = nodaldisplacement[celldofs]
            points = cellquads[+1, cellid].points
            update_product_stress!(
                qpstress,
                basis,
                stiffness,
                transfstress,
                theta0,
                celldisp,
                points,
                jac,
                vectosymmconverter,
            )
        end
        if s == -1 || s == 0
            nodeids = CutCell.nodal_connectivity(cutmesh, -1, cellid)
            celldofs = CutCell.element_dofs(nodeids, dim)
            celldisp = nodaldisplacement[celldofs]
            points = cellquads[-1, cellid].points
            update_parent_stress!(
                qpstress,
                basis,
                stiffness,
                celldisp,
                points,
                jac,
                vectosymmconverter,
            )
        end
    end
    return reshape(qpstress, 4, :)
end

function parent_stress_at_interface_quadrature_points(
    nodaldisplacement,
    basis,
    stiffness,
    interfacequads,
    cutmesh,
)

    dim = CutCell.dimension(basis)
    qpstress = zeros(0)
    jac = CutCell.jacobian(cutmesh)
    vectosymmconverter = CutCell.vector_to_symmetric_matrix_converter()
    cellsign = CutCell.cell_sign(cutmesh)

    cellids = findall(cellsign .== 0)

    for cellid in cellids
        nodeids = CutCell.nodal_connectivity(cutmesh, -1, cellid)
        celldofs = CutCell.element_dofs(nodeids, dim)
        celldisp = nodaldisplacement[celldofs]
        points = interfacequads[-1, cellid].points
        update_parent_stress!(
            qpstress,
            basis,
            stiffness,
            celldisp,
            points,
            jac,
            vectosymmconverter,
        )
    end
    return reshape(qpstress, 4, :)
end

function product_stress_at_interface_quadrature_points(
    nodaldisplacement,
    basis,
    stiffness,
    transfstress,
    theta0,
    interfacequads,
    cutmesh,
)

    dim = CutCell.dimension(basis)
    qpstress = zeros(0)
    jac = CutCell.jacobian(cutmesh)
    vectosymmconverter = CutCell.vector_to_symmetric_matrix_converter()
    cellsign = CutCell.cell_sign(cutmesh)

    cellids = findall(cellsign .== 0)

    for cellid in cellids
        nodeids = CutCell.nodal_connectivity(cutmesh, +1, cellid)
        celldofs = CutCell.element_dofs(nodeids, dim)
        celldisp = nodaldisplacement[celldofs]
        points = interfacequads[+1, cellid].points
        update_product_stress!(
            qpstress,
            basis,
            stiffness,
            transfstress,
            theta0,
            celldisp,
            points,
            jac,
            vectosymmconverter,
        )
    end
    return reshape(qpstress, 4, :)
end

function compute_quadrature_points(cellquads, cutmesh)
    ncells = CutCell.number_of_cells(cutmesh)
    coords = zeros(2, 0)
    for cellid = 1:ncells
        s = CutCell.cell_sign(cutmesh, cellid)
        cellmap = CutCell.cell_map(cutmesh, cellid)
        @assert s == -1 || s == 0 || s == +1
        if s == +1 || s == 0
            coords = hcat(coords, cellmap(cellquads[+1, cellid].points))
        end
        if s == -1 || s == 0
            coords = hcat(coords, cellmap(cellquads[-1, cellid].points))
        end
    end
    return coords
end

ext: jl


text:
using SIAN

println("Setting up the problem")

ode = @ODEmodel(
  x1'(t) = -x1(t) * x5(t) / (k2 + x1(t)),
  x2'(t) = 2 * x1(t) * x5(t) / ((k2 + x1(t)) * 3) - k4 * x2(t),
  x3'(t) = k4 * (x2(t)) / 2 - k4 * x3(t),
  x4'(t) = x1(t) * x5(t) / (3 * (k2 + x1(t))) + k4 * (x2(t)) / 2 + k4 * x3(t),
  x5'(t) = -k3 * x5(t),
  y1(t) = x1(t),
  y2(t) = x2(t) + x3(t),
  y3(t) = x4(t)
)

res = identifiability_ode(ode, get_parameters(ode); p=0.99, p_mod=0, nthrds=1)

println(res)

max_stars_repo_name: iliailmer/SIAN-Julia

max_issues_repo_name: iliailmer/SIAN-Julia

max_forks_repo_name: iliailmer/SIAN-Julia


text:
@testset "Matrix orthonormalization tests" begin
    algs = [QRFact(),
            SVDFact(),
            SecondMomentMatching(),
            GramSchmidt()]
    for alg in algs
        U = randn(1000, 10)
        Z = randn(1000, 10)
        X = U*Z'
        orthonormalize!(U, Z, alg)
        @test maximum(abs.(U'*U - I)) <= 1e-8
        @test maximum(abs.(U*Z' - X)) <= 1e-8

        U = randn(1000, 10)
        orthonormalize!(U, alg)
        @test maximum(abs.(U'*U - I)) <= 1e-8
    end
end

@testset "LRA orthonormalization tests" begin
    algs = [QRFact(),
            SVDFact(),
            SecondMomentMatching(),
            GramSchmidt()]
    for alg in algs
        U = randn(1000, 10)
        Z = randn(1000, 10)
        X = U*Z'
        LRA = TwoFactorRepresentation(U,Z)
        orthonormalize!(LRA, alg)
        @test maximum(abs.(LRA.U'*LRA.U - I)) <= 1e-8
        @test maximum(abs.(LRA - X)) <= 1e-8

        U = randn(1000, 10)
        S = randn(10, 10)
        V = randn(1000, 10)
        X = U*S*V'
        LRA = SVDLikeRepresentation(U,S,V)
        orthonormalize!(LRA, alg)
        @test maximum(abs.(LRA.U'*LRA.U-I)) + maximum(abs.(LRA.V'*LRA.V-I)) <= 1e-8
        @test maximum(abs.(LRA - X)) <= 1e-8
    end
end


text:
isdefined(Base, :__precompile__) && __precompile__()

module ForwardDiff

using Compat

import Calculus
import NaNMath

#############################
# types/functions/constants #
#############################

# multithreading #
#----------------#

const IS_MULTITHREADED_JULIA = VERSION >= v"0.5.0-dev+923" && Base.Threads.nthreads() > 1

if IS_MULTITHREADED_JULIA
    const NTHREADS = Base.Threads.nthreads()
    @inline compat_threadid() = Base.Threads.threadid()
else
    const NTHREADS = 1
    @inline compat_threadid() = 1
end

# function generation #
#---------------------#

const AUTO_DEFINED_UNARY_FUNCS = map(first, Calculus.symbolic_derivatives_1arg())
const NANMATH_FUNCS = (:sin, :cos, :tan, :asin, :acos, :acosh,
                       :atanh, :log, :log2, :log10, :lgamma, :log1p)

# chunk handling #
#----------------#

const MAX_CHUNK_SIZE = 10

immutable Chunk{N}
    function Chunk()
        @assert N <= MAX_CHUNK_SIZE "cannot create Chunk{$N}: max chunk size is $(MAX_CHUNK_SIZE)"
        return new()
    end
end

@inline Base.copy(chunk::Chunk) = chunk

# This is type-unstable, which is why our docs advise users to manually enter a chunk size
# when possible. The type instability here doesn't really hurt performance, since most of
# the heavy lifting happens behind a function barrier, but it can cause inference to give up
# when predicting the final output type of API functions.
pickchunk(x) = Chunk{pickchunksize(x)}()

function pickchunksize(x)
    k = length(x)
    if k <= MAX_CHUNK_SIZE
        return k
    else
        # Constrained to chunk <= MAX_CHUNK_SIZE, minimize (in order of priority):
        #   1. the number of chunks that need to be computed
        #   2. the number of "left over" perturbations in the final chunk
        nchunks = round(Int, k / MAX_CHUNK_SIZE, RoundUp)
        return round(Int, k / nchunks, RoundUp)
    end
end

# abstract types #
#----------------#

abstract ForwardDiffResult

############
# includes #
############

include("partials.jl")
include("dual.jl")
include("cache.jl")
include("derivative.jl")
include("gradient.jl")
include("jacobian.jl")
include("hessian.jl")

###########
# exports #
###########

export Chunk, DerivativeResult, GradientResult, JacobianResult, HessianResult

end # module


text:
module Config
Tv = Float64

end

max_stars_repo_name: ooreilly/sbpjl

max_issues_repo_name: ooreilly/sbpjl

max_forks_repo_name: ooreilly/sbpjl


text:
# imaginary sqrt
function imqr(x)
    try
        sqrt(x) + 0im
    catch e
        sqrt(-x)im
    end
end
# imaginary sqrt call
println(imqr(1))
println(imqr(-1))

max_stars_repo_name: elucian/julia

max_issues_repo_name: elucian/julia

max_forks_repo_name: elucian/julia


text:
@testset "Elements" begin
  Qx, x = PolynomialRing(FlintQQ, "x")

  K1, a1 = NumberField(x^3 - 2, "a")
  O1 = EquationOrder(K1)

  K2, a2 = number_field(4*x^2 + 1, "a")
  O2 = maximal_order(K2)

  @testset "Construction" begin

    b1 = @inferred O1(2*a1^0)
    @test b1.elem_in_nf == 2*a1^0
    @test parent(b1) == O1
    @test typeof(b1) == NfOrdElem

    b2 = @inferred O1(2)
    @test parent(b2) == O1
    @test typeof(b2) == NfOrdElem
    @test b1 == b2

    b3 = @inferred O1(fmpz(2))
    @test parent(b3) == O1
    @test typeof(b3) == NfOrdElem
    @test b1 == b3

    b4 = @inferred O1([2, 0, 0])
    @test parent(b4) == O1
    @test typeof(b4) == NfOrdElem
    @test b4.has_coord
    @test b1 == b4

    b5 = @inferred O1([FlintZZ(2), FlintZZ(0), FlintZZ(0)])
    @test parent(b5) == O1
    @test typeof(b5) == NfOrdElem
    @test b5.has_coord
    @test b1 == b5

    b6 = @inferred O1(2*a1^0, [FlintZZ(2), FlintZZ(0), FlintZZ(0)])
    @test parent(b6) == O1
    @test typeof(b6) == NfOrdElem
    @test b6.has_coord
    @test b1 == b6

    b7 = @inferred O1()
    @test parent(b6) == O1
    @test typeof(b6) == NfOrdElem
  end

  b1 = O1(2*a1^0)
  b2 = O1(2)

  @testset "Deepcopy" begin
    b = @inferred O1(a1)
    bb = @inferred deepcopy(b)
    @test b == bb
  end

  @testset "Conversion to basis and number field" begin
    b = @inferred elem_in_nf(b1)
    @test b == K1(2)

    b = @inferred coordinates(b1)
    @test b == [ FlintZZ(2), FlintZZ(0), FlintZZ(0) ]

    b = O1(a1//2, false)
    @test_throws ErrorException coordinates(b)

    b = O1(a1)
    c = @inferred K1(b)
  @test c == a1

  end

  @testset "Discriminant" begin

    b = @inferred discriminant([O1(1), O1(2*a1), O1(4*a1^2)])
    @test b == 64 * -108

    @test_throws ErrorException discriminant([O1(1)])
  end

  @testset "Hashing" begin
    b = @inferred hash(b1)
    @test b == hash(b2)
  end

  @testset "Zero/one" begin
    b = @inferred one(O1)
    @test isone(b)

    b = @inferred one(b1)
    @test isone(b)

    b = @inferred zero(O1)
    @test iszero(b)

    b = @inferred zero(b1)
    @test iszero(b)
  end

  @testset "Unary operations" begin
    b = @inferred -b1
    @test b == O1(-2)
    b = -O1([2, 0, 0])
    @test b.has_coord
  end

  @testset "Binary operations" begin
    b = @inferred O1(a1) * O1(a1^2)
    @test b == O1(2)

    b = @inferred O1(a1) + O1(a1^2)
    c = O1(a1)
    c = @inferred add!(c, c, O1(a1^2))
    @test b == c
    c = O1(a1)
    c = @inferred addeq!(c, O1(a1^2))
    @test b == c
    @test b == O1(a1 + a1^2)

    c = @inferred O1([1, 0, 0]) + O1([0, 1, 0])
    @test c.has_coord

    b = @inferred O1(a1) - O1(a1^2)
    @test b == O1(a1 - a1^2)

    c = @inferred O1([1, 0, 0]) - O1([0, 1, 0])
    @test c.has_coord

    c = @inferred divexact(O1(a1^2), O1(a1))
    @test c == O1(a1)

    c = @inferred divexact(O1(a1^2), O1(a1), true)
    @test c == O1(a1)

    c = @inferred divexact(O1(a1^2), O1(a1), false)
    @test c == O1(a1)

    @test_throws ErrorException divexact(O1(1), O1(2))

    b = O1(2)
    c = @inferred b//b
    @test c isa elem_type(K1)
    @test c == 1
    c = @inferred b//3
    @test c isa elem_type(K1)
    @test c == 2//3
  end

  @testset "Ad hoc binary operations" begin
    b = O1(2*a1)
    c = @inferred 2 * O1(a1)
    @test b == c
    c = @inferred O1(a1) * 2
    @test b == c
    c = @inferred fmpz(2) * O1(a1)
    @test b == c
    c = @inferred O1(a1) * fmpz(2)
    @test b == c

    b = O1(2 + a1)
    c = @inferred 2 + O1(a1)
    @test b == c
    c = @inferred O1(a1) + 2
    @test b == c
    c = @inferred fmpz(2) + O1(a1)
    @test b == c
    c = @inferred O1(a1) + fmpz(2)
    @test b == c

    b = O1(2 - a1)
    c = @inferred 2 - O1(a1)
    @test b == c
    b1 = O1(a1)
    b1 = @inferred sub!(b1, b1, 2)
    @test b1 == -b
    b1 = sub!(b1, b1, -fmpz(2))
    @test b1 == O1(a1)
    c = @inferred -(O1(a1) - 2)
    @test b == c
    c = @inferred fmpz(2) - O1(a1)
    @test b == c
    c = @inferred -(O1(a1) - fmpz(2))
    @test b == c

    b = O1(2*a1)
    c = @inferred divexact(b, 2)
    @test c == O1(a1)
    c = @inferred divexact(b, fmpz(2))
    @test c == O1(a1)
    c = @inferred divexact(b, fmpz(2), true)
    @test c == O1(a1)
    c = @inferred divexact(b, fmpz(2), false)
    @test c == O1(a1)

    @test_throws ErrorException divexact(b, O1(4*a1))
  end

  @testset "Exponentiation" begin
    b = O1(a1)
    c = @inferred b^3
    @test c == O1(2)
    c = @inferred b^fmpz(3)
    @test c == O1(2)
  end

  @testset "Modular reduction" begin
    b = O1([3, 2, 2])
    c = @inferred mod(b, 2)
    @test c == O1(1)
    c = @inferred mod(b, fmpz(2))
    @test c == O1(1)
  end

  @testset "Modular exponentiation" begin
    b = O1(2*a1)
    c = @inferred powermod(b, fmpz(3), fmpz(3))
    @test c == O1(1)
    c = @inferred powermod(b, fmpz(3), 3)
    @test c == O1(1)
    c = @inferred powermod(b, 3, fmpz(3))
    @test c == O1(1)
    c = @inferred powermod(b, 3, 3)
    @test c == O1(1)

    b1 = O2(4*a2)
    c1 = @inferred powermod(b1, fmpz(2), fmpz(2))
    @test iszero(c1)
  end

  @testset "Representation matrix" begin
    b = O1(1)
    c = @inferred representation_matrix(b)
    @test c == one(MatrixSpace(FlintZZ, 3, 3))
    b = O1(a1)
    c = @inferred representation_matrix(b)
    @test c == FlintZZ[0 1 0; 0 0 1; 2 0 0]
    c = @inferred representation_matrix(b, K1)
    @test c == Hecke.FakeFmpqMat(FlintZZ[0 1 0; 0 0 1; 2 0 0], one(FlintZZ))
  end

  @testset "Trace" begin
    b = O1(a1)
    c = @inferred tr(b)
    @test c == 0
  end

  @testset "Norm" begin
    b = O1(a1)
    c = @inferred norm(b)
    @test c == 2
  end

  @testset "Random elements" begin
    B = 10
    b = @inferred rand(O1, -B:B)
    for i in 1:degree(O1)
      @test -B <= coordinates(b)[i] && coordinates(b)[i] <= B
    end

    B = BigInt(10)
    b = @inferred rand(O1, -B:B)
    B = fmpz(B)
    for i in 1:degree(O1)
      @test -B <= coordinates(b)[i] && coordinates(b)[i] <= B
    end

    B = 10
    b = @inferred rand(O1, B)
    for i in 1:degree(O1)
      @test -B <= coordinates(b)[i] && coordinates(b)[i] <= B
    end

    B = FlintZZ(10)
    b = @inferred rand(O1, B)
    for i in 1:degree(O1)
      @test -B <= coordinates(b)[i] && coordinates(b)[i] <= B
    end
  end

  RR = ArbField(64)

  @testset "Minkowski map" begin
    b = O1(a1)
    c = @inferred minkowski_map(b, 1024)
    @test overlaps(c[1], root(RR(2), 3))
    @test Hecke.radiuslttwopower(c[1], -1024)
    @test overlaps(c[2],  (-1//Base.sqrt(RR(2))*root(RR(2), 3)))
    @test Hecke.radiuslttwopower(c[2], -1024)
    @test overlaps(c[3], (Base.sqrt(RR(3)//RR(2))*root(RR(2), 3)))
    @test Hecke.radiuslttwopower(c[3], -1024)
  end

  CC = AcbField(64)

  @testset "Conjugates" begin
    b = O1(a1)
    c = @inferred conjugates_arb(b, 1024)
    @test isa(c, Vector{acb})
    @test overlaps(c[1], CC(root(RR(2), 3)))
    @test Hecke.radiuslttwopower(c[1], -1024)
    @test overlaps(c[2], (-CC(1)//2 + onei(CC)*Base.sqrt(RR(3))//2)*CC(root(RR(2), 3)))
    @test Hecke.radiuslttwopower(c[1], -1024)
    @test overlaps(c[3], (-CC(1)//2 - onei(CC)*Base.sqrt(RR(3))//2)*CC(root(RR(2), 3)))
    @test Hecke.radiuslttwopower(c[1], -1024)

    c = @inferred conjugates_arb_log(b, 1024)
    @test isa(c, Vector{arb})
    @test overlaps(c[1], log(RR(2))//3)
    @test Hecke.radiuslttwopower(c[1], -1024)
    @test overlaps(c[2], 2*log(RR(2))//3)
    @test Hecke.radiuslttwopower(c[2], -1024)
    @inferred t2(b)
  end

  @testset "Promotion rule" begin
    b = @inferred ==(O1(1), 1)
  end

  @testset "Factorization" begin
    K, a = NumberField(x^2 + 1, "a")
    OK = maximal_order(K)
    b = OK(2 * 3 * a)
    fac = @inferred factor(b)
    @test isunit(unit(fac)) == 1
    @test b == unit(fac) * prod(p^e for (p, e) in fac)

    K, a = NumberField(x^3 - 2, "a")
    OK = maximal_order(K)
    b = rand(OK, -10:10)
		while isone(abs(norm(b)))
      b = rand(OK, -10:10)
		end
    fac = @inferred factor(b)
    @test isunit(unit(fac))
    @test b == unit(fac) * prod(p^e for (p, e) in fac)
  end
end


text:
using ModelingToolkit
using LinearAlgebra
using SparseArrays: sparse
using Test

@variables a,b,c,d

# test some matrix operations don't throw errors
X = [a b;c d]
det(X)
lu(X)
inv(X)

# test operations with sparse arrays and Operations
# note `isequal` instead of `==` because `==` would give another Operation

# test that we can create a sparse array of Operation
Oarray = zeros(Operation, 2,2)
Oarray[2,2] = a
@test isequal(sparse(Oarray), sparse([2], [2], [a]))

# test Operation * sparse
@test isequal(a * sparse([2], [2], [1]), sparse([2], [2], [a * 1]))

# test sparse{Operation} + sparse{Operation}
A = sparse([2], [2], [a])
B = sparse([2], [2], [b])
@test isequal(A + B, sparse([2], [2], [a+b]))

# test sparse{Operation} * sparse{Operation}
C = sparse([1, 2], [2, 1], [c, c])
D = sparse([1, 2], [2, 1], [d, d])

@test isequal(C * D, sparse([1,2], [1,2], [c * d, c * d]))


text:
using Requires
@init @require CUDAnative = "be33ccc6-a3ff-5ff2-a52e-74243cff1e17" begin
  using .CUDAnative
end
using StaticArrays

"""
    band_lu_knl!(A, Val(Nq), Val(Nqi), Val(Nqj), Val(nstate), Val(nvertelem),
                 Val(nhorzelem), Val(eband))

This performs Band Gaussian Elimination (Algorithm 4.3.1 of Golub and Van
Loan).  The array `A` contains a band matrix for each vertical column.  For
example, `A[i, j, :, :, h]`, is the band matrix associated with the `(i, j)`th
degree of freedom in the horizontal element `h`.

Each `n` by `n` band matrix is assumed to have upper bandwidth `q` and lower
bandwidth `p` where `n = nstate * Nq * nvertelem` and `p = q = nstate * Nq *
eband - 1`.

Each band matrix is stored in the [LAPACK band storage](https://www.netlib.org/lapack/lug/node124.html).
For example the band matrix

    B = [b₁₁ b₁₂ 0   0   0
         b₂₁ b₂₂ b₂₃ 0   0
         b₃₁ b₃₂ b₃₃ b₃₄ 0
         0   b₄₂ b₄₃ b₄₄ b₄₅
         0   0   b₅₃ b₅₄ b₅₅]

is stored as

    B = [0   b₁₂ b₂₃ b₃₄ b₄₅
         b₁₁ b₂₂ b₃₃ b₄₄ b₅₅
         b₂₁ b₃₂ b₄₃ b₅₄ 0
         b₃₁ b₄₂ b₅₃ 0   0]

### Reference

    @book{GolubVanLoan,
      title = {Matrix Computations},
      author = {Gene H. Golub and Charles F. Van Loan},
      edition = {4th},
      isbn = {9781421407944},
      publisher = {Johns Hopkins University Press},
      address = {Baltimore, MD, USA},
      url = {http://www.cs.cornell.edu/cv/GVL4/golubandvanloan.htm},
      year = 2013
    }

"""
function band_lu_knl!(A, ::Val{Nq}, ::Val{Nqi}, ::Val{Nqj}, ::Val{nstate},
                      ::Val{nvertelem}, ::Val{nhorzelem},
                      ::Val{eband}) where {Nq, Nqi, Nqj, nstate, nvertelem,
                                           nhorzelem, eband}
  FT = eltype(A)
  n = nstate * Nq * nvertelem
  p = q = nstate * Nq * eband - 1

  @inbounds @loop for h in (1:nhorzelem; blockIdx().x)
    @loop for j in (1:Nqj; threadIdx().y)
      @loop for i in (1:Nqi; threadIdx().x)
        for v = 1:nvertelem
          for k = 1:Nq
            for s = 1:nstate
              kk = s + (k - 1) * nstate + (v - 1) * nstate * Nq

              Aq = A[i, j, q + 1, kk, h]
              for ii = 1:p
                A[i, j, q + ii + 1, kk, h] /= Aq
              end

              for jj = 1:q
                if jj + kk ≤ n
                  Ajj = A[i, j, q - jj + 1, jj + kk, h]
                  for ii = 1:p
                    A[i, j, q + ii - jj + 1, jj + kk, h] -=
                        A[i, j, q + ii + 1, kk, h] * Ajj
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end

"""
    band_forward_knl!(b, LU, Val(Nq), Val(Nqj), Val(nstate), Val(nvertelem),
                      Val(nhorzelem), Val(eband))

This performs Band Forward Substitution (Algorithm 4.3.2 of Golub and Van
Loan), i.e., the right-hand side `b` is replaced with the solution of `L*x=b`.

The array `b` is of the size `(Nq * Nqj * Nq, nstate, nvertelem * nhorzelem)`.

The LU-factorization array `LU` contains a single band matrix or one
for each vertical column, see [`band_lu!`](@ref).

Each `n` by `n` band matrix is assumed to have upper bandwidth `q` and lower
bandwidth `p` where `n = nstate * Nq * nvertelem` and `p = q = nstate * Nq *
eband - 1`.

### Reference

    @book{GolubVanLoan,
      title = {Matrix Computations},
      author = {Gene H. Golub and Charles F. Van Loan},
      edition = {4th},
      isbn = {9781421407944},
      publisher = {Johns Hopkins University Press},
      address = {Baltimore, MD, USA},
      url = {http://www.cs.cornell.edu/cv/GVL4/golubandvanloan.htm},
      year = 2013
    }

"""
function band_forward_knl!(b, LU::AbstractArray{T,N}, ::Val{Nq}, ::Val{Nqj},
                           ::Val{nstate}, ::Val{nvertelem}, ::Val{nhorzelem},
                           ::Val{eband}) where {T, N, Nq, Nqj, nstate,
                                                nvertelem, nhorzelem, eband}
  FT = eltype(b)
  n = nstate * Nq * nvertelem
  p = q = eband * nstate * Nq - 1

  l_b = MArray{Tuple{p+1}, FT}(undef)

  @inbounds @loop for h in (1:nhorzelem; blockIdx().x)
    @loop for j in (1:Nqj; threadIdx().y)
      @loop for i in (1:Nq; threadIdx().x)
        @unroll for v = 1:eband
          @unroll for k = 1:Nq
            @unroll for s = 1:nstate
              ijk = i + Nqj * (j-1) + Nq * Nqj * (k-1)
              ee = v + nvertelem * (h - 1)
              ii  = s + (k - 1) * nstate + (v - 1) * nstate * Nq
              l_b[ii] =  nvertelem ≥ v ? b[ijk, s, ee] : zero(FT)
            end
          end
        end

        for v = 1:nvertelem
          @unroll for k = 1:Nq
            @unroll for s = 1:nstate
              jj = s + (k - 1) * nstate + (v - 1) * nstate * Nq

              @unroll for ii = 2:p+1
                Lii = N == 2 ? LU[ii+q, jj] : LU[i, j, ii+q, jj, h]
                l_b[ii] -= Lii * l_b[1]
              end

              ijk = i + Nqj * (j-1) + Nq * Nqj * (k-1)
              ee = v + nvertelem * (h - 1)

              b[ijk, s, ee] = l_b[1]

              @unroll for ii = 1:p
                l_b[ii] = l_b[ii + 1]
              end

              if jj + p < n
                (idx, si) = fldmod1(jj + p + 1, nstate)
                (vi, ki) = fldmod1(idx, Nq)

                ijk = i + Nqj * (j-1) + Nq * Nqj * (ki-1)
                ee = vi + nvertelem * (h - 1)

                l_b[p + 1] = b[ijk, si, ee]
              end
            end
          end
        end
      end
    end
  end

  nothing
end

"""
    band_back_knl!(b, LU, Val(Nq), Val(Nqj), Val(nstate), Val(nvertelem),
                   Val(nhorzelem), Val(eband))

This performs Band Back Substitution (Algorithm 4.3.3 of Golub and Van
Loan), i.e., the right-hand side `b` is replaced with the solution of `U*x=b`.

The array `b` is of the size `(Nq * Nqj * Nq, nstate, nvertelem * nhorzelem)`.

The LU-factorization array `LU` contains a single band matrix or one
for each vertical column, see [`band_lu!`](@ref).

Each `n` by `n` band matrix is assumed to have upper bandwidth `q` and lower
bandwidth `p` where `n = nstate * Nq * nvertelem` and `p = q = nstate * Nq *
eband - 1`.

### Reference

    @book{GolubVanLoan,
      title = {Matrix Computations},
      author = {Gene H. Golub and Charles F. Van Loan},
      edition = {4th},
      isbn = {9781421407944},
      publisher = {Johns Hopkins University Press},
      address = {Baltimore, MD, USA},
      url = {http://www.cs.cornell.edu/cv/GVL4/golubandvanloan.htm},
      year = 2013
    }

"""
function band_back_knl!(b, LU::AbstractArray{T, N}, ::Val{Nq}, ::Val{Nqj},
                        ::Val{nstate}, ::Val{nvertelem}, ::Val{nhorzelem},
                        ::Val{eband}) where {T, N, Nq, Nqj, nstate, nvertelem,
                                             nhorzelem, eband}
  FT = eltype(b)
  n = nstate * Nq * nvertelem
  q = nstate * Nq * eband - 1

  l_b = MArray{Tuple{q+1}, FT}(undef)

  @inbounds @loop for h in (1:nhorzelem; blockIdx().x)
    @loop for j in (1:Nqj; threadIdx().y)
      @loop for i in (1:Nq; threadIdx().x)
        @unroll for v = nvertelem:-1:(nvertelem - eband + 1)
          @unroll for k = Nq:-1:1
            @unroll for s = nstate:-1:1
              vi = eband - nvertelem + v
              ii = s + (k - 1) * nstate + (vi - 1) * nstate * Nq

              ijk = i + Nqj * (j-1) + Nq * Nqj * (k-1)
              ee = v + nvertelem * (h - 1)

              l_b[ii] =  b[ijk, s, ee]
            end
          end
        end

        for v = nvertelem:-1:1
          @unroll for k = Nq:-1:1
            @unroll for s = nstate:-1:1
              jj = s + (k - 1) * nstate + (v - 1) * nstate * Nq

              l_b[q + 1] /= N == 2 ? LU[q + 1, jj] : LU[i, j, q + 1, jj, h]

              @unroll for ii = 1:q
                Uii = N == 2 ? LU[ii, jj] : LU[i, j, ii, jj, h]
                l_b[ii] -= Uii * l_b[q + 1]
              end

              ijk = i + Nqj * (j-1) + Nq * Nqj * (k-1)
              ee = v + nvertelem * (h - 1)

              b[ijk, s, ee] = l_b[q + 1]

              @unroll for ii = q:-1:1
                l_b[ii+1] = l_b[ii]
              end

              if jj - q  > 1
                (idx, si) = fldmod1(jj - q - 1, nstate)
                (vi, ki) = fldmod1(idx, Nq)

                ijk = i + Nqj * (j-1) + Nq * Nqj * (ki-1)
                ee = vi + nvertelem * (h - 1)

                l_b[1] = b[ijk, si, ee]
              end
            end
          end
        end
      end
    end
  end

  nothing
end

function knl_set_banded_data!(bl::BalanceLaw, ::Val{dim}, ::Val{N},
                              ::Val{nvertelem}, Q, kin, sin, evin, helems,
                              velems) where {dim, N, nvertelem}
  FT = eltype(Q)

  Nq = N + 1
  Nqj = dim == 2 ? 1 : Nq
  nstate = num_state(bl,FT)

  @inbounds @loop for eh in (helems; blockIdx().y)
    @loop for ev in (velems; blockIdx().x)
      e = ev + (eh - 1) * nvertelem
      @loop for k in (1:Nq; threadIdx().z)
        @loop for j in (1:Nqj; threadIdx().y)
          @loop for i in (1:Nq; threadIdx().x)
            ijk = i + Nqj * (j-1) + Nq * Nqj * (k-1)
            @unroll for s = 1:nstate
              if k == kin && s == sin && evin == ev
                Q[ijk, s, e] = 1
              else
                Q[ijk, s, e] = 0
              end
            end
          end
        end
      end
    end
  end
  nothing
end

function knl_set_banded_matrix!(bl::BalanceLaw, ::Val{dim}, ::Val{N},
                                ::Val{nvertelem}, ::Val{p}, ::Val{q},
                                ::Val{eshift}, A::AbstractArray{FT, AN}, dQ,
                                kin, sin, evin, helems, vpelems
                               ) where {dim, N, nvertelem, p, q, eshift,
                                        FT, AN}
  Nq = N + 1
  Nqj = dim == 2 ? 1 : Nq
  nstate = num_state(bl,FT)

  # sin, kin, evin are the state, vertical fod, and vert element we are
  # handling

  # column index of matrix
  jj = sin + (kin - 1) * nstate + (evin - 1) * nstate * Nq

  # one thread is launch for dof that might contribute to column jj's band
  @inbounds @loop for eh in (helems; blockIdx().y)
    @loop for ep in (vpelems; blockIdx().x - eshift)
      # ep is the shift we need to add to evin to get the element we need to
      # consider
      ev = ep + evin
      if 1 ≤ ev ≤ nvertelem
        e = ev + (eh - 1) * nvertelem
        @loop for k in (1:Nq; threadIdx().z)
          @loop for j in (1:Nqj; threadIdx().y)
            @loop for i in (1:Nq; threadIdx().x)
              ijk = i + Nqj * (j-1) + Nq * Nqj * (k-1)
              @unroll for s = 1:nstate
                # row index of matrix
                ii = s + (k - 1) * nstate + (ev - 1) * nstate * Nq
                # row band index
                bb = ii - jj
                # make sure we're in the bandwidth
                if -q ≤ bb ≤ p
                  if AN === 5
                    A[i, j, bb + q+1, jj, eh] = dQ[ijk, s, e]
                  elseif AN === 2
                    if (i, j, eh) == (1, 1, 1)
                      A[bb + q+1, jj] = dQ[ijk, s, e]
                    end
                  end
                end
              end
            end
          end
        end
      end
    end
  end
  nothing
end

function knl_banded_matrix_vector_product!(bl::BalanceLaw, ::Val{dim}, ::Val{N},
                                           ::Val{nvertelem}, ::Val{p}, ::Val{q},
                                           dQ, A::AbstractArray{FT, AN}, Q,
                                           helems, velems
                                          ) where {dim, N, nvertelem, p, q, FT,
                                                   AN}

  Nq = N + 1
  Nqj = dim == 2 ? 1 : Nq
  nstate = num_state(bl,FT)

  elo = div(q, Nq * nstate-1)
  eup = div(p, Nq * nstate-1)

  # matrix row loops
  @loop for eh in (helems; blockIdx().y)
    @loop for ev in (velems; blockIdx().x)
      e = ev + nvertelem * (eh - 1)
      @loop for k in (1:Nq; threadIdx().z)
        @loop for j in (1:Nqj; threadIdx().y)
          @loop for i in (1:Nq; threadIdx().x)
            @unroll for s = 1:nstate
              Ax = -zero(FT)
              ii = s + (k - 1) * nstate + (ev - 1) * nstate * Nq

              # banded matrix column loops
              @unroll for evv = max(1, ev-elo):min(nvertelem, ev+eup)
                ee = evv + nvertelem * (eh - 1)
                @unroll for kk = 1:Nq
                  ijk = i + Nqj * (j-1) + Nq * Nqj * (kk-1)
                  @unroll for ss = 1:nstate
                    jj = ss + (kk - 1) * nstate + (evv - 1) * nstate * Nq
                    bb = ii - jj
                    if -q ≤ bb ≤ p
                      if AN === 5
                        Ax += A[i, j, bb + q + 1, jj, eh] * Q[ijk, ss, ee]
                      elseif AN === 2
                        Ax += A[bb + q + 1, jj] * Q[ijk, ss, ee]
                      end
                    end
                  end
                end
              end
              ijk = i + Nqj * (j-1) + Nq * Nqj * (k-1)
              dQ[ijk, s, e] = Ax
            end
          end
        end
      end
    end
  end
  nothing
end

max_stars_repo_name: emassoud/CLIMA

max_issues_repo_name: emassoud/CLIMA

max_forks_repo_name: emassoud/CLIMA


text:
ROOT=pwd()
include(joinpath(ROOT,"..","src_PowSysMod", "PowSysMod_body.jl"))

path = joinpath("instances", "IIDM", "etat_reseau")
data_branches = readdlm(joinpath(path, "eod2020_network_branches.txt"))
data_buses = readdlm(joinpath(path, "eod2020_network_buses.txt"))
data_generators = readdlm(joinpath(path, "eod2020_network_generators.txt"))
data_limits = readdlm(joinpath(path, "eod2020_network_limits.txt"))
data_loads = readdlm(joinpath(path, "eod2020_network_loads.txt"))
data_substations = readdlm(joinpath(path, "eod2020_network_substations.txt"))

bus = Dict{String, Dict{String, Any}}()

for i=1:size(data_buses, 1)
    busid = Int(data_buses[i, 1])
    substationid = Int(data_buses[i, 2])
    V = data_buses[i, 4] # p.u.
    θ = data_buses[i, 5] # radians
    P, Q = data_buses[i, 6:7]
    basekV, minV, maxV = data_substations[substationid, 4:6]

    busname = "BUS_$busid"
    data_buses[i, 3] == 0 || warn("Buses - $busname : parameter cc!=0 ($(data_buses[i, 3])), not handled")
    data_buses[i, 8] == 0 || warn("Buses - $busname : parameter fault!=0 ($(data_buses[i, 8])), not handled")
    data_buses[i, 9] == 0 || warn("Buses - $busname : parameter curative!=0 ($(data_buses[i, 9])), not handled")

    bus[busname] = Dict{String, Any}()
    bus[busname]["Volt"] = IIDMVolt(busname, busid, string(substationid), basekV, minV, maxV, V, θ, P, Q)
end

for i=1:size(data_loads, 2)
    busid = data_loads[i, 2]
    P, Q = data_loads[i, 4:5]
    busname = "BUS_$busid"

    data_loads[i, 6] == 0 || warn("Loads - $busname : parameter fault!=0 ($(data_loads[i, 6])), not handled")
    data_loads[i, 7] == 0 || warn("Loads - $busname : parameter curative!=0 ($(data_loads[i, 7])), not handled")

    bus_elems = bus["$busname"]
    nb = count([ismatch(r"Load_", x) for x in keys(bus_elems)])
    bus_elems["Load_$(nb+1)"] = IIDMLoad(string(nb+1), P+im*Q)
end

for i=1:size(data_generators, 1)
    busid = data_generators[i, 2]
    minP, maxP = data_generators[i, 5:6]
    volt_regulator_on, targetV = data_generators[i, 11:12]
    minQmaxP, minQminP, maxQmaxP, maxQminP = data_generators[i, 7:10]
    S_bounds = Set([(minP+im*minQminP, minP+im*maxQminP), (maxP+im*minQmaxP, maxP+im*maxQmaxP)])
    busname = "BUS_$busid"

    data_generators[i, 2] == data_generators[i, 3] || warn("Generators - $busname : 'bus' is not 'con. bus', not handled")
    data_generators[i, 15] == 0 || warn("Loads - $busname : parameter fault!=0 ($(data_generators[i, 15])), not handled")
    data_generators[i, 16] == 0 || warn("Loads - $busname : parameter curative!=0 ($(data_generators[i, 16])), not handled")

    bus_elems = bus["$busname"]
    nb = count([ismatch(r"Gen_", x) for x in keys(bus_elems)])
    bus_elems["Gen_$(nb+1)"] = IIDMGeneratorFuel(string(nb+1), minP, maxP, targetV, volt_regulator_on, S_bounds)
end

link = Dict{Link, Dict{String, IIDMLine_π}}()
for i=1:size(data_branches, 1)
    busid1, busid2 = data_branches[i, 2:3]
    r, x, g1, g2, b1, b2 = data_branches[i, 7:12]
    p1, p2, q1, q2 = data_branches[i, 16:19]

    linkname = Link("BUS_$busid1", "BUS_$busid2")
    if !haskey(link, linkname)
        link[linkname] = Dict{String, IIDMLine_π}()
    end
    link_elems = link[link_elems]

    nb = count([ismatch(r"Branch_", x) for x in keys(bus_elems)])
    bus_elems["Branch_$(nb+1)"] = IIDMLine_π(r, x, g1+im*b1, g2+im*b2, p1+im*q1, p2+im*q2, basekV_orig, basekV_dest, lim)
end

find(data_branches[:, 13] .!= 1)
find(data_branches[:, 14] .!= -1)
find(data_branches[:, 15] .!= -1)

data = readdlm(filename)

find(data[:, 4] .== -1)

path = joinpath("instances", "IIDM", "etat_reseau")

data = readdlm(filename)

find(data[:, 1] .!= 0)

max_stars_repo_name: Gimaju/GOC

max_issues_repo_name: Gimaju/GOC

max_forks_repo_name: Gimaju/GOC


text:
@test coloropp(WHITE) == BLACK
@test coloropp(BLACK) == WHITE

@test colorfromchar('w') == WHITE
@test colorfromchar('b') == BLACK
@test isnothing(colorfromchar('?'))

@test tochar(WHITE) == 'w'
@test tochar(BLACK) == 'b'

@test piecetypefromchar('p') == PAWN
@test piecetypefromchar('P') == PAWN
@test piecetypefromchar('n') == KNIGHT
@test piecetypefromchar('N') == KNIGHT
@test piecetypefromchar('b') == BISHOP
@test piecetypefromchar('B') == BISHOP
@test piecetypefromchar('r') == ROOK
@test piecetypefromchar('R') == ROOK
@test piecetypefromchar('q') == QUEEN
@test piecetypefromchar('Q') == QUEEN
@test piecetypefromchar('k') == KING
@test piecetypefromchar('K') == KING

@test tochar(PAWN, false) == 'p'
@test tochar(PAWN, true) == 'P'
@test tochar(KNIGHT, false) == 'n'
@test tochar(KNIGHT, true) == 'N'
@test tochar(BISHOP, false) == 'b'
@test tochar(BISHOP, true) == 'B'
@test tochar(ROOK, false) == 'r'
@test tochar(ROOK, true) == 'R'
@test tochar(QUEEN, false) == 'q'
@test tochar(QUEEN, true) == 'Q'
@test tochar(KING, false) == 'k'
@test tochar(KING, true) == 'K'

const ALL_COLORS = [WHITE, BLACK]
const ALL_PIECE_TYPES = [PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING]

for t in ALL_PIECE_TYPES
    @test piecetypefromchar(tochar(t)) == t
end

for c in ALL_COLORS
    for t in ALL_PIECE_TYPES
        p = Piece(c, t)
        @test c == pcolor(p)
        @test t == ptype(p)
    end
end

const ALL_PIECES = [
    PIECE_WP,
    PIECE_WN,
    PIECE_WB,
    PIECE_WR,
    PIECE_WQ,
    PIECE_WK,
    PIECE_BP,
    PIECE_BN,
    PIECE_BB,
    PIECE_BR,
    PIECE_BQ,
    PIECE_BK,
]

for p in ALL_PIECES
    @test p == Piece(pcolor(p), ptype(p))
    @test p == piecefromchar(tochar(p))
end

@test !isslider(PIECE_WP)
@test !isslider(PIECE_WN)
@test isslider(PIECE_WB)
@test isslider(PIECE_WR)
@test isslider(PIECE_WQ)
@test !isslider(PIECE_WK)
@test !isslider(PIECE_BP)
@test !isslider(PIECE_BN)
@test isslider(PIECE_BB)
@test isslider(PIECE_BR)
@test isslider(PIECE_BQ)
@test !isslider(PIECE_BK)


text:
# Dummy bridges used for testing
module IdentityBridges

import MathOptInterface
const MOI = MathOptInterface
const MOIB = MOI.Bridges

const F{T} = MOI.ScalarAffineFunction{T}
const S{T} = MOI.EqualTo{T}

struct VariableBridge{T} <: MOIB.Variable.SetMapBridge{T,S{T},S{T}}
    variable::MOI.VariableIndex
    constraint::MOI.ConstraintIndex{MOI.VariableIndex,S{T}}
end

struct ConstraintBridge{T} <:
       MOIB.Constraint.SetMapBridge{T,S{T},S{T},F{T},F{T}}
    constraint::MOI.ConstraintIndex{F{T},S{T}}
end

const IdentityBridge{T} = Union{VariableBridge{T},ConstraintBridge{T}}

MOIB.map_set(::Type{<:IdentityBridge}, set::S) = set
MOIB.inverse_map_set(::Type{<:IdentityBridge}, set::S) = set
MOIB.map_function(::Type{<:IdentityBridge}, func) = func
MOIB.inverse_map_function(::Type{<:IdentityBridge}, func) = func
MOIB.adjoint_map_function(::Type{<:IdentityBridge}, func) = func
MOIB.inverse_adjoint_map_function(::Type{<:IdentityBridge}, func) = func

struct ObjectiveBridge{T} <: MOIB.Objective.AbstractBridge end

function MOIB.Objective.bridge_objective(
    ::Type{ObjectiveBridge{T}},
    model::MOI.ModelLike,
    func::F{T},
) where {T}
    MOI.set(model, MOI.ObjectiveFunction{F}(), func)
    return ObjectiveBridge{T}()
end

function MOIB.Objective.supports_objective_function(
    ::Type{ObjectiveBridge{T}},
    ::Type{F{T}},
) where {T}
    return true
end

function MOIB.added_constrained_variable_types(::Type{<:ObjectiveBridge})
    return Tuple{DataType}[]
end

function MOIB.added_constraint_types(::Type{<:ObjectiveBridge})
    return Tuple{DataType,DataType}[]
end

function MOIB.set_objective_function_type(::Type{ObjectiveBridge{T}}) where {T}
    return F{T}
end

# Attributes, Bridge acting as a model
function MOI.get(::ObjectiveBridge, ::MOI.NumberOfVariables)
    return 0
end

function MOI.get(::ObjectiveBridge, ::MOI.ListOfVariableIndices)
    return MOI.VariableIndex[]
end

# No variables or constraints are created in this bridge so there is nothing to
# delete.
MOI.delete(model::MOI.ModelLike, bridge::ObjectiveBridge) = nothing

function MOI.set(
    ::MOI.ModelLike,
    ::MOI.ObjectiveSense,
    ::ObjectiveBridge,
    ::MOI.OptimizationSense,
)
    # `ObjectiveBridge` is sense agnostic, therefore, we don't need to change
    # anything.
    return
end

function MOI.get(
    model::MOI.ModelLike,
    attr::Union{MOIB.ObjectiveFunctionValue{F{T}},MOI.ObjectiveFunction{F{T}}},
    ::ObjectiveBridge{T},
) where {T}
    return MOI.get(model, attr)
end

end


text:
using BinaryBuilder

versionstr = "0.6"
version = VersionNumber(versionstr)

sources = [
    "https://github.com/michaelforney/samurai/releases/download/$(versionstr)/samurai-$(versionstr).tar.gz" =>
        "b1ead55ec7b319e08e1c66924c55c2af467f32a250cb86827b7a4496b6a8822f",
]

script = raw"""
cd samurai-0.6
make install PREFIX=${prefix}
ln -s samu ${prefix}/bin/ninja
"""

platforms = [
 Linux(:i686, libc=:glibc)
 Linux(:x86_64, libc=:glibc)
# Linux(:aarch64, libc=:glibc) #struct st_mtim error
 Linux(:armv7l, libc=:glibc, call_abi=:eabihf)
 Linux(:powerpc64le, libc=:glibc)
 Linux(:i686, libc=:musl)
 Linux(:x86_64, libc=:musl)
 Linux(:aarch64, libc=:musl)
 Linux(:armv7l, libc=:musl, call_abi=:eabihf)
 MacOS(:x86_64)
 FreeBSD(:x86_64)
# Windows(:i686) # not supported
# Windows(:x86_64) # not supported
]

products(prefix) = [
    ExecutableProduct(prefix, "ninja", :ninja)
    ExecutableProduct(prefix, "samu", :samu)
]

dependencies = [
]

build_tarballs(ARGS, "samurai", version, sources, script, platforms, products, dependencies)

max_stars_repo_name: benlorenz/samuraiBuilder

max_issues_repo_name: benlorenz/samuraiBuilder

max_forks_repo_name: benlorenz/samuraiBuilder


text:
@time @testset "block_sizes" begin

    for T ∈ [Float32, Float64, Int16, Int32, Int64, UInt16, UInt32, UInt64]
        @inferred Octavian.block_sizes(T)
        @inferred Octavian.first_cache_size(T)
        @inferred Octavian.second_cache_size(T)
    end

    @inferred Octavian.MᵣW_mul_factor()
    @inferred Octavian.W₁Default()
    @inferred Octavian.W₂Default()
    @inferred Octavian.R₁Default()
    @inferred Octavian.R₂Default()

    @inferred Octavian.first_cache()
    @inferred Octavian.second_cache()

    @inferred Octavian.first_cache_size()
    @inferred Octavian.second_cache_size()

    @inferred Octavian.bcache_count()

end


text:
struct RigidWall
    rs # Riemann solver
end

function reflect(p::PrimitiveVars,
                 velocity::Float64)::PrimitiveVars
    return PrimitiveVars(p.density,
                         p.pressure,
                         2*velocity-p.velocity)
end

function reflect(p::RPCond,
                 velocity::Float64)::RPCond
    return RPCond(p.density,
                  p.pressure,
                  2*velocity-p.velocity,
                  p.sound_speed,
                  p.energy)
end

function calcLeftFlux(bc::RigidWall,
                      state::HydroSnapshot,
                      edge_velocities::Array{Float64,1},
                      eos,
                      cached)::Conserved
    rpcond = RPCond(state.cells[1].density,
                    state.cells[1].pressure,
                    state.cells[1].velocity,
                    cached["sound_speeds"][1],
                    cached["energies"][1])
    return calcFlux(bc.rs,
                    reflect(rpcond,edge_velocities[1]),
                    rpcond,
                    edge_velocities[1],
                    eos)
end

function calcRightFlux(bc::RigidWall,
                       state::HydroSnapshot,
                       edge_velocities::Array{Float64,1},
                       eos,
                       cached)::Conserved
    rpcond = RPCond(state.cells[end].density,
                    state.cells[end].pressure,
                    state.cells[end].velocity,
                    cached["sound_speeds"][end],
                    cached["energies"][end])
    return calcFlux(bc.rs,
                    rpcond,
                    reflect(rpcond,edge_velocities[end]),
                    edge_velocities[end],
                    eos)
end

max_stars_repo_name: bolverk/Sirion

max_issues_repo_name: bolverk/Sirion

max_forks_repo_name: bolverk/Sirion