text:
B = Array{Int}(2, 3, 4, 5, 6)

n = 0
for i5=1:6, i4=1:5, i3=1:4
    n += 1
    B[.., i3, i4, i5] = n
end
# B => 2×3×4×5×6 Array{Int64,5}:
# [:, :, 1, 1, 1] =
#  1  1  1
#  1  1  1
#
# [:, :, 2, 1, 1] =
#  2  2  2
#  2  2  2
#
#  :
#
# [:, :, 4, 5, 6] =
#  120  120  120
#  120  120  120

@test B[1, 1, ..] == B[1, 1, :, :, :] == reshape(1:120, 4, 5, 6)
@test B[1, 1, .., 1] == B[1, 1, :, :, 1] == reshape(1:20, 4, 5)

C = Array{Int}(2, 3, 4, 5, 6)

n = 0
for i3=1:4, i2=1:3, i1=1:2
    n += 1
    C[i1, i2, i3, ..] = n
end
# C => 2×3×4×5×6 Array{Int64,5}:
# [:, :, 1, 1, 1] =
#  1  3  5
#  2  4  6
#
# [:, :, 2, 1, 1] =
#  7   9  11
#  8  10  12
#
#  :
#
# [:, :, 4, 5, 6] =
#  19  21  23
#  20  22  24

@test C[.., 1, 1] == C[:, :, :, 1, 1] == reshape(1:24, 2, 3, 4)
@test C[1, .., 1, 1] == C[1, :, :, 1, 1] == reshape(1:2:24, 3, 4)

D = ones(Int, 1, 2, 3, 4)
D[1, .., 2] = 2
@test D == [i1 == 1 && i4 == 2 ? 2 : 1 for i1=1:1, i2=1:2, i3=1:3, i4=1:4]


text:
module Utils

import ChainRulesTestUtils

check_rrule(args...) = ChainRulesTestUtils.test_rrule(args...; check_inferred = false)

end  # module

ext: jl


text:
abstract type Point end

struct CartesianPoint{T} <: Point
	x::T
	y::T
	z::T
end

struct CylindricalPoint{T} <: Point
	z::T
	r::T
	θ::T
end

"""
	cartesian2cylindrical(x, y, z)
Transform a point or vector from cartesian (x, y, z)  to cylindrical (z, r, θ) coordinates,
assuming the z-axis is the axis of the cylinder
"""
function cartesian2cylindrical(x, y, z)
	r = √(x^2 + y^2)
	θ = atan(y, x)
	return (z, r, θ)
end

"""
	cylindrical2cartesian(z, r, θ)
Transform a point or vector (z, r, θ) from cylindrical  to cartesian (x, y, z) coordinates,
assuming the z-axis is the axis of the cylinder
"""
function cylindrical2cartesian(z, r, θ)
	x = r * cos(θ)
	y = r * sin(θ)
	return (x, y, z)
end

function cartesian2cylindrical(cart::CartesianPoint)
	z, r, θ = cartesian2cyclindrical(cart.x, cart.y, cart.z)
	return CylindricalPoint(z, r, θ)
end

function cylindrical2cartesian(cyl::CylindricalPoint)
	x, y, z = cylindrical2cartesian(cyl.z, cyl.r, cyl.θ)
	return CartesianPoint(x, y, z)
end


text:
using Documenter, SQLite

makedocs(;
    modules=[SQLite],
    format=Documenter.HTML(),
    pages=[
        "Home" => "index.md",
    ],
    repo="https://github.com/JuliaDatabases/SQLite.jl/blob/{commit}{path}#L{line}",
    sitename="SQLite.jl",
    authors="Jacob Quinn",
    assets=String[],
)

deploydocs(;
    repo="github.com/JuliaDatabases/SQLite.jl",
)


text:
using ModelingToolkit
using Test

@parameters t
@variables a b(t) c d e(t)

b = ParentScope(b)
c = ParentScope(ParentScope(c))
d = GlobalScope(d)

# ensure it works on Term too
LocalScope(e.val)
ParentScope(e.val)
GlobalScope(e.val)
@test ModelingToolkit.getname(ModelingToolkit.namespace_expr(ModelingToolkit.namespace_expr(b, :foo, t), :bar, t)) == :bar₊b

renamed(nss, sym) = ModelingToolkit.getname(foldr(ModelingToolkit.renamespace, nss, init=sym))

@test renamed([:foo :bar :baz], a) == :foo₊bar₊baz₊a
@test renamed([:foo :bar :baz], b) == :foo₊bar₊b
@test renamed([:foo :bar :baz], c) == :foo₊c
@test renamed([:foo :bar :baz], d) == :d

eqs = [
    0 ~ a
    0 ~ b
    0 ~ c
    0 ~ d
]
@named sub4 = NonlinearSystem(eqs, [a, b, c, d], [])
@named sub3 = NonlinearSystem(eqs, [a, b, c, d], [])
@named sub2 = NonlinearSystem([], [], [], systems=[sub3, sub4])
@named sub1 = NonlinearSystem([], [], [], systems=[sub2])
@named sys = NonlinearSystem([], [], [], systems=[sub1])

names = ModelingToolkit.getname.(states(sys))
@test :d in names
@test :sub1₊c in names
@test :sub1₊sub2₊b in names
@test :sub1₊sub2₊sub3₊a in names
@test :sub1₊sub2₊sub4₊a in names


text:
module TestIntSets

include("../src/IntSets.jl")

using Test
using Random

@testset "IntSet" begin
    function test_state(s::IntSet)
        n = limit(s)
        cs = collect(s)
        @test allunique(cs)
        @test length(cs) == length(s)
        @test in.(1:n,Ref(cs)) == in.(1:n,Ref(s))
    end

    @testset "IntSet()" begin
        @testset for n = 1:5
            s = IntSet(n)
            test_state(s)
            @test length(s) == 0
        end
    end

    @testset "push!" begin
        @testset for n = 1:5
            @testset for seed = 1:10
                Random.seed!(seed)
                vs = rand(1:n,10)
                s = IntSet(n)
                for k = 1:length(vs)
                    push!(s,vs[k])
                    test_state(s)
                    @test issetequal(s,vs[1:k])
                end
            end
        end

        @testset "inbounds" begin
            s = IntSet(3); @test_throws Exception push!(s,4)
        end
    end

    @testset "union!" begin
        @testset for n = 1:5
            @testset for seed = 1:10
                Random.seed!(seed)
                vs = rand(1:n,10)
                p = min.(10,cumsum([1;rand(0:3,5)]))
                s = IntSet(n)
                for k = 1:length(p)-1
                    union!(s,vs[p[k]:p[k+1]-1])
                    test_state(s)
                    @test issetequal(s,vs[1:p[k+1]-1])
                end
            end
        end

        @testset "inbounds" begin
            s = IntSet(3); @test_throws Exception union!(s,[4])
        end
    end

    @testset "empty!" begin
        s = IntSet(1)
        empty!(s)
        test_state(s)
        @test length(s) == 0
        push!(s,1)
        empty!(s)
        test_state(s)
        @test length(s) == 0
    end

    @testset "sort!" begin
        @testset for n = 1:5
            @testset for seed = 1:10
                Random.seed!(42)
                vs = rand(1:n,rand(1:n))
                s = IntSet(n)
                union!(s,vs)
                sort!(s)
                test_state(s)
                @test collect(s) == unique!(sort!(vs))
            end
        end
    end

    @testset "IntSet(0)" begin
        s = IntSet(0)
        test_state(s)
        empty!(s)
        test_state(s)
    end
end

end # module

max_stars_repo_name: ettersi/SparseFactorizations

max_issues_repo_name: ettersi/SparseFactorizations

max_forks_repo_name: ettersi/SparseFactorizations


text:
function to_json(io::IO, x, indent; kw...)
    d = to_dict(x; kw...)
    JSON.print(io, d, indent)
end

function to_json(io::IO, x; kw...)
    d = to_dict(x; kw...)
    JSON.print(io, d)
end

function to_json(filename::String, x, xs...; kw...)
    d = to_dict(x; kw...)
    open(filename, "w+") do io
        JSON.print(io, d, xs...)
    end
end

function to_json(x, xs...; kw...)
    d = to_dict(x; kw...)
    JSON.json(d, xs...)
end

function from_json(::Type{T}, filename::String; kw...) where T
    is_option(T) || error("not an option type")
    d = JSON.parsefile(filename)
    d["#filename#"] = filename
    return from_dict(T, d; kw...)
end

function from_json(::Type{T}, io::IO; kw...) where T
    is_option(T) || error("not an option type")
    d = JSON.parse(io)
    return from_dict(T, d; kw...)
end


text:
export add_scalar_inverse

function add_scalar_inverse(mgr::Ptr{Manager}, f::Ptr{Node}, epsilon::Ptr{Node})
    result = Cudd_addScalarInverse(mgr, f, epsilon)
    if result == C_NULL
        throw(OutOfMemoryError())
    end
    return result
end


text:
using Documenter, Compose

makedocs(
    modules = [Compose],
    clean = true,
    format = :html,
    sitename = "Compose.jl",
    pages = Any[
        "Home" => "index.md",
        "Tutorial" => "tutorial.md",
        "Gallery" => Any[
            "Forms" => "gallery/forms.md",
            "Properties"=> "gallery/properties.md",
            "Transformations"=> "gallery/transforms.md",
            ],
        "Library" => "library.md"
    ]
)

deploydocs(
    repo   = "github.com/GiovineItalia/Compose.jl.git",
    target = "build"
)


text:
@testset "Clustering" begin
    g10 = complete_graph(10)
    @testset "$g" for g in testgraphs(g10)
        @test @inferred(local_clustering_coefficient(g, 1)) == 1.0
        @test @inferred(local_clustering_coefficient(g)) == ones(10)
        @test @inferred(global_clustering_coefficient(g)) == 1.0
        @test @inferred(local_clustering(g)) == (fill(36, 10), fill(36, 10))
        @test @inferred(triangles(g)) == fill(36, 10)
        @test @inferred(triangles(g, 1)) == 36
    end
    # 1265 / 1266
    g = complete_graph(3)
    add_edge!(g, 2, 2)
    @test @inferred(triangles(g)) == fill(1, 3)
end


text:
using PyCall
#pygui(:qt5) # good, default
# pygui(:wx) # crashes
# pygui(:gtk3)
using Random
import PyPlot as plt
#const plt = PyPlot

# https://github.com/JuliaPy/PyPlot.jl
function learn_basic_usage()
    # use x = linspace(0,2*pi,1000) in Julia 0.6
    x = range(0; stop=2*pi, length=1000)
    y = sin.(3 * x + 4 * cos.(2 * x))
    plt.plot(x, y, color="red", linewidth=2.0, linestyle="--")
    plt.title("A sinusoidally modulated sinusoid")
end

# https://matplotlib.org/stable/tutorials/introductory/pyplot.html
function learn_intro_to_pyplot_1()
    plt.clf() # clear figure, cla(), close()
    # x data are [0, 1, 2, 3]
    plt.plot([1, 2, 3, 4])
    plt.ylabel("Some numbers")
    plt.show()

    # https://stackoverflow.com/questions/6916978/how-do-i-tell-matplotlib-to-create-a-second-new-plot-then-later-plot-on-the-o
end
function learn_intro_to_pyplot_2()
    plt.clf() # clear figure, cla(), close()
    plt.plot([1, 2, 3, 4], [1, 4, 9, 16]) # "b-"
    plt.show()
end
function learn_intro_to_pyplot_3()
    plt.clf() # clear figure, cla(), close()
    plt.plot([1, 2, 3, 4], [1, 4, 9, 16], "ro")
    plt.axis([0, 6, 0, 20])
    plt.show()
end

function learn_intro_to_pyplot_4()
    plt.clf() # clear figure, cla(), close()
    t = range(0, step=0.2, stop=5)
    @show t
    plt.plot(
        t, t, "r--",
        t, t.^2, "bs",
        t, t.^3, "g^"
    )
    plt.show()
end

function learn_intro_to_pyplot_5()
    plt.clf() # clear figure, cla(), close()
    data = Dict(
        "a" => range(0,length=50),
        "c" => rand(0:50, 50),
        "d" => randn(50),
    )
    data["b"] = data["a"] + 10 * randn(50)
    data["d"] = abs.(data["d"]) .* 100

    plt.scatter("a", "b", c="c", s="d", data=data)
    plt.xlabel("entry a")
    plt.ylabel("entry b")
    plt.show()
end

#learn_basic_usage()
#learn_intro_to_pyplot_1()
#learn_intro_to_pyplot_2()
#learn_intro_to_pyplot_3()
#learn_intro_to_pyplot_4()
learn_intro_to_pyplot_5()

nothing


text:
@testset "Testing ecdf.jl" begin
    # set up

    obs = rand(40)
    e = ECDF(obs)

    # 1.1 is larger than all obs, so ecdf should be 1
    @test e(1.1) ≈ 1.0

    # -1.0 is small than all obs, so ecdf should be 0
    @test e(-1.0) ≈ 0.0

    # evaluate at more than more than point
    @test e([1.1, -1.0]) ≈ [1.0, 0.0]

    # larger values should have larger values on ecdf
    let x = rand()
        F_1 = e(x)
        F_2 = e(x*1.1)
        @test F_1 <= F_2
    end

end  # testset


text:
struct utility_function{T} end

function utility_function{T}(n::Integer) where T
    u=zeros(T,n)
    @. u=max(0,log(n/2+1)-log(1:n))
    su=sum(u)
    @. u=u./su .- 1/n
    u
end

function randchisq(rn::AbstractRNG,::Type{T},ν::Integer) where T
    ν < 0 && throw(ArgumentError("ν (DOF) must be atleast 0."))
    s=zero(T)
    for i in 1:ν
        s+=abs2(randn(rn,T))
    end
    s
end

function randchisq(::Type{T},ν::Integer) where T
    randchisq(Random.default_rng(),T,ν)
end

function geo_mean(x::AbstractVector{T}) where T
    gm=one(T)
    ds=0
    for e in x
        e<=0 && continue
        ds+=1
        gm*=e
    end
    ds==0 && return zero(T)
    gm^(1/ds)
end

Base.@kwdef mutable struct Termination{T}
    atol::T=T(1e-8)
    iterations::Int=1e4
end

function termination_criteria(C::Termination,atol,iterations)
    atol <= C.atol && return true
    iterations >= C.iterations && return true
    return false
end


text:
module GraphAnalysis

# Deklaracia dodatkovych modulov
using Graphs
using DataStructures
using Distributions
using GraphAnalysis

export

    # Centrality
    centrality_closeness,
    centrality_degree,
    centrality_betweenness,
    centrality_eccentricity,
    centrality_eccentricity_list_comprehension,
    centrality_eigenvector,
    centrality_radiality,
    centrality_radiality_list_comprehension,
    centrality_load,

    # Nacitanie, ulozenie grafu
    save_graph, load_graph,

    # Rozklad grafu na k_jadra
    coreness,
    k_core,
    k_shell,
    k_crust,
    k_corona,

    # Doplnkove funkcie
    contains_parallel_edges,
    contains_selfloops,
    degree_histogram,
    graph_radius,
    graph_diameter,
    get_vertex,
    vertex_eccentricity,
    average_shortest_distance,
    get_subgraph

# Zdrojove subory pre dodatkove funkcie pre centrality
include("assemble_basic.jl")
include("assemble_endpoints.jl")
include("assemble_shortest_paths.jl")
include("rescale_graph.jl")
include("node_loadness.jl")

# Zdrojove subory pre analyzu centralit
include("centrality_closeness.jl")
include("centrality_degree.jl")
include("centrality_betweenness.jl")
include("centrality_eccentricity.jl")
include("centrality_eccentricity_list_comprehension.jl")
include("centrality_eigenvector.jl")
include("centrality_radiality.jl")
include("centrality_radiality_list_comprehension.jl")
include("centrality_radiality_list_comprehension.jl")
include("centrality_load.jl")

# Zdrojove subory pre nacitanie a ulozenie grafu
include("save_graph.jl")
include("load_graph.jl")

# Zdrojove subory pre rozklad grafu na rozne k topologie
include("coreness.jl")
include("k_core.jl")
include("k_shell.jl")
include("k_crust.jl")
include("k_corona.jl")

# Zdrojove subory pre doplnkovo implementovane funkcie
include("contains_parallel_edges.jl")
include("contains_selfloops.jl")
include("degree_histogram.jl")
include("graph_radius.jl")
include("graph_diameter.jl")
include("get_vertex.jl")
include("vertex_eccentricity.jl")
include("average_shortest_distance.jl")
include("get_subgraph.jl")

end

max_stars_repo_name: mpuk/GraphAnalysis

max_issues_repo_name: mpuk/GraphAnalysis

max_forks_repo_name: mpuk/GraphAnalysis


text:
function jump_sensorloc(solver, seed, n; verbose = false, test = false)

    m, x_true, a, d, d_bar = sensorloc_data(seed, n)

    model = Model(with_optimizer(solver))

    # Build SDP problem
    @variable(model, X[1:n+2, 1:n+2], PSD)

    # Constraint with distances from anchors to sensors
    for j in 1:n
        for k in 1:m
            # e = zeros(n, 1)
            # e[j] = -1.0
            # v = vcat(a[k], e)
            # V = v * v'
            # @constraint(model, sum(V .* X) == d_bar[k, j]^2)
            @constraint(model, X[1,1]*a[k][1]*a[k][1] + X[2,2]*a[k][2]*a[k][2]
                                 - 2 * X[1, j+2] * a[k][1]
                                 - 2 * X[2, j+2] * a[k][2]
                                 + X[j+2, j+2]
                                == d_bar[k, j]^2)
        end
    end

    # Constraint with distances from sensors to sensors
    count, count_all = 0, 0
    for i in 1:n
        for j in 1:i - 1
            count_all += 1
            if rand() > 0.9
                count += 1
                # e = zeros(n, 1)
                # e[i] = 1.0
                # e[j] = -1.0
                # v = vcat(zeros(2, 1), e)
                # V = v * v'
                # @constraint(model, sum(V .* X) == d[i, j]^2)
                @constraint(model, X[i+2,i+2] + X[j+2,j+2] - 2*X[i+2,j+2] == d[i, j]^2)
            end
        end
    end
    if verbose
        @show count_all, count
    end

    @constraint(model, X[1, 1] == 1.0)
    @constraint(model, X[1, 2] == 0.0)
    @constraint(model, X[2, 1] == 0.0)
    @constraint(model, X[2, 2] == 1.0)

    # Feasibility objective function
    # L = eye(n+1)
    # @objective(model, Min, sum(L[i, j] * X[i, j] for i in 1:n+1, j in 1:n+1))
    @objective(model, Min, 0.0 * X[1, 1] + 0.0 * X[2, 2])

    teste = @time optimize!(model)

    XX = value.(X)

    verbose && sensorloc_eval(n, m, x_true, XX)

    objval = objective_value(model)
    stime = MOI.get(model, MOI.SolveTime())

    # @show tp = typeof(model.moi_backend.optimizer.model.optimizer)
    # @show fieldnames(tp)
    rank = -1
    try
        @show rank = model.moi_backend.optimizer.model.optimizer.sol.final_rank
    catch
    end
    status = 0
    if JuMP.termination_status(model) == MOI.OPTIMAL
        status = 1
    end
    return (objval, stime, rank, status)
    # return (objval, stime)
end


text:
using EffectiveWaves
using LinearAlgebra
using Plots
pyplot()

medium = Medium(ρ=1.0, c=1.0)
species = [Specie(ρ=0.1,r=0.4, c=0.2, volfrac=0.3)]

ωs = [1.0]
ω = ωs[1]
k = ω/medium.c
hankel_order = ho = 2

kps = wavenumbers(ω, medium, species; symmetry = :plane, dim = 3,
    hankel_order = hankel_order, num_wavenumbers=17,
    tol = 1e-8,
    mesh_points = 14, mesh_size = 2.0)

# Doesnt really work
# R_kps = wavenumbers(ω, medium, species; dim = 3, hankel_order = hankel_order,
#     num_wavenumbers=27, tol = 1e-8, mesh_points = 10, mesh_size = 2.0)
R_kps = Complex{Float64}[2.30521+1.85168im, -1.46227+2.03392im, -1.45281+2.03493im, 10.9431+5.60625im, -10.0589+5.61005im, -10.0562+5.61218im, 19.1007+6.88548im, -18.2139+6.88838im, 27.0945+7.7147im, 35.0209+8.32989im, 35.0222+8.33306im, 42.9157+8.82717im, 50.7889+9.23896im, 58.6476+9.58905im, 58.649+9.59209im, 66.5001+9.90123im, 74.3447+10.1762im, 82.1845+10.4237im, 90.0205+10.6489im]

wavesystem2D = wavematrix2D(ωs[1], medium, species; hankel_order=hankel_order);
det2D(kp) = det(wavesystem2D(kp))
kps2 = wavenumbers(ω, medium, species; dim = 2, hankel_order = hankel_order,
    num_wavenumbers=27, tol = 1e-8, mesh_points = 10, mesh_size = 2.0);

wavesystemPlane = wavematrix3DPlane(ωs[1], medium, species; hankel_order=hankel_order)
detP(kp) = det(wavesystemPlane(kp))
detP.(kps)

inds = findall( abs.(detP.(kps)) .< 1e-5);
kps = kps[inds]

wavesystem3D = wavematrix3D(ωs[1], medium, species; hankel_order=hankel_order);
detR(kp) = (det(wavesystem3D(kp)))^(1/2)
detR.(kps)

MRsvd = svd(wavesystem3D(kps[2]))
MRsvd = svd(wavesystem3D(kps[1]))
MRsvd.S
wave_vec =  MRsvd.V[:,end]
wave_mat = reshape(wave_vec,((ho+1)^2,(ho+1)^2))


text:
# This file is a part of Julia. License is MIT: https://julialang.org/license

using Random: randcycle

@testset "binomial" begin
    @test binomial(5,-1) == 0
    @test binomial(5,10) == 0
    @test binomial(5,3) == 10
    @test binomial(2,1) == 2
    @test binomial(1,2) == 0
    @test binomial(-2,1) == -2 # let's agree
    @test binomial(2,-1) == 0

    #Issue 6154
    @test binomial(Int32(34), Int32(15)) == binomial(BigInt(34), BigInt(15)) == 1855967520
    @test binomial(Int64(67), Int64(29)) == binomial(BigInt(67), BigInt(29)) == 7886597962249166160
    @test binomial(Int128(131), Int128(62)) == binomial(BigInt(131), BigInt(62)) == 157311720980559117816198361912717812000
    @test_throws OverflowError binomial(Int64(67), Int64(30))
end

@testset "permutations" begin
    p = shuffle([1:1000;])
    @test isperm(p)
    @test all(invperm(invperm(p)) .== p)
    @test isperm(()) == true
    @test isperm((1,)) == true
    @test isperm((2,)) == false
    @test isperm((1,2)) == true
    @test isperm((2,1)) == true
    @test isperm((2,2)) == false
    @test isperm((1,3)) == false
    @test invperm(()) == ()
    @test invperm((1,)) == (1,)
    @test invperm((1,2)) == (1,2)
    @test invperm((2,1)) == (2,1)
    @test_throws ArgumentError invperm((1,3))

    push!(p, 1)
    @test !isperm(p)

    a = randcycle(10)
    @test invpermute!(permute!([1:10;], a),a) == [1:10;]

    # PR 12785
    let ai = 2:-1:1
        @test invpermute!(permute!([1, 2], ai), ai) == [1, 2]
    end

    # PR 35234
    for N in 3:1:20
        A=randcycle(N)
        T=Tuple(A)
        K=Tuple(A.-1)
        @test A[collect(invperm(T))] == 1:N
        @test_throws ArgumentError invperm(K)
        @test isperm(T) == true
        @test isperm(K) == false
    end
end

@testset "factorial" begin
    @test factorial(7) == 5040
    @test factorial(Int8(7)) == 5040
    @test factorial(UInt8(7)) == 5040
    @test factorial(Int16(7)) == 5040
    @test factorial(UInt16(7)) == 5040
    @test factorial(Int32(7)) == 5040
    @test factorial(UInt32(7)) == 5040
    @test factorial(Int64(7)) == 5040
    @test factorial(UInt64(7)) == 5040
    @test factorial(Int128(7)) == 5040
    @test factorial(UInt128(7)) == 5040
    @test factorial(0) == 1
    @test_throws DomainError factorial(-1)
    @test factorial(Int64(20)) == 2432902008176640000
    # issue #6579
    @test_throws OverflowError factorial(Int64(21))
    @test typeof(factorial(Int8(2))) == typeof(factorial(Int8(1)))
    if Int === Int32
        @test factorial(Int32(12)) === Int32(479001600)
        @test_throws OverflowError factorial(Int32(13))
    end

    _fact_table64 =
        Int64[1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800,
              87178291200,1307674368000,20922789888000,355687428096000,6402373705728000,
              121645100408832000,2432902008176640000]

    _fact_table128 =
        UInt128[0x00000000000000000000000000000001, 0x00000000000000000000000000000002,
                0x00000000000000000000000000000006, 0x00000000000000000000000000000018,
                0x00000000000000000000000000000078, 0x000000000000000000000000000002d0,
                0x000000000000000000000000000013b0, 0x00000000000000000000000000009d80,
                0x00000000000000000000000000058980, 0x00000000000000000000000000375f00,
                0x00000000000000000000000002611500, 0x0000000000000000000000001c8cfc00,
                0x0000000000000000000000017328cc00, 0x0000000000000000000000144c3b2800,
                0x00000000000000000000013077775800, 0x00000000000000000000130777758000,
                0x00000000000000000001437eeecd8000, 0x00000000000000000016beecca730000,
                0x000000000000000001b02b9306890000, 0x000000000000000021c3677c82b40000,
                0x0000000000000002c5077d36b8c40000, 0x000000000000003ceea4c2b3e0d80000,
                0x000000000000057970cd7e2933680000, 0x00000000000083629343d3dcd1c00000,
                0x00000000000cd4a0619fb0907bc00000, 0x00000000014d9849ea37eeac91800000,
                0x00000000232f0fcbb3e62c3358800000, 0x00000003d925ba47ad2cd59dae000000,
                0x0000006f99461a1e9e1432dcb6000000, 0x00000d13f6370f96865df5dd54000000,
                0x0001956ad0aae33a4560c5cd2c000000, 0x0032ad5a155c6748ac18b9a580000000,
                0x0688589cc0e9505e2f2fee5580000000, 0xde1bc4d19efcac82445da75b00000000]

    for expected in Any[_fact_table64, _fact_table128]
        for (n, factn) in enumerate(expected)
            @test factorial(oftype(factn, n)) === factn
        end
    end
end

max_stars_repo_name: TimoLarson/julia

max_issues_repo_name: TimoLarson/julia

max_forks_repo_name: TimoLarson/julia


text:
function init_cache_evec(n, max_iters)
    return (
        p = zeros(max_iters),
        w = zeros(max_iters),
        V = zeros(n, max_iters+1),
        tmp1 = Vector{Float64}(undef, n),
        tmp2 = Vector{Float64}(undef, n)
    )
end

function approx_min_evec!(v::Vector{T}, M::AbstractMatrix; n::Int, q::Int, cache=nothing, tol=1e-12) where {T}
    max_iters = min(q, n-1)
    if isnothing(cache)
        cache = init_cache_evec(n, max_iters)
    end

    #initialize
    #QUESTION: Should this be warm started?
    @views randn!(cache.V[:,1])
    @views cache.V[:,1] .= cache.V[:,1] ./ norm(cache.V[:,1])

    i = 1
    while i <= max_iters
        vi = @view(cache.V[:,i])
        vi1 = @view(cache.V[:,i+1])

        # quad form
        mul!(vi1, M, vi)
        cache.w[i] = dot(vi, vi1)

        vi1 .-= cache.w[i] .* vi
        if i > 1
            @views vi1 .-= cache.p[i-1] .* cache.V[:,i-1]
        end

        cache.p[i] = norm(vi1)
        cache.p[i] < tol && break

        vi1 ./= cache.p[i]
        i += 1

    end
    i -= 1

    # LAPACK call for SymTridiagonal eigenvectors
    # https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/#LinearAlgebra.LAPACK.stegr!
    @views cache.tmp1[1:i] .= LAPACK.stegr!('V', 'I', cache.w[1:i], cache.p[1:i-1], 0.0, 0.0, 1, 1)[2][:,1]
    @views mul!(v, cache.V[:,1:i], cache.tmp1[1:i])
    mul!(cache.tmp1, M, v)
    ξ = dot(v, cache.tmp1)
    return ξ

end

# Directly uses two primatives
function approx_min_evec!(v, C_u!, Aadj_zu!, AX; n::Int, q::Int, cache=nothing, tol=1e-12)
    max_iters = min(q, n-1)
    if isnothing(cache)
        cache = init_cache_evec(n, max_iters)
    end

    #initialize
    @views randn!(cache.V[:,1])
    @views cache.V[:,1] .= cache.V[:,1] ./ norm(cache.V[:,1])

    i = 1
    while i <= max_iters
        vi = @view(cache.V[:,i])
        vi1 = @view(cache.V[:,i+1])

        C_u!(cache.tmp1, vi)
        Aadj_zu!(vi1, AX, vi)
        vi1 .+= cache.tmp1
        cache.w[i] = dot(vi, vi1)

        vi1 .-= cache.w[i] .* vi
        if i > 1
            @views vi1 .-= cache.p[i-1] .* cache.V[:,i-1]
        end

        cache.p[i] = norm(vi1)
        cache.p[i] < tol && break

        vi1 ./= cache.p[i]
        i += 1

    end
    i -= 1

    # LAPACK call for SymTridiagonal eigenvectors
    # https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/#LinearAlgebra.LAPACK.stegr!
    @views cache.tmp1[1:i] .= LAPACK.stegr!('V', 'I', cache.w[1:i], cache.p[1:i-1], 0.0, 0.0, 1, 1)[2][:,1]
    @views mul!(v, cache.V[:,1:i], cache.tmp1[1:i])

    C_u!(cache.tmp1, v)
    Aadj_zu!(cache.tmp2, AX, v)
    cache.tmp1 .+= cache.tmp2

    M!(cache.tmp1, v)
    ξ = dot(v, cache.tmp1)
    return ξ

end


text:
module MyPkg

using Dates

todayis() = dayname(now())

function build_time()
    open("deps/time.txt", "r") do file
        for ln in eachline(file)
            println("$(ln)")
        end
    end
end

end # module

max_stars_repo_name: glennmoy/MyPkg

max_issues_repo_name: glennmoy/MyPkg

max_forks_repo_name: glennmoy/MyPkg


text:
module DataTestTypes
    export Block

    struct Block
        a::Int64
        b::Int64
    end
end

max_stars_repo_name: pjuangph/JuliaLearning

max_issues_repo_name: pjuangph/JuliaLearning

max_forks_repo_name: pjuangph/JuliaLearning


text:
using Weave, Test, YAML

header = YAML.load("""
---
options:
    out_path: reports
    md2html:
        out_path : html/
    md2pdf:
        out_path : pdf/
    github:
        out_path : md/
    fig_ext : .png
---
""")

args = header["options"]
@test Weave.combine_args(args, "md2html") == Dict("fig_ext" => ".png",
                                            "out_path" => "html/")
@test Weave.combine_args(args, "github") == Dict("fig_ext" => ".png",
                                            "out_path" => "md/")
@test Weave.combine_args(args, "pandoc") == Dict("fig_ext" => ".png",
                                                "out_path" => "reports")
doc = Weave.read_doc(joinpath(@__DIR__, "documents", "header_test.jmd"))
@test doc.chunk_defaults[:echo] == false
@test doc.chunk_defaults[:out_width] == "30%"


text:
"""
A special package that manages opencv binary depedencies

```julia
Pkg.build("LibOpenCV")
```

try to search your system opencv libraries and its dependencies, and throws errors
if any issues. If opencv librarires are not found, it will install fresh opencv
libraries into `deps` directrory, but not recommended unless if you have perfect
requiremsnts to build opencv.
"""
module LibOpenCV

# Load dependency
deps = joinpath(Pkg.dir("LibOpenCV"), "deps", "deps.jl")
if isfile(deps)
    include(deps)
else
    error("LibOpenCV not properly installed. Please run Pkg.build(\"LibOpenCV\")")
end

import Base.Filesystem
using DocStringExtensions
using Cxx

Libdl.dlopen(libopencv_core, Libdl.RTLD_GLOBAL)

const libdir = dirname(libopencv_core)
const libext = splitext(libopencv_core)[2]

"""
$(SIGNATURES)

It tries to search the specified library by name. Not exported, but meant to be
used by other opencv packages.

**Parameters**

- `mod` : Module name
- `libdirs` : library seach directries (default is dir of `libopencv_highgui`)
- `ext` : library extention name (e.g. `.so`)

**Retures**

- `libpath` : library path if found, othrewise return `C_NULL`

**Examples**

From the [CVHighGUI.jl](@ref) package,

```julia
libopencv_highgui = LibOpenCV.find_library_e("libopencv_highgui")
try
    Libdl.dlopen(libopencv_highgui, Libdl.RTLD_GLOBAL)
catch e
    warn("You might need to set DYLD_LIBRARY_PATH to load dependencies proeprty.")
    rethrow(e)
end
```
"""
function find_library_e(mod, libdirs=[libdir], ext=libext)
    for libdir in libdirs
        libpath = joinpath(libdir, string(mod, ext))
        if isfile(libpath)
            return libpath
        end
    end
    C_NULL
end

# Split the library directory in folders.
folder_path = split(libdir, Base.Filesystem.path_separator);
# Change the last "lib" part to "include". This is a wild guess, but quite
# robust.
lib_ids = find(folder_path .== "lib")
@assert (size(lib_ids, 1) > 0) "Include path could not be guessed!"
folder_path[lib_ids[end]] = "include";
const incdir = join(folder_path, Base.Filesystem.path_separator);
@assert isdir(incdir) "Include path could not be guessed: $(incdir)!"

opencvhpp = joinpath(incdir, "opencv2", "opencv.hpp")
if !isfile(opencvhpp)
    error("Cannot find $(opencvhpp)")
end

# Add libraries first as user include (-I), then as well as system includes.
# The former is necessary to get preference over the system installed OpenCV if
# necessary, the latter is necessary to have the internal OpenCV include with
# quotes (<>) work.
addHeaderDir(incdir, kind=C_User)
addHeaderDir(joinpath(incdir, "opencv2"), kind=C_User)
addHeaderDir(incdir, kind=C_System)
addHeaderDir(joinpath(incdir, "opencv2"), kind=C_System)

cxxinclude(opencvhpp)

end # module


text:
import Base

# """
# A power measure is a product of a measure with itself. The number of elements in
# the product determines the dimensionality of the resulting support.

# Note that power measures are only well-defined for integer powers.

# The nth power of a measure μ can be written μ^x.
# """
# PowerMeasure{M,N,D} = ProductMeasure{Fill{M,N,D}}

# function Base.show(io::IO, μ::PowerMeasure)
#     io = IOContext(io, :compact => true)
#     print(io, μ.data.value, " ^ ", size(μ.data))
# end

# function Base.show_unquoted(io::IO, μ::PowerMeasure{M,N,D}, indent::Int, prec::Int) where {M,N,D}
#     io = IOContext(io, :compact => true)
#     if Base.operator_precedence(:^) ≤ prec
#         print(io, "(")
#         show(io, μ.data.value)
#         print(io, ")")
#     else
#         show(io, size(μ.data))
#     end
#     return nothing
# end

Base.:^(μ::AbstractMeasure, n::Integer) = For(_ -> μ, 1:n)

Base.:^(μ::AbstractMeasure, size::NTuple{N,I}) where {N, I <: Integer} = For(_ -> μ, CartesianIndices(size))

# sampletype(d::PowerMeasure{M,N}) where {M,N} = @inbounds Array{sampletype(first(d.data)), N}

function Base.:^(μ::WeightedMeasure, n::NTuple{N,Int}) where {N}
    k = prod(n) * μ.logweight
    return WeightedMeasure(k, μ.base^n)
end

# basemeasure(μ::PowerMeasure) = @inbounds basemeasure(first(μ.data))^size(μ.data)


text:
## DTU42380a2: Supply Networks and Inventory
## Edward J. Xu
## April 10, 2020
## Data and Functions

function get_data()
  demands = [
    640000.00	400000.00	320000.00	440000.00	700000.00	350000.00;
    1152000.00	720000.00	576000.00	792000.00	1260000.00	630000.00;
    2073600.00	1296000.00	1036800.00	1425600.00	2268000.00	1134000.00
    ]  # demands[s, v]

  # demands = [
  #   640000.00	400000.00	320000.00	440000.00	700000.00	350000.00;
  #   1216000.00	760000.00	608000.00	836000.00	1330000.00	665000.00;
  #   2310400.00	1444000.00	1155200.00	1588400.00	2527000.00	1263500.00
  #   ]  # demands[s, v]

  costs_ship = [
    0.500	0.625	0.875	1.000	1.250	1.375
    0.625	0.625	0.625	0.750	1.000	1.125
    0.875	0.875	0.625	0.625	0.750	0.875
    1.000	1.000	0.750	0.625	0.750	0.625
    1.125	1.250	0.750	0.875	0.625	1.000
    ]  # costs_fix[l, v]

  costs_fix = [
    300000.00 500000.00
    250000.00 420000.00
    220000.00 375000.00
    220000.00 375000.00
    240000.00 400000.00
    ]  # costs_fix[l, w]

  cost_var = 0.2

  q = [2 4] * 1000000  # q[w]

  e = [
    1 1 0;
    0 1 1;
    1 1 1;
    0 0 1;
    0 0 0
    ]  # e[p, s]

  return demands, costs_ship, costs_fix, cost_var, q, e
end

"Get the optimized value of decision vector."
function value_vec(vec_x::Union{Array{VariableRef,1}, VariableRef})
    if isa(vec_x, VariableRef)
        vec_value = value(vec_x)
    else
        vec_value = [value(vec_x[i]) for i = 1:length(vec_x)]
    end

    return vec_value
end

"Get the optimized value of decision matrix."
function value_mat(mat_x::Array{VariableRef,2})
  m, n = size(mat_x)
  mat_value = [value(mat_x[i, j]) for i=1:m, j=1:n]

  return mat_value
end

"Get the optimized value of a 3-D decision matrix."
function value_mat3(mat3_x::Array{VariableRef,3})
  m, n, o = size(mat3_x)
  mat3_value =
  mat3_value = [value(mat3_x[i, j, k]) for i=1:m, j=1:n, k=1:o]

  return mat3_value
end


text:
# 64-bit, little endian
# significantly faster routines, but uses pointer tricks to bypass julia's memory safety mechanisms
@inline function load32u(a::Vector{UInt8}, i::Integer)
    return unsafe_load(reinterpret(Ptr{UInt32}, pointer(a,i)))
end
@inline function load64u(a::Vector{UInt8}, i::Integer)
    return unsafe_load(reinterpret(Ptr{UInt64}, pointer(a,i)))
end
@inline function load128u(a::Vector{UInt8}, i::Integer)
    return unsafe_load(reinterpret(Ptr{UInt128}, pointer(a, i)))
end
@inline function store32u!(a::Vector{UInt8}, i::Integer, u::UInt32)
    unsafe_store!(reinterpret(Ptr{UInt32}, pointer(a, i)), u)
end
@inline function unaligned_copy_64u!(dst::Vector{UInt8}, di::Integer, src::Vector{UInt8}, si::Integer)
    unsafe_store!(reinterpret(Ptr{UInt64}, pointer(dst, di)), load64u(src, si))
end
@inline function unaligned_copy_128u!(dst::Vector{UInt8}, di::Integer, src::Vector{UInt8}, si::Integer)
    unsafe_store!(reinterpret(Ptr{UInt128}, pointer(dst, di)), load128u(src, si))
end


text:
using Base.Test, JuMP, Gurobi

include("../MIPTests.jl/miptests.jl")
include("../src/branch_and_bound.jl")

solver = GurobiSolver(OutputFlag=0)

test1(solveMIP, solver) # 2/2
test2(solveMIP, solver) # 2/2
test3(solveMIP, solver) # 3/3
test3_2(solveMIP, solver) # 1/1
test3_3(solveMIP, solver) # 1/1
testCaminho(solveMIP, solver) # 1/1
testInfeasibleKnapsack(solveMIP, solver) # 1/1
testInfeasibleUC(solveMIP, solver) # 1/1
testSudoku(solveMIP, solver) # 8/8
testSudoku4x4(solveMIP, solver) # 1/1
testUnboundedKnapsack(solveMIP, solver) # 1/1
test_MIP_Minimal_Brito(solveMIP, solver) # 3/3
test_MIP_Pequeno_Brito(solveMIP, solver) # 3/3
test_Minimal_UC(solveMIP, solver) # 3/3
test_P1_Brito(solveMIP, solver) # 3/3
test_PL_Infeasible_Brito(solveMIP, solver) # 1/1
test_PL_Infeasible_Raphael(solveMIP, solver) # 1/1
test_PL_Simples_Brito(solveMIP, solver) # 2/2
test_PL_Simples_Raphael(solveMIP, solver) # 2/2
test_PL_Unbounded_Brito(solveMIP, solver) # 1/1
test_feature_selection_medio(solveMIP, solver) # 2/2
test_feature_selection_pequeno_inviavel(solveMIP, solver) # 1/1
test_feature_selection_pequeno_viavel(solveMIP, solver) # 2/2
teste_PL_andrew_inviavel(solveMIP, solver) # 1/1
teste_PL_andrew_unbounded(solveMIP, solver) # 1/1
teste_PL_andrew_viavel(solveMIP, solver) # 3/3

# Hard tests
test_feature_selection_grande(solveMIP, solver) # 2/2
testRobustCCUC(solveMIP, solver)


text:
SIRD = LabelledReactionNet{Float64, Float64}([:S=>0.0, :I=>0.0, :R=>0.0, :D=>0.0],
                                             (:inf=>0.0)=>((:S,:I)=>(:I,:I)),
                                             (:rec=>0.0)=>(:I=>:R),
                                             (:death=>0.0)=>(:I=>:D))

SIR  = LabelledReactionNet{Float64, Float64}([:S=>1.0, :I=>0.0, :R=>0.0],
                                             (:inf=>0.5)=>((:S,:I)=>(:I,:I)),
                                             (:rec=>0.1)=>(:I=>:R))
models = [SIR, SIRD]

AlgebraicPetri.ModelComparison.compare(A::Subobject, B::Subobject) = compare(dom(hom(A)), dom(hom(B)))
@testset "Subobjects" begin
for pn in [models,
           ReactionNet{Float64, Float64}.([SIR, SIRD]),
           LabelledPetriNet.(models),
           PetriNet.(models)]

  c_res = compare(pn[1], pn[2])
  @test apex(c_res) == pn[1]
  @test length(legs(c_res)) == 2

  @test Graph(legs(c_res)[1]) isa Graph
  @test Graph(c_res) isa Graph

  so = Subobject.(legs(c_res))
  for s in so
    @test Graph(s) isa Graph
    @test codom(hom(s)) == pn[2]
  end

  @test dom(hom(~foldl(∨, so) ∨ foldl(∨, so))) == pn[2]
  A,B = so
  @test implies(A, B) == ¬(A) ∨ B
  @test ¬(A ∧ B) == ¬(A) ∨ ¬(B)
  @test ¬(A ∧ B) != ¬(A) ∨ B
  # modus ponens holds only up to inclusion, not equality.
  @test length(compare(A ∧ implies(A,B), B)) > 0
  # this is an equivalent check because X ∧ B == X iff X ↪ B
  @test (A ∧ implies(A,B)) == B ∧ (A ∧ implies(A,B))

  @test length(compare(B ∧ implies(B,A), A)) > 0
  @test (B ∧ implies(B,A)) == A ∧ (B ∧ implies(B,A))

  @test ¬(A ∨ (¬B)) == ¬(A) ∧ ¬(¬(B))
  @test ¬(A ∨ (¬B)) == ¬(A) ∧ B
  @test A ∧ ¬(¬(A)) == ¬(¬(A))
  @test implies((A∧B), A) == A∨B
end
end

max_stars_repo_name: AlgebraicJulia/AlgebraicPetri

max_issues_repo_name: AlgebraicJulia/AlgebraicPetri

max_forks_repo_name: AlgebraicJulia/AlgebraicPetri


text:
function sim_components(model)
    return LRMoE.sim_expert.(model)
end

function sim_logit_gating(α, X)
    X = Array(X)
    probs = exp.(LogitGating(α, X))
    return hcat([rand(Distributions.Multinomial(1, probs[i,:])) for i in 1:size(X)[1]]...)'
end

function sim_dataset(α, X, model; exposure = nothing)
    X = Array(X)
    if isnothing(exposure)
        exposure = fill(1.0, size(X)[1])
    end
    model_expo = exposurize_model(model, exposure = exposure)
    gating_sim = sim_logit_gating(α, X)
    return vcat([sim_components(model_expo[:,:,i]) * gating_sim[i,:] for i in 1:size(X)[1]]'...)
end

max_stars_repo_name: sparktseung/JuliaLRMoE

max_issues_repo_name: sparktseung/JuliaLRMoE

max_forks_repo_name: sparktseung/JuliaLRMoE


text:
using Distributed, ClusterManagers, DistributedData

# read the number of available workers from  environment and start the worker processes
n_workers = parse(Int, ENV["SLURM_NTASKS"])
addprocs_slurm(n_workers, topology = :master_worker)

# load the required packages on all workers
@everywhere using DistributedData

# generate a random dataset on all workers
dataset = dtransform((), _ -> randn(10000, 10000), workers(), :myData)

# for demonstration, sum the whole dataset
totalResult = dmapreduce(dataset, sum, +)

# do not forget to save the results!
f = open("result.txt", "w")
println(f, totalResult)
close(f)


text:
module Stress_Test

using Intan,SpikeSorting,Gtk.ShortNames, Cairo

function stress_init(amps)
    d=Debug(string(dirname(Base.source_path()),"/data/qq.mat"),"qq")
    myt=Task_NoTask()
    rhd=makeRHD(amps,myt,debug=d)
    handles = makegui(rhd)
    (rhd,handles)
end

function stress_test(myrhd,handles)

    Intan.init_cb(handles.init.handle,(handles,myrhd));

    myctx=getgc(handles.c)
    myctx2=getgc(handles.c2)

    #calibrate
    for i=1:1000
        Intan.main_loop(myrhd,handles,myctx,myctx2)
    end

    setproperty!(handles.cal,:active,false)
    Intan.cal_cb(handles.cal.handle,(handles,myrhd))
    mytimes=zeros(Float64,1000)

    for i=1:1000
        mytimes[i]=@elapsed Intan.main_loop(myrhd,handles,myctx,myctx2)
    end
    destroy(handles.win)
    mytimes
end

function total_test(amps)
    sleep(1.0)
    (myrhd,myhandles)=stress_init(amps)
    sleep(1.0)
    stress_times=stress_test(myrhd,myhandles)
end

function perform_test()
    st=zeros(Float64,8)

    myamp=RHD2132("PortA1")
    st[1]=mean(total_test(myamp))

    append!(myamp,RHD2132("PortA2"))
    st[2]=mean(total_test(myamp))

    append!(myamp,RHD2132("PortB1"))
    st[3]=mean(total_test(myamp))

    append!(myamp,RHD2132("PortB2"))
    st[4]=mean(total_test(myamp))

    append!(myamp,RHD2132("PortC1"))
    st[5]=mean(total_test(myamp))

    append!(myamp,RHD2132("PortC2"))
    st[6]=mean(total_test(myamp))

    append!(myamp,RHD2132("PortD1"))
    st[7]=mean(total_test(myamp))

    append!(myamp,RHD2132("PortD2"))
    st[8]=mean(total_test(myamp))

    #normalize
    st=st./(Intan.SAMPLES_PER_DATA_BLOCK/30000)
    println(st)

end

end


text:
MIMETYPES_DICT = Dict([
    (".x3d", "application/vnd.hzn-3d-crossword"),
    (".3gp", "video/3gpp"),
    (".3g2", "video/3gpp2"),
    (".mseq", "application/vnd.mseq"),
    (".pwn", "application/vnd.3m.post-it-notes"),
    (".plb", "application/vnd.3gpp.pic-bw-large"),
    (".psb", "application/vnd.3gpp.pic-bw-small"),
    (".pvb", "application/vnd.3gpp.pic-bw-var"),
    (".tcap", "application/vnd.3gpp2.tcap"),
    (".7z", "application/x-7z-compressed"),
    (".abw", "application/x-abiword"),
    (".ace", "application/x-ace-compressed"),
    (".acc", "application/vnd.americandynamics.acc"),
    (".acu", "application/vnd.acucobol"),
    (".atc", "application/vnd.acucorp"),
    (".adp", "audio/adpcm"),
    (".aab", "application/x-authorware-bin"),
    (".aam", "application/x-authorware-map"),
    (".aas", "application/x-authorware-seg"),
    (".air", "application/vnd.adobe.air-application-installer-package+zip"),
    (".swf", "application/x-shockwave-flash"),
    (".fxp", "application/vnd.adobe.fxp"),
    (".pdf", "application/pdf"),
    (".ppd", "application/vnd.cups-ppd"),
    (".dir", "application/x-director"),
    (".xdp", "application/vnd.adobe.xdp+xml"),
    (".xfdf", "application/vnd.adobe.xfdf"),
    (".aac", "audio/x-aac"),
    (".ahead", "application/vnd.ahead.space"),
    (".azf", "application/vnd.airzip.filesecure.azf"),
    (".azs", "application/vnd.airzip.filesecure.azs"),
    (".azw", "application/vnd.amazon.ebook"),
    (".ami", "application/vnd.amiga.ami"),
    (".apk", "application/vnd.android.package-archive"),
    (".cii", "application/vnd.anser-web-certificate-issue-initiation"),
    (".fti", "application/vnd.anser-web-funds-transfer-initiation"),
    (".atx", "application/vnd.antix.game-component"),
    (".mpkg", "application/vnd.apple.installer+xml"),
    (".aw", "application/applixware"),
    (".les", "application/vnd.hhe.lesson-player"),
    (".swi", "application/vnd.aristanetworks.swi"),
    (".s", "text/x-asm"),
    (".atomcat", "application/atomcat+xml"),
    (".atomsvc", "application/atomsvc+xml"),
    (".atom, .xml", "application/atom+xml"),
    (".ac", "application/pkix-attr-cert"),
    (".aif", "audio/x-aiff"),
    (".avi", "video/x-msvideo"),
    (".aep", "application/vnd.audiograph"),
    (".dxf", "image/vnd.dxf"),
    (".dwf", "model/vnd.dwf"),
    (".par", "text/plain-bas"),
    (".bcpio", "application/x-bcpio"),
    (".bin", "application/octet-stream"),
    (".bmp", "image/bmp"),
    (".torrent", "application/x-bittorrent"),
    (".cod", "application/vnd.rim.cod"),
    (".mpm", "application/vnd.blueice.multipass"),
    (".bmi", "application/vnd.bmi"),
    (".sh", "application/x-sh"),
    (".btif", "image/prs.btif"),
    (".rep", "application/vnd.businessobjects"),
    (".bz", "application/x-bzip"),
    (".bz2", "application/x-bzip2"),
    (".csh", "application/x-csh"),
    (".c", "text/x-c"),
    (".cdxml", "application/vnd.chemdraw+xml"),
    (".css", "text/css"),
    (".cdx", "chemical/x-cdx"),
    (".cml", "chemical/x-cml"),
    (".csml", "chemical/x-csml"),
    (".cdbcmsg", "application/vnd.contact.cmsg"),
    (".cla", "application/vnd.claymore"),
    (".c4g", "application/vnd.clonk.c4group"),
    (".sub", "image/vnd.dvb.subtitle"),
    (".cdmia", "application/cdmi-capability"),
    (".cdmic", "application/cdmi-container"),
    (".cdmid", "application/cdmi-domain"),
    (".cdmio", "application/cdmi-object"),
    (".cdmiq", "application/cdmi-queue"),
    (".c11amc", "application/vnd.cluetrust.cartomobile-config"),
    (".c11amz", "application/vnd.cluetrust.cartomobile-config-pkg"),
    (".ras", "image/x-cmu-raster"),
    (".dae", "model/vnd.collada+xml"),
    (".csv", "text/csv"),
    (".cpt", "application/mac-compactpro"),
    (".wmlc", "application/vnd.wap.wmlc"),
    (".cgm", "image/cgm"),
    (".ice", "x-conference/x-cooltalk"),
    (".cmx", "image/x-cmx"),
    (".xar", "application/vnd.xara"),
    (".cmc", "application/vnd.cosmocaller"),
    (".cpio", "application/x-cpio"),
    (".clkx", "application/vnd.crick.clicker"),
    (".clkk", "application/vnd.crick.clicker.keyboard"),
    (".clkp", "application/vnd.crick.clicker.palette"),
    (".clkt", "application/vnd.crick.clicker.template"),
    (".clkw", "application/vnd.crick.clicker.wordbank"),
    (".wbs", "application/vnd.criticaltools.wbs+xml"),
    (".cryptonote", "application/vnd.rig.cryptonote"),
    (".cif", "chemical/x-cif"),
    (".cmdf", "chemical/x-cmdf"),
    (".cu", "application/cu-seeme"),
    (".cww", "application/prs.cww"),
    (".curl", "text/vnd.curl"),
    (".dcurl", "text/vnd.curl.dcurl"),
    (".mcurl", "text/vnd.curl.mcurl"),
    (".scurl", "text/vnd.curl.scurl"),
    (".car", "application/vnd.curl.car"),
    (".pcurl", "application/vnd.curl.pcurl"),
    (".cmp", "application/vnd.yellowriver-custom-menu"),
    (".dssc", "application/dssc+der"),
    (".xdssc", "application/dssc+xml"),
    (".deb", "application/x-debian-package"),
    (".uva", "audio/vnd.dece.audio"),
    (".uvi", "image/vnd.dece.graphic"),
    (".uvh", "video/vnd.dece.hd"),
    (".uvm", "video/vnd.dece.mobile"),
    (".uvu", "video/vnd.uvvu.mp4"),
    (".uvp", "video/vnd.dece.pd"),
    (".uvs", "video/vnd.dece.sd"),
    (".uvv", "video/vnd.dece.video"),
    (".dvi", "application/x-dvi"),
    (".seed", "application/vnd.fdsn.seed"),
    (".dtb", "application/x-dtbook+xml"),
    (".res", "application/x-dtbresource+xml"),
    (".ait", "application/vnd.dvb.ait"),
    (".svc", "application/vnd.dvb.service"),
    (".eol", "audio/vnd.digital-winds"),
    (".djvu", "image/vnd.djvu"),
    (".dtd", "application/xml-dtd"),
    (".mlp", "application/vnd.dolby.mlp"),
    (".wad", "application/x-doom"),
    (".dpg", "application/vnd.dpgraph"),
    (".dra", "audio/vnd.dra"),
    (".dfac", "application/vnd.dreamfactory"),
    (".dts", "audio/vnd.dts"),
    (".dtshd", "audio/vnd.dts.hd"),
    (".dwg", "image/vnd.dwg"),
    (".geo", "application/vnd.dynageo"),
    (".es", "application/ecmascript"),
    (".mag", "application/vnd.ecowin.chart"),
    (".mmr", "image/vnd.fujixerox.edmics-mmr"),
    (".rlc", "image/vnd.fujixerox.edmics-rlc"),
    (".exi", "application/exi"),
    (".mgz", "application/vnd.proteus.magazine"),
    (".epub", "application/epub+zip"),
    (".eml", "message/rfc822"),
    (".nml", "application/vnd.enliven"),
    (".xpr", "application/vnd.is-xpr"),
    (".xif", "image/vnd.xiff"),
    (".xfdl", "application/vnd.xfdl"),
    (".emma", "application/emma+xml"),
    (".ez2", "application/vnd.ezpix-album"),
    (".ez3", "application/vnd.ezpix-package"),
    (".fst", "image/vnd.fst"),
    (".fvt", "video/vnd.fvt"),
    (".fbs", "image/vnd.fastbidsheet"),
    (".fe_launch", "application/vnd.denovo.fcselayout-link"),
    (".f4v", "video/x-f4v"),
    (".flv", "video/x-flv"),
    (".fpx", "image/vnd.fpx"),
    (".npx", "image/vnd.net-fpx"),
    (".flx", "text/vnd.fmi.flexstor"),
    (".fli", "video/x-fli"),
    (".ftc", "application/vnd.fluxtime.clip"),
    (".fdf", "application/vnd.fdf"),
    (".f", "text/x-fortran"),
    (".mif", "application/vnd.mif"),
    (".fm", "application/vnd.framemaker"),
    (".fh", "image/x-freehand"),
    (".fsc", "application/vnd.fsc.weblaunch"),
    (".fnc", "application/vnd.frogans.fnc"),
    (".ltf", "application/vnd.frogans.ltf"),
    (".ddd", "application/vnd.fujixerox.ddd"),
    (".xdw", "application/vnd.fujixerox.docuworks"),
    (".xbd", "application/vnd.fujixerox.docuworks.binder"),
    (".oas", "application/vnd.fujitsu.oasys"),
    (".oa2", "application/vnd.fujitsu.oasys2"),
    (".oa3", "application/vnd.fujitsu.oasys3"),
    (".fg5", "application/vnd.fujitsu.oasysgp"),
    (".bh2", "application/vnd.fujitsu.oasysprs"),
    (".spl", "application/x-futuresplash"),
    (".fzs", "application/vnd.fuzzysheet"),
    (".g3", "image/g3fax"),
    (".gmx", "application/vnd.gmx"),
    (".gtw", "model/vnd.gtw"),
    (".txd", "application/vnd.genomatix.tuxedo"),
    (".ggb", "application/vnd.geogebra.file"),
    (".ggt", "application/vnd.geogebra.tool"),
    (".gdl", "model/vnd.gdl"),
    (".gex", "application/vnd.geometry-explorer"),
    (".gxt", "application/vnd.geonext"),
    (".g2w", "application/vnd.geoplan"),
    (".g3w", "application/vnd.geospace"),
    (".gsf", "application/x-font-ghostscript"),
    (".bdf", "application/x-font-bdf"),
    (".gtar", "application/x-gtar"),
    (".texinfo", "application/x-texinfo"),
    (".gnumeric", "application/x-gnumeric"),
    (".kml", "application/vnd.google-earth.kml+xml"),
    (".kmz", "application/vnd.google-earth.kmz"),
    (".gqf", "application/vnd.grafeq"),
    (".gif", "image/gif"),
    (".gv", "text/vnd.graphviz"),
    (".gac", "application/vnd.groove-account"),
    (".ghf", "application/vnd.groove-help"),
    (".gim", "application/vnd.groove-identity-message"),
    (".grv", "application/vnd.groove-injector"),
    (".gtm", "application/vnd.groove-tool-message"),
    (".tpl", "application/vnd.groove-tool-template"),
    (".vcg", "application/vnd.groove-vcard"),
    (".h261", "video/h261"),
    (".h263", "video/h263"),
    (".h264", "video/h264"),
    (".hpid", "application/vnd.hp-hpid"),
    (".hps", "application/vnd.hp-hps"),
    (".hdf", "application/x-hdf"),
    (".rip", "audio/vnd.rip"),
    (".hbci", "application/vnd.hbci"),
    (".jlt", "application/vnd.hp-jlyt"),
    (".pcl", "application/vnd.hp-pcl"),
    (".hpgl", "application/vnd.hp-hpgl"),
    (".hvs", "application/vnd.yamaha.hv-script"),
    (".hvd", "application/vnd.yamaha.hv-dic"),
    (".hvp", "application/vnd.yamaha.hv-voice"),
    (".sfd-hdstx", "application/vnd.hydrostatix.sof-data"),
    (".stk", "application/hyperstudio"),
    (".hal", "application/vnd.hal+xml"),
    (".html", "text/html"),
    (".irm", "application/vnd.ibm.rights-management"),
    (".sc", "application/vnd.ibm.secure-container"),
    (".ics", "text/calendar"),
    (".icc", "application/vnd.iccprofile"),
    (".ico", "image/x-icon"),
    (".igl", "application/vnd.igloader"),
    (".ief", "image/ief"),
    (".ivp", "application/vnd.immervision-ivp"),
    (".ivu", "application/vnd.immervision-ivu"),
    (".rif", "application/reginfo+xml"),
    (".3dml", "text/vnd.in3d.3dml"),
    (".spot", "text/vnd.in3d.spot"),
    (".igs", "model/iges"),
    (".i2g", "application/vnd.intergeo"),
    (".cdy", "application/vnd.cinderella"),
    (".xpw", "application/vnd.intercon.formnet"),
    (".fcs", "application/vnd.isac.fcs"),
    (".ipfix", "application/ipfix"),
    (".cer", "application/pkix-cert"),
    (".pki", "application/pkixcmp"),
    (".crl", "application/pkix-crl"),
    (".pkipath", "application/pkix-pkipath"),
    (".igm", "application/vnd.insors.igm"),
    (".rcprofile", "application/vnd.ipunplugged.rcprofile"),
    (".irp", "application/vnd.irepository.package+xml"),
    (".jad", "text/vnd.sun.j2me.app-descriptor"),
    (".jar", "application/java-archive"),
    (".class", "application/java-vm"),
    (".jnlp", "application/x-java-jnlp-file"),
    (".ser", "application/java-serialized-object"),
    (".java", "text/x-java-source,java"),
    (".js", "application/javascript"),
    (".json", "application/json"),
    (".joda", "application/vnd.joost.joda-archive"),
    (".jpm", "video/jpm"),
    (".jpeg, .jpg", "image/jpeg"),
    (".jpgv", "video/jpeg"),
    (".ktz", "application/vnd.kahootz"),
    (".mmd", "application/vnd.chipnuts.karaoke-mmd"),
    (".karbon", "application/vnd.kde.karbon"),
    (".chrt", "application/vnd.kde.kchart"),
    (".kfo", "application/vnd.kde.kformula"),
    (".flw", "application/vnd.kde.kivio"),
    (".kon", "application/vnd.kde.kontour"),
    (".kpr", "application/vnd.kde.kpresenter"),
    (".ksp", "application/vnd.kde.kspread"),
    (".kwd", "application/vnd.kde.kword"),
    (".htke", "application/vnd.kenameaapp"),
    (".kia", "application/vnd.kidspiration"),
    (".kne", "application/vnd.kinar"),
    (".sse", "application/vnd.kodak-descriptor"),
    (".lasxml", "application/vnd.las.las+xml"),
    (".latex", "application/x-latex"),
    (".lbd", "application/vnd.llamagraphics.life-balance.desktop"),
    (".lbe", "application/vnd.llamagraphics.life-balance.exchange+xml"),
    (".jam", "application/vnd.jam"),
    (".123", "application/vnd.lotus-1-2-3"),
    (".apr", "application/vnd.lotus-approach"),
    (".pre", "application/vnd.lotus-freelance"),
    (".nsf", "application/vnd.lotus-notes"),
    (".org", "application/vnd.lotus-organizer"),
    (".scm", "application/vnd.lotus-screencam"),
    (".lwp", "application/vnd.lotus-wordpro"),
    (".lvp", "audio/vnd.lucent.voice"),
    (".m3u", "audio/x-mpegurl"),
    (".m4v", "video/x-m4v"),
    (".hqx", "application/mac-binhex40"),
    (".portpkg", "application/vnd.macports.portpkg"),
    (".mgp", "application/vnd.osgeo.mapguide.package"),
    (".mrc", "application/marc"),
    (".mrcx", "application/marcxml+xml"),
    (".mxf", "application/mxf"),
    (".nbp", "application/vnd.wolfram.player"),
    (".ma", "application/mathematica"),
    (".mathml", "application/mathml+xml"),
    (".mbox", "application/mbox"),
    (".mc1", "application/vnd.medcalcdata"),
    (".mscml", "application/mediaservercontrol+xml"),
    (".cdkey", "application/vnd.mediastation.cdkey"),
    (".mwf", "application/vnd.mfer"),
    (".mfm", "application/vnd.mfmp"),
    (".msh", "model/mesh"),
    (".mads", "application/mads+xml"),
    (".mets", "application/mets+xml"),
    (".mods", "application/mods+xml"),
    (".meta4", "application/metalink4+xml"),
    (".potm", "application/vnd.ms-powerpoint.template.macroenabled.12"),
    (".docm", "application/vnd.ms-word.document.macroenabled.12"),
    (".dotm", "application/vnd.ms-word.template.macroenabled.12"),
    (".mcd", "application/vnd.mcd"),
    (".flo", "application/vnd.micrografx.flo"),
    (".igx", "application/vnd.micrografx.igx"),
    (".es3", "application/vnd.eszigno3+xml"),
    (".mdb", "application/x-msaccess"),
    (".asf", "video/x-ms-asf"),
    (".exe", "application/x-msdownload"),
    (".cil", "application/vnd.ms-artgalry"),
    (".cab", "application/vnd.ms-cab-compressed"),
    (".ims", "application/vnd.ms-ims"),
    (".application", "application/x-ms-application"),
    (".clp", "application/x-msclip"),
    (".mdi", "image/vnd.ms-modi"),
    (".eot", "application/vnd.ms-fontobject"),
    (".xls", "application/vnd.ms-excel"),
    (".xlam", "application/vnd.ms-excel.addin.macroenabled.12"),
    (".xlsb", "application/vnd.ms-excel.sheet.binary.macroenabled.12"),
    (".xltm", "application/vnd.ms-excel.template.macroenabled.12"),
    (".xlsm", "application/vnd.ms-excel.sheet.macroenabled.12"),
    (".chm", "application/vnd.ms-htmlhelp"),
    (".crd", "application/x-mscardfile"),
    (".lrm", "application/vnd.ms-lrm"),
    (".mvb", "application/x-msmediaview"),
    (".mny", "application/x-msmoney"),
    (".pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation"),
    (".sldx", "application/vnd.openxmlformats-officedocument.presentationml.slide"),
    (".ppsx", "application/vnd.openxmlformats-officedocument.presentationml.slideshow"),
    (".potx", "application/vnd.openxmlformats-officedocument.presentationml.template"),
    (".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),
    (".xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template"),
    (".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"),
    (".dotx", "application/vnd.openxmlformats-officedocument.wordprocessingml.template"),
    (".obd", "application/x-msbinder"),
    (".thmx", "application/vnd.ms-officetheme"),
    (".onetoc", "application/onenote"),
    (".pya", "audio/vnd.ms-playready.media.pya"),
    (".pyv", "video/vnd.ms-playready.media.pyv"),
    (".ppt", "application/vnd.ms-powerpoint"),
    (".ppam", "application/vnd.ms-powerpoint.addin.macroenabled.12"),
    (".sldm", "application/vnd.ms-powerpoint.slide.macroenabled.12"),
    (".pptm", "application/vnd.ms-powerpoint.presentation.macroenabled.12"),
    (".ppsm", "application/vnd.ms-powerpoint.slideshow.macroenabled.12"),
    (".mpp", "application/vnd.ms-project"),
    (".pub", "application/x-mspublisher"),
    (".scd", "application/x-msschedule"),
    (".xap", "application/x-silverlight-app"),
    (".stl", "application/vnd.ms-pki.stl"),
    (".cat", "application/vnd.ms-pki.seccat"),
    (".vsd", "application/vnd.visio"),
    (".wm", "video/x-ms-wm"),
    (".wma", "audio/x-ms-wma"),
    (".wax", "audio/x-ms-wax"),
    (".wmx", "video/x-ms-wmx"),
    (".wmd", "application/x-ms-wmd"),
    (".wpl", "application/vnd.ms-wpl"),
    (".wmz", "application/x-ms-wmz"),
    (".wmv", "video/x-ms-wmv"),
    (".wvx", "video/x-ms-wvx"),
    (".wmf", "application/x-msmetafile"),
    (".trm", "application/x-msterminal"),
    (".doc", "application/msword"),
    (".wri", "application/x-mswrite"),
    (".wps", "application/vnd.ms-works"),
    (".xbap", "application/x-ms-xbap"),
    (".xps", "application/vnd.ms-xpsdocument"),
    (".mid", "audio/midi"),
    (".mpy", "application/vnd.ibm.minipay"),
    (".afp", "application/vnd.ibm.modcap"),
    (".rms", "application/vnd.jcp.javame.midlet-rms"),
    (".tmo", "application/vnd.tmobile-livetv"),
    (".prc", "application/x-mobipocket-ebook"),
    (".mbk", "application/vnd.mobius.mbk"),
    (".dis", "application/vnd.mobius.dis"),
    (".plc", "application/vnd.mobius.plc"),
    (".mqy", "application/vnd.mobius.mqy"),
    (".msl", "application/vnd.mobius.msl"),
    (".txf", "application/vnd.mobius.txf"),
    (".daf", "application/vnd.mobius.daf"),
    (".fly", "text/vnd.fly"),
    (".mpc", "application/vnd.mophun.certificate"),
    (".mpn", "application/vnd.mophun.application"),
    (".mj2", "video/mj2"),
    (".mpga", "audio/mpeg"),
    (".mxu", "video/vnd.mpegurl"),
    (".mpeg", "video/mpeg"),
    (".m21", "application/mp21"),
    (".mp4a", "audio/mp4"),
    (".mp4", "video/mp4"),
    (".mp4", "application/mp4"),
    (".m3u8", "application/vnd.apple.mpegurl"),
    (".mus", "application/vnd.musician"),
    (".msty", "application/vnd.muvee.style"),
    (".mxml", "application/xv+xml"),
    (".ngdat", "application/vnd.nokia.n-gage.data"),
    (".n-gage", "application/vnd.nokia.n-gage.symbian.install"),
    (".ncx", "application/x-dtbncx+xml"),
    (".nc", "application/x-netcdf"),
    (".nlu", "application/vnd.neurolanguage.nlu"),
    (".dna", "application/vnd.dna"),
    (".nnd", "application/vnd.noblenet-directory"),
    (".nns", "application/vnd.noblenet-sealer"),
    (".nnw", "application/vnd.noblenet-web"),
    (".rpst", "application/vnd.nokia.radio-preset"),
    (".rpss", "application/vnd.nokia.radio-presets"),
    (".n3", "text/n3"),
    (".edm", "application/vnd.novadigm.edm"),
    (".edx", "application/vnd.novadigm.edx"),
    (".ext", "application/vnd.novadigm.ext"),
    (".gph", "application/vnd.flographit"),
    (".ecelp4800", "audio/vnd.nuera.ecelp4800"),
    (".ecelp7470", "audio/vnd.nuera.ecelp7470"),
    (".ecelp9600", "audio/vnd.nuera.ecelp9600"),
    (".oda", "application/oda"),
    (".ogx", "application/ogg"),
    (".oga", "audio/ogg"),
    (".ogv", "video/ogg"),
    (".dd2", "application/vnd.oma.dd2+xml"),
    (".oth", "application/vnd.oasis.opendocument.text-web"),
    (".opf", "application/oebps-package+xml"),
    (".qbo", "application/vnd.intu.qbo"),
    (".oxt", "application/vnd.openofficeorg.extension"),
    (".osf", "application/vnd.yamaha.openscoreformat"),
    (".weba", "audio/webm"),
    (".webm", "video/webm"),
    (".odc", "application/vnd.oasis.opendocument.chart"),
    (".otc", "application/vnd.oasis.opendocument.chart-template"),
    (".odb", "application/vnd.oasis.opendocument.database"),
    (".odf", "application/vnd.oasis.opendocument.formula"),
    (".odft", "application/vnd.oasis.opendocument.formula-template"),
    (".odg", "application/vnd.oasis.opendocument.graphics"),
    (".otg", "application/vnd.oasis.opendocument.graphics-template"),
    (".odi", "application/vnd.oasis.opendocument.image"),
    (".oti", "application/vnd.oasis.opendocument.image-template"),
    (".odp", "application/vnd.oasis.opendocument.presentation"),
    (".otp", "application/vnd.oasis.opendocument.presentation-template"),
    (".ods", "application/vnd.oasis.opendocument.spreadsheet"),
    (".ots", "application/vnd.oasis.opendocument.spreadsheet-template"),
    (".odt", "application/vnd.oasis.opendocument.text"),
    (".odm", "application/vnd.oasis.opendocument.text-master"),
    (".ott", "application/vnd.oasis.opendocument.text-template"),
    (".ktx", "image/ktx"),
    (".sxc", "application/vnd.sun.xml.calc"),
    (".stc", "application/vnd.sun.xml.calc.template"),
    (".sxd", "application/vnd.sun.xml.draw"),
    (".std", "application/vnd.sun.xml.draw.template"),
    (".sxi", "application/vnd.sun.xml.impress"),
    (".sti", "application/vnd.sun.xml.impress.template"),
    (".sxm", "application/vnd.sun.xml.math"),
    (".sxw", "application/vnd.sun.xml.writer"),
    (".sxg", "application/vnd.sun.xml.writer.global"),
    (".stw", "application/vnd.sun.xml.writer.template"),
    (".otf", "application/x-font-otf"),
    (".osfpvg", "application/vnd.yamaha.openscoreformat.osfpvg+xml"),
    (".dp", "application/vnd.osgi.dp"),
    (".pdb", "application/vnd.palm"),
    (".p", "text/x-pascal"),
    (".paw", "application/vnd.pawaafile"),
    (".pclxl", "application/vnd.hp-pclxl"),
    (".efif", "application/vnd.picsel"),
    (".pcx", "image/x-pcx"),
    (".psd", "image/vnd.adobe.photoshop"),
    (".prf", "application/pics-rules"),
    (".pic", "image/x-pict"),
    (".chat", "application/x-chat"),
    (".p10", "application/pkcs10"),
    (".p12", "application/x-pkcs12"),
    (".p7m", "application/pkcs7-mime"),
    (".p7s", "application/pkcs7-signature"),
    (".p7r", "application/x-pkcs7-certreqresp"),
    (".p7b", "application/x-pkcs7-certificates"),
    (".p8", "application/pkcs8"),
    (".plf", "application/vnd.pocketlearn"),
    (".pnm", "image/x-portable-anymap"),
    (".pbm", "image/x-portable-bitmap"),
    (".pcf", "application/x-font-pcf"),
    (".pfr", "application/font-tdpfr"),
    (".pgn", "application/x-chess-pgn"),
    (".pgm", "image/x-portable-graymap"),
    (".png", "image/png"),
    (".ppm", "image/x-portable-pixmap"),
    (".pskcxml", "application/pskc+xml"),
    (".pml", "application/vnd.ctc-posml"),
    (".ai", "application/postscript"),
    (".pfa", "application/x-font-type1"),
    (".pbd", "application/vnd.powerbuilder6"),
    ("RFC 2015", "application/pgp-encrypted"),
    (".pgp", "application/pgp-signature"),
    (".box", "application/vnd.previewsystems.box"),
    (".ptid", "application/vnd.pvi.ptid1"),
    (".pls", "application/pls+xml"),
    (".str", "application/vnd.pg.format"),
    (".ei6", "application/vnd.pg.osasli"),
    (".dsc", "text/prs.lines.tag"),
    (".psf", "application/x-font-linux-psf"),
    (".qps", "application/vnd.publishare-delta-tree"),
    (".wg", "application/vnd.pmi.widget"),
    (".qxd", "application/vnd.quark.quarkxpress"),
    (".esf", "application/vnd.epson.esf"),
    (".msf", "application/vnd.epson.msf"),
    (".ssf", "application/vnd.epson.ssf"),
    (".qam", "application/vnd.epson.quickanime"),
    (".qfx", "application/vnd.intu.qfx"),
    (".qt", "video/quicktime"),
    (".rar", "application/x-rar-compressed"),
    (".ram", "audio/x-pn-realaudio"),
    (".rmp", "audio/x-pn-realaudio-plugin"),
    (".rsd", "application/rsd+xml"),
    (".rm", "application/vnd.rn-realmedia"),
    (".bed", "application/vnd.realvnc.bed"),
    (".mxl", "application/vnd.recordare.musicxml"),
    (".musicxml", "application/vnd.recordare.musicxml+xml"),
    (".rnc", "application/relax-ng-compact-syntax"),
    (".rdz", "application/vnd.data-vision.rdz"),
    (".rdf", "application/rdf+xml"),
    (".rp9", "application/vnd.cloanto.rp9"),
    (".jisp", "application/vnd.jisp"),
    (".rtf", "application/rtf"),
    (".rtx", "text/richtext"),
    (".link66", "application/vnd.route66.link66+xml"),
    (".rss, .xml", "application/rss+xml"),
    (".shf", "application/shf+xml"),
    (".st", "application/vnd.sailingtracker.track"),
    (".svg", "image/svg+xml"),
    (".sus", "application/vnd.sus-calendar"),
    (".sru", "application/sru+xml"),
    (".setpay", "application/set-payment-initiation"),
    (".setreg", "application/set-registration-initiation"),
    (".sema", "application/vnd.sema"),
    (".semd", "application/vnd.semd"),
    (".semf", "application/vnd.semf"),
    (".see", "application/vnd.seemail"),
    (".snf", "application/x-font-snf"),
    (".spq", "application/scvp-vp-request"),
    (".spp", "application/scvp-vp-response"),
    (".scq", "application/scvp-cv-request"),
    (".scs", "application/scvp-cv-response"),
    (".sdp", "application/sdp"),
    (".etx", "text/x-setext"),
    (".movie", "video/x-sgi-movie"),
    (".ifm", "application/vnd.shana.informed.formdata"),
    (".itp", "application/vnd.shana.informed.formtemplate"),
    (".iif", "application/vnd.shana.informed.interchange"),
    (".ipk", "application/vnd.shana.informed.package"),
    (".tfi", "application/thraud+xml"),
    (".shar", "application/x-shar"),
    (".rgb", "image/x-rgb"),
    (".slt", "application/vnd.epson.salt"),
    (".aso", "application/vnd.accpac.simply.aso"),
    (".imp", "application/vnd.accpac.simply.imp"),
    (".twd", "application/vnd.simtech-mindmapper"),
    (".csp", "application/vnd.commonspace"),
    (".saf", "application/vnd.yamaha.smaf-audio"),
    (".mmf", "application/vnd.smaf"),
    (".spf", "application/vnd.yamaha.smaf-phrase"),
    (".teacher", "application/vnd.smart.teacher"),
    (".svd", "application/vnd.svd"),
    (".rq", "application/sparql-query"),
    (".srx", "application/sparql-results+xml"),
    (".gram", "application/srgs"),
    (".grxml", "application/srgs+xml"),
    (".ssml", "application/ssml+xml"),
    (".skp", "application/vnd.koan"),
    (".sgml", "text/sgml"),
    (".sdc", "application/vnd.stardivision.calc"),
    (".sda", "application/vnd.stardivision.draw"),
    (".sdd", "application/vnd.stardivision.impress"),
    (".smf", "application/vnd.stardivision.math"),
    (".sdw", "application/vnd.stardivision.writer"),
    (".sgl", "application/vnd.stardivision.writer-global"),
    (".sm", "application/vnd.stepmania.stepchart"),
    (".sit", "application/x-stuffit"),
    (".sitx", "application/x-stuffitx"),
    (".sdkm", "application/vnd.solent.sdkm+xml"),
    (".xo", "application/vnd.olpc-sugar"),
    (".au", "audio/basic"),
    (".wqd", "application/vnd.wqd"),
    (".sis", "application/vnd.symbian.install"),
    (".smi", "application/smil+xml"),
    (".xsm", "application/vnd.syncml+xml"),
    (".bdm", "application/vnd.syncml.dm+wbxml"),
    (".xdm", "application/vnd.syncml.dm+xml"),
    (".sv4cpio", "application/x-sv4cpio"),
    (".sv4crc", "application/x-sv4crc"),
    (".sbml", "application/sbml+xml"),
    (".tsv", "text/tab-separated-values"),
    (".tiff", "image/tiff"),
    (".tao", "application/vnd.tao.intent-module-archive"),
    (".tar", "application/x-tar"),
    (".tcl", "application/x-tcl"),
    (".tex", "application/x-tex"),
    (".tfm", "application/x-tex-tfm"),
    (".tei", "application/tei+xml"),
    (".txt", "text/plain"),
    (".dxp", "application/vnd.spotfire.dxp"),
    (".sfs", "application/vnd.spotfire.sfs"),
    (".tsd", "application/timestamped-data"),
    (".tpt", "application/vnd.trid.tpt"),
    (".mxs", "application/vnd.triscape.mxs"),
    (".t", "text/troff"),
    (".tra", "application/vnd.trueapp"),
    (".ttf", "application/x-font-ttf"),
    (".ttl", "text/turtle"),
    (".umj", "application/vnd.umajin"),
    (".uoml", "application/vnd.uoml+xml"),
    (".unityweb", "application/vnd.unity"),
    (".ufd", "application/vnd.ufdl"),
    (".uri", "text/uri-list"),
    (".utz", "application/vnd.uiq.theme"),
    (".ustar", "application/x-ustar"),
    (".uu", "text/x-uuencode"),
    (".vcs", "text/x-vcalendar"),
    (".vcf", "text/x-vcard"),
    (".vcd", "application/x-cdlink"),
    (".vsf", "application/vnd.vsf"),
    (".wrl", "model/vrml"),
    (".vcx", "application/vnd.vcx"),
    (".mts", "model/vnd.mts"),
    (".vtu", "model/vnd.vtu"),
    (".vis", "application/vnd.visionary"),
    (".viv", "video/vnd.vivo"),
    (".ccxml", "application/ccxml+xml,"),
    (".vxml", "application/voicexml+xml"),
    (".src", "application/x-wais-source"),
    (".wbxml", "application/vnd.wap.wbxml"),
    (".wbmp", "image/vnd.wap.wbmp"),
    (".wav", "audio/x-wav"),
    (".davmount", "application/davmount+xml"),
    (".woff", "application/x-font-woff"),
    (".wspolicy", "application/wspolicy+xml"),
    (".webp", "image/webp"),
    (".wtb", "application/vnd.webturbo"),
    (".wgt", "application/widget"),
    (".hlp", "application/winhlp"),
    (".wml", "text/vnd.wap.wml"),
    (".wmls", "text/vnd.wap.wmlscript"),
    (".wmlsc", "application/vnd.wap.wmlscriptc"),
    (".wpd", "application/vnd.wordperfect"),
    (".stf", "application/vnd.wt.stf"),
    (".wsdl", "application/wsdl+xml"),
    (".xbm", "image/x-xbitmap"),
    (".xpm", "image/x-xpixmap"),
    (".xwd", "image/x-xwindowdump"),
    (".der", "application/x-x509-ca-cert"),
    (".fig", "application/x-xfig"),
    (".xhtml", "application/xhtml+xml"),
    (".xml", "application/xml"),
    (".xdf", "application/xcap-diff+xml"),
    (".xenc", "application/xenc+xml"),
    (".xer", "application/patch-ops-error+xml"),
    (".rl", "application/resource-lists+xml"),
    (".rs", "application/rls-services+xml"),
    (".rld", "application/resource-lists-diff+xml"),
    (".xslt", "application/xslt+xml"),
    (".xop", "application/xop+xml"),
    (".xpi", "application/x-xpinstall"),
    (".xspf", "application/xspf+xml"),
    (".xul", "application/vnd.mozilla.xul+xml"),
    (".xyz", "chemical/x-xyz"),
    (".yaml", "text/yaml"),
    (".yang", "application/yang"),
    (".yin", "application/yin+xml"),
    (".zir", "application/vnd.zul"),
    (".zip", "application/zip"),
    (".zmm", "application/vnd.handheld-entertainment+xml"),
    (".zaz", "application/vnd.zzazz.deck+xml"),
])


text:
# Copyright (c) 2018: Matthew Wilhelm & Matthew Stuber.
# This code is licensed under MIT license (see LICENSE.md for full details)
#############################################################################
# EAGO
# A development environment for robust and global optimization
# See https://github.com/PSORLab/EAGO.jl
#############################################################################
# src/eago_script/tracer.jl
# Utilities for tracing a user-defined function.
#############################################################################

struct NodeInfo
    nodetype::NodeType
    index::Int64
    children::Vector{Int64}
end
children(x::NodeInfo) = x.children

# convert method assumes that the children connectivity using in Tracer has
# has been converted to an area hold a single parent value as is used in JuMP
convert(::Type{NodeData}, x::NodeInfo) = NodeData(x.nodetype, x.index, x.children[1])

# val = 1..n corresponds to 1..n variable
struct SetTrace <: Real
    val::Int
end
SetTrace() = SetTrace(0)

val(x::SetTrace) = x.val

struct SetTraceSto
    storage::Vector{SetTrace}
end
getindex(A::SetTraceSto, i::Int64) = getindex(A.storage, i)
iterate(v::SetTraceSto, i=1) = (length(v.storage) < i ? nothing : (v.storage[i], i + 1))

export Tape

# JuMP convention is to store child from function... function call = -1,
# next highest call is has parent 1 and so on... This is a forward tape recording
# architecture, so we'll store children then invert...
mutable struct Tape
    nd::Vector{NodeInfo}
    const_values::Vector{Float64}
    num_valued::Dict{Int,Bool}
    set_trace_count::Int
    const_count::Int
end

Tape() = Tape(NodeInfo[], Float64[], Dict{Int,Bool}(), 0, 0)

function Tape(n::Int)
    node_list = [NodeInfo(VARIABLE,i,[-1]) for i = 1:n]
    num_valued = Dict{Int,Bool}()
    for i = 1:n
        num_valued[i] = false
    end
    Tape(node_list, Float64[], num_valued, n, 0)
end

function add_constant(x::Tape, y)
    x.set_trace_count += 1; x.const_count += 1
    node = NodeInfo(VALUE, x.const_count,[-2]); push!(x.nd, node)
    x.num_valued[x.set_trace_count] = true
    push!(x.const_values, Float64(y))
    x.set_trace_count
end

function add_set_node!(x::Tape, node::NodeInfo)
    push!(x.nd, node)
    x.set_trace_count += 1
    x.num_valued[x.set_trace_count] = false
end

@context TraceCtx

# defines primitives for CALLUNIVAR operators
for i in (abs, sin, cos, tan, sec, csc, cot, asin, acos, atan, asec, acsc,
          acot, sinh, cosh, tanh, asinh, acosh, atanh, sech, asech, csch,
          acsch, coth, acoth, sqrt, log, log2, log10, log1p, exp, exp2, expm1,
          +, -, inv)
    id = univariate_operator_to_id[Symbol(i)]
    @eval function Cassette.overdub(ctx::TraceCtx, ::typeof($i), x::SetTrace)
                add_set_node!(ctx.metadata, NodeInfo(CALLUNIVAR, $id, [val(x)]))
                return SetTrace(ctx.metadata.set_trace_count)
          end
    @eval Cassette.overdub(ctx::TraceCtx, ::typeof($i), x::Real) = ($i)(x)
end

# defines primitives for bivariate CALL operators (NEED TO ADD ^)
for i in (+, -, *, ^, /) # TODO ADD :max, :min
    id = operator_to_id[Symbol(i)]
    @eval function Cassette.overdub(ctx::TraceCtx, ::typeof($i), x::SetTrace, y::SetTrace)
               add_set_node!(ctx.metadata, NodeInfo(CALL, $id, [val(x), val(y)]))
               SetTrace(ctx.metadata.set_trace_count)
          end
    for j in (Int16,Int32,Int64,Float16,Float32,Float64,Irrational)
        @eval function Cassette.overdub(ctx::TraceCtx, ::typeof($i), x::SetTrace, y::($j))
                    add_set_node!(ctx.metadata, NodeInfo(CALL, $id, [val(x), add_constant(ctx.metadata, y)]))
                    SetTrace(ctx.metadata.set_trace_count)
              end
        @eval function Cassette.overdub(ctx::TraceCtx, ::typeof($i), x::($j), y::SetTrace)
                    add_set_node!(ctx.metadata, NodeInfo(CALL, $id, [add_constant(ctx.metadata, x),val(y)]))
                    SetTrace(ctx.metadata.set_trace_count)
              end
    end
    @eval Cassette.overdub(ctx::TraceCtx, ::typeof($i), x::Real, y::Real) = ($i)(x,y)
end

# defines primitives for bivariate COMPARISON operators
for i in (>,<,==,>=,<=)
    id = comparison_operator_to_id[Symbol(i)]
    @eval function Cassette.overdub(ctx::TraceCtx, ::typeof($i), x::SetTrace, y::SetTrace)
                add_set_node!(ctx.metadata, NodeInfo(COMPARISON, $id, [val(x), val(y)]))
                SetTrace(ctx.metadata.set_trace_count)
            end
    for j in (Int16,Int32,Int64,Float16,Float32,Float64,Irrational)
        @eval function Cassette.overdub(ctx::TraceCtx, ::typeof($i), x::SetTrace, y::($j))
                    add_set_node!(ctx.metadata, NodeInfo(COMPARISON, $id, [val(x),add_constant(ctx.metadata, y)]))
                    SetTrace(ctx.metadata.set_trace_count)
              end
        @eval function Cassette.overdub(ctx::TraceCtx, ::typeof($i), x::($j), y::SetTrace)
                    add_set_node!(ctx.metadata, NodeInfo(COMPARISON, $id, [add_constant(ctx.metadata, x), val(y)]))
                    SetTrace(ctx.metadata.set_trace_count)
              end
    end
    @eval Cassette.overdub(ctx::TraceCtx, ::typeof($i), x::Real, y::Real) = ($i)(x, y)
end

# define primitives for associative terms
Cassette.overdub(ctx::TraceCtx, ::typeof(*), x, y) = afoldl(x, y)
Cassette.overdub(ctx::TraceCtx, ::typeof(afoldl), x, y, z) = afoldl(x, y, z)
Cassette.overdub(ctx::TraceCtx, ::typeof(afoldl), a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p...) = afoldl(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p...)

# conversion
Cassette.overdub(ctx::TraceCtx, ::typeof(float), x) = x
Cassette.overdub(ctx::TraceCtx, ::typeof(AbstractFloat), x) = x

# primitive for array access
Cassette.overdub(ctx::TraceCtx, ::typeof(getindex), A::Array, i::Int) = getindex(A,i)
Cassette.overdub(ctx::TraceCtx, ::typeof(getindex), A::SetTraceSto, i::Int) = getindex(A,i)

function Cassette.overdub(ctx::TraceCtx, ::typeof(typeassert), x::Real, type::Type)
    if !isa(x,SetTrace)
        typeassert(x, type)
    end
    return x
end

# prehook for debugging mainly
function Cassette.prehook(ctx::TraceCtx, f::Function, args...)
    #println(f, args)
end

function trace_script(f::Function, n::Int)
    tape = Tape(n)
    if n > 1
        x = SetTraceSto(SetTrace[SetTrace(i) for i = 1:n])
        overdub(TraceCtx(metadata = tape), f, x)
    else
        overdub(TraceCtx(metadata = tape), f, SetTrace(1))
    end
    return tape
end

max_stars_repo_name: PSORLab/RSActivationFunctions

max_issues_repo_name: PSORLab/RSActivationFunctions

max_forks_repo_name: PSORLab/RSActivationFunctions


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

mutable struct IoK8sApiCoreV1NodeConfigStatus <: SwaggerModel
    active::Any # spec type: Union{ Nothing, IoK8sApiCoreV1NodeConfigSource } # spec name: active
    assigned::Any # spec type: Union{ Nothing, IoK8sApiCoreV1NodeConfigSource } # spec name: assigned
    error::Any # spec type: Union{ Nothing, String } # spec name: error
    lastKnownGood::Any # spec type: Union{ Nothing, IoK8sApiCoreV1NodeConfigSource } # spec name: lastKnownGood

    function IoK8sApiCoreV1NodeConfigStatus(;active=nothing, assigned=nothing, error=nothing, lastKnownGood=nothing)
        o = new()
        validate_property(IoK8sApiCoreV1NodeConfigStatus, Symbol("active"), active)
        setfield!(o, Symbol("active"), active)
        validate_property(IoK8sApiCoreV1NodeConfigStatus, Symbol("assigned"), assigned)
        setfield!(o, Symbol("assigned"), assigned)
        validate_property(IoK8sApiCoreV1NodeConfigStatus, Symbol("error"), error)
        setfield!(o, Symbol("error"), error)
        validate_property(IoK8sApiCoreV1NodeConfigStatus, Symbol("lastKnownGood"), lastKnownGood)
        setfield!(o, Symbol("lastKnownGood"), lastKnownGood)
        o
    end
end # type IoK8sApiCoreV1NodeConfigStatus

const _property_map_IoK8sApiCoreV1NodeConfigStatus = Dict{Symbol,Symbol}(Symbol("active")=>Symbol("active"), Symbol("assigned")=>Symbol("assigned"), Symbol("error")=>Symbol("error"), Symbol("lastKnownGood")=>Symbol("lastKnownGood"))
const _property_types_IoK8sApiCoreV1NodeConfigStatus = Dict{Symbol,String}(Symbol("active")=>"IoK8sApiCoreV1NodeConfigSource", Symbol("assigned")=>"IoK8sApiCoreV1NodeConfigSource", Symbol("error")=>"String", Symbol("lastKnownGood")=>"IoK8sApiCoreV1NodeConfigSource")
Base.propertynames(::Type{ IoK8sApiCoreV1NodeConfigStatus }) = collect(keys(_property_map_IoK8sApiCoreV1NodeConfigStatus))
Swagger.property_type(::Type{ IoK8sApiCoreV1NodeConfigStatus }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_IoK8sApiCoreV1NodeConfigStatus[name]))}
Swagger.field_name(::Type{ IoK8sApiCoreV1NodeConfigStatus }, property_name::Symbol) =  _property_map_IoK8sApiCoreV1NodeConfigStatus[property_name]

function check_required(o::IoK8sApiCoreV1NodeConfigStatus)
    true
end

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


text:
module ManifoldMeasures

using KeywordCalls,
    LinearAlgebra,
    Manifolds,
    MeasureTheory,
    Random,
    SpecialFunctions,
    StaticArrays,
    StatsBase,
    StatsFuns
using HypergeometricFunctions: HypergeometricFunctions
using Manifolds: ℝ

const MAX_LENGTH_SIZED = 100

# experimental implementation of Option 3 in
# https://github.com/cscherrer/MeasureTheory.jl/issues/129#issue-962733685
default_number_type(::typeof(ℝ), T) = real(T)
default_number_type(::typeof(ℂ), T) = complex(real(T))

function default_point(μ, S::Type)
    M = base_manifold(μ)
    T = default_number_type(number_system(M), S)
    sz = representation_size(M)
    return prod(sz) ≤ MAX_LENGTH_SIZED ? MArray{Tuple{sz...},T}(undef) : Array{T}(undef, sz)
end

Manifolds.base_manifold(μ::AbstractMeasure) = base_manifold(basemeasure(μ))

include("utils.jl")
include("specialfunctions.jl")
include("factorizations.jl")
include("normalized.jl")
include("haar.jl")
include("hausdorff.jl")

include("vonmisesfisher.jl")
include("bingham.jl")
include("angularcentralgaussian.jl")

# primitive
export Normalized, Hausdorff, Haar, LeftHaar, RightHaar

export AngularCentralGaussian, Bingham, VonMises, VonMisesFisher

export mode, normalize

end


text:
function nenergy(ecut,e0,ω=1.0,basis="Hermite")
  if basis=="Hermite"
    M = floor((ecut - e0)/ω)+1; M=Int(M)
    n = collect(0:(M-1))
    en = ω*(n+0.5)
  return M,n,en
  else
    error("basis not implemented")
  end
end


text: include("CTValueIterationADP.jl")


text:
# Autogenerated wrapper script for OpenCV_jll for aarch64-linux-gnu-cxx11
export libopencv_calib3d, libopencv_core, libopencv_dnn, libopencv_features2d, libopencv_flann, libopencv_gapi, libopencv_highgui, libopencv_imgcodecs, libopencv_imgproc, libopencv_julia, libopencv_objdetect, libopencv_stitching, libopencv_video, libopencv_videoio

using Qt5Base_jll
using Libglvnd_jll
using libcxxwrap_julia_jll
JLLWrappers.@generate_wrapper_header("OpenCV")
JLLWrappers.@declare_library_product(libopencv_calib3d, "libopencv_calib3d.so.4.5")
JLLWrappers.@declare_library_product(libopencv_core, "libopencv_core.so.4.5")
JLLWrappers.@declare_library_product(libopencv_dnn, "libopencv_dnn.so.4.5")
JLLWrappers.@declare_library_product(libopencv_features2d, "libopencv_features2d.so.4.5")
JLLWrappers.@declare_library_product(libopencv_flann, "libopencv_flann.so.4.5")
JLLWrappers.@declare_library_product(libopencv_gapi, "libopencv_gapi.so.4.5")
JLLWrappers.@declare_library_product(libopencv_highgui, "libopencv_highgui.so.4.5")
JLLWrappers.@declare_library_product(libopencv_imgcodecs, "libopencv_imgcodecs.so.4.5")
JLLWrappers.@declare_library_product(libopencv_imgproc, "libopencv_imgproc.so.4.5")
JLLWrappers.@declare_library_product(libopencv_julia, "libopencv_julia.so")
JLLWrappers.@declare_library_product(libopencv_objdetect, "libopencv_objdetect.so.4.5")
JLLWrappers.@declare_library_product(libopencv_stitching, "libopencv_stitching.so.4.5")
JLLWrappers.@declare_library_product(libopencv_video, "libopencv_video.so.4.5")
JLLWrappers.@declare_library_product(libopencv_videoio, "libopencv_videoio.so.4.5")
function __init__()
    JLLWrappers.@generate_init_header(Qt5Base_jll, Libglvnd_jll, libcxxwrap_julia_jll)
    JLLWrappers.@init_library_product(
        libopencv_calib3d,
        "lib/libopencv_calib3d.so",
        RTLD_LAZY | RTLD_DEEPBIND,
    )

    JLLWrappers.@init_library_product(
        libopencv_core,
        "lib/libopencv_core.so",
        RTLD_LAZY | RTLD_DEEPBIND,
    )

    JLLWrappers.@init_library_product(
        libopencv_dnn,
        "lib/libopencv_dnn.so",
        RTLD_LAZY | RTLD_DEEPBIND,
    )

    JLLWrappers.@init_library_product(
        libopencv_features2d,
        "lib/libopencv_features2d.so",
        RTLD_LAZY | RTLD_DEEPBIND,
    )

    JLLWrappers.@init_library_product(
        libopencv_flann,
        "lib/libopencv_flann.so",
        RTLD_LAZY | RTLD_DEEPBIND,
    )

    JLLWrappers.@init_library_product(
        libopencv_gapi,
        "lib/libopencv_gapi.so",
        RTLD_LAZY | RTLD_DEEPBIND,
    )

    JLLWrappers.@init_library_product(
        libopencv_highgui,
        "lib/libopencv_highgui.so",
        RTLD_LAZY | RTLD_DEEPBIND,
    )

    JLLWrappers.@init_library_product(
        libopencv_imgcodecs,
        "lib/libopencv_imgcodecs.so",
        RTLD_LAZY | RTLD_DEEPBIND,
    )

    JLLWrappers.@init_library_product(
        libopencv_imgproc,
        "lib/libopencv_imgproc.so",
        RTLD_LAZY | RTLD_DEEPBIND,
    )

    JLLWrappers.@init_library_product(
        libopencv_julia,
        "lib/libopencv_julia.so",
        RTLD_LAZY | RTLD_DEEPBIND,
    )

    JLLWrappers.@init_library_product(
        libopencv_objdetect,
        "lib/libopencv_objdetect.so",
        RTLD_LAZY | RTLD_DEEPBIND,
    )

    JLLWrappers.@init_library_product(
        libopencv_stitching,
        "lib/libopencv_stitching.so",
        RTLD_LAZY | RTLD_DEEPBIND,
    )

    JLLWrappers.@init_library_product(
        libopencv_video,
        "lib/libopencv_video.so",
        RTLD_LAZY | RTLD_DEEPBIND,
    )

    JLLWrappers.@init_library_product(
        libopencv_videoio,
        "lib/libopencv_videoio.so",
        RTLD_LAZY | RTLD_DEEPBIND,
    )

    JLLWrappers.@generate_init_footer()
end  # __init__()


text:
#=
    These tests aim to minimally test each expected feature in MOI, in addition
    to the full end-to-end tests in contlinear.jl etc
=#

const unittests = Dict{String, Function}()

"""
    test_model_solution(model::MOI.ModelLike, config::TestConfig;
        objective_value   = nothing,
        variable_primal   = nothing,
        constraint_primal = nothing,
        constraint_dual   = nothing
    )

Solve, and then test, various aspects of a model.

First, check that `TerminationStatus == MOI.Success`.

If `objective_value` is not nothing, check that the attribute `ObjectiveValue()`
is approximately `objective_value`.

If `variable_primal` is not nothing, check that the attribute  `PrimalStatus` is
`MOI.FeasiblePoint`. Then for each `(index, value)` in `variable_primal`, check
that the primal value of the variable `index` is approximately `value`.

If `constraint_primal` is not nothing, check that the attribute  `PrimalStatus` is
`MOI.FeasiblePoint`. Then for each `(index, value)` in `constraint_primal`, check
that the primal value of the constraint `index` is approximately `value`.

Finally, if `config.duals = true`, and if `constraint_dual` is not nothing,
check that the attribute  `DualStatus` is `MOI.FeasiblePoint`. Then for each
`(index, value)` in `constraint_dual`, check that the dual of the constraint
`index` is approximately `value`.

### Example

    MOIU.loadfromstring!(model, \"\"\"
        variables: x
        minobjective: 2.0x + 1.0
        c: x >= 1.0
    \"\"\")
    x = MOI.get(model, MOI.VariableIndex, "x")
    c = MOI.get(model, MOI.ConstraintIndex{MOI.SingleVariable, MOI.GreaterThan{Float64}}, "c")
    test_model_solution(model, config;
        objective_value   = 3.0,
        variable_primal   = [(x, 1.0)],
        constraint_primal = [(c, 1.0)],
        constraint_dual   = [(c, 2.0)]
    )

"""
function test_model_solution(model, config;
        objective_value   = nothing,
        variable_primal   = nothing,
        constraint_primal = nothing,
        constraint_dual   = nothing
    )
    config.solve || return
    atol, rtol = config.atol, config.rtol
    MOI.optimize!(model)
    @test MOI.get(model, MOI.TerminationStatus()) == MOI.Success
    if objective_value != nothing
        @test MOI.get(model, MOI.ObjectiveValue()) ≈ objective_value atol=atol rtol=rtol
    end
    if variable_primal != nothing
        @test MOI.get(model, MOI.PrimalStatus()) == MOI.FeasiblePoint
        for (index, solution_value) in variable_primal
            @test MOI.get(model, MOI.VariablePrimal(), index) ≈ solution_value atol=atol rtol=rtol
        end
    end
    if constraint_primal != nothing
        @test MOI.get(model, MOI.PrimalStatus()) == MOI.FeasiblePoint
        for (index, solution_value) in constraint_primal
            @test MOI.get(model, MOI.ConstraintPrimal(), index) ≈ solution_value atol=atol rtol=rtol
        end
    end
    if config.duals
        if constraint_dual != nothing
            @test MOI.get(model, MOI.DualStatus()) == MOI.FeasiblePoint
            for (index, solution_value) in constraint_dual
                @test MOI.get(model, MOI.ConstraintDual(), index) ≈ solution_value atol=atol rtol=rtol
            end
        end
    end
end

include("variables.jl")
include("objectives.jl")
include("constraints.jl")
include("basic_constraint_tests.jl")
include("modifications.jl")
include("solve.jl")

@moitestset unit


text:
# Tests of intstats.jl

using MLBase
using Base.Test

# repeach

@test repeach(2:4, 2) == [2, 2, 3, 3, 4, 4]
@test repeach(2:4, 1:3) == [2, 3, 3, 4, 4, 4]

# repeachcol

a = rand(4, 3)

@test repeachcol(a, 2) == a[:, [1,1,2,2,3,3]]
@test repeachcol(a, 1:3) == a[:, [1,2,2,3,3,3]]

# repeachrow

a = rand(3, 4)
@test repeachrow(a, 2) == a[[1,1,2,2,3,3], :]
@test repeachrow(a, 1:3) == a[[1,2,2,3,3,3], :]

# counteq & countne

a = [1, 2, 3, 4, 5, 6, 7]
b = [1, 3, 3, 4, 6, 7, 8]

@test counteq(a, b) == 3
@test countne(a, b) == 4


text:
# Load j4pr
using j4pr
using DataStructures, DataArrays, LearnBase, MLKernels, MLLabelUtils, Distances, Images

if (VERSION > v"0.7-")
	using Test
end

# [core]
include("t_data_cells.jl");
include("t_interfaces.jl");
include("t_operators.jl");
include("t_pipe_creation.jl");
include("t_data_access_patterns.jl");
include("t_coreutils.jl");
Test.@testset "[j4pr: /src/core]" begin
	Test.@testset "Data cells: types, aliases" begin t_data_cells(); end
	Test.@testset "Interfaces: interation, types" begin t_interfaces(); end
	Test.@testset "Operators: piping, concatenation" begin t_operators(); end
	Test.@testset "Pipe creation: types and results" begin t_pipe_creation(); end
	Test.@testset "Data access patterns: geting/modifying observations/variables" begin t_data_access_patterns(); end
	Test.@testset "coreutils.jl (utility functions)" begin t_coreutils(); end
end

# [/lib]
include("t_libutils.jl")
Test.@testset "[j4pr: /src/lib]" begin
	Test.@testset "libutils.jl (utility functions for libraries)" begin t_libutils(); end
end

# [/lib/data]
include("t_libdata.jl")
Test.@testset "[j4pr: /src/lib/data]" begin
	Test.@testset "Data container processing functions (class slicing, filtering, encoding)" begin t_libdata(); end
end

# [/lib/ext]
### include("ext/t_kpca.jl")
### include("ext/t_fa.jl")
include("ext/t_dist.jl")
include("ext/t_pca.jl")
include("ext/t_whiten.jl")
include("ext/t_ppca.jl")
include("ext/t_ica.jl")
include("ext/t_mds.jl")
include("ext/t_lda.jl")
include("ext/t_lr.jl")
include("ext/t_kmeans.jl")
include("ext/t_kmedoids.jl")
include("ext/t_affinityprop.jl")
include("ext/t_decisiontree.jl")
include("ext/t_mlkernel.jl")
Test.@testset "[j4pr: /src/lib/ext]" begin
	### Test.@testset "kpca.jl (KPCA)" begin t_kpca(); end
	### Test.@testset "fa.jl (Factor analysis)" begin t_fa(); end
	Test.@testset "dist.jl (Distances)" begin t_dist(); end
	Test.@testset "whiten.jl (Whitening)" begin t_whiten(); end
	Test.@testset "pca.jl (PCA)" begin t_pca(); end
	Test.@testset "ppca.jl (PPCA)" begin t_ppca(); end
	Test.@testset "ica.jl (ICA)" begin t_ica(); end
	Test.@testset "mds.jl (MDS)" begin t_mds(); end
	Test.@testset "lda.jl (LDA)" begin t_lda(); end
	Test.@testset "lr.jl (Linear regression)" begin t_lr(); end
	Test.@testset "kmeans.jl (K-means clustering)" begin t_kmeans(); end
	Test.@testset "kmedoids.jl (K-medoids clustering)" begin t_kmedoids(); end
	Test.@testset "affinityprop.jl (Affinity propagation clustering)" begin t_affinityprop(); end
	Test.@testset "decisiontree.jl (DT/RF/stump regression/classification)" begin t_decisiontree(); end
	Test.@testset "mlkernel.jl (ML kernels)" begin t_mlkernel(); end
end

# [/lib/sup]
include("t_lindisc.jl")
include("t_quaddisc.jl")
include("t_parzen.jl")
include("t_loss.jl")
include("t_combiners.jl")
include("t_randomsubspace.jl")
include("t_adaboost.jl")
include("t_stump.jl")
include("t_networklearner.jl")
Test.@testset "[j4pr: /src/lib/sup]" begin
	Test.@testset "lindisc.jl (Linear discriminant classifier)" begin t_lindisc(); end
	Test.@testset "quaddisc.jl (Quadratic discriminant classifier)" begin t_quaddisc(); end
	Test.@testset "parzen.jl (Parzen density estimator/classifier)" begin t_parzen(); end
	Test.@testset "loss.jl (Loss functions)" begin t_loss(); end
	Test.@testset "combiners.jl (Label/output combiners)" begin t_combiners(); end
	Test.@testset "randomsubspace.jl (Random subspace ensemble)" begin t_randomsubspace(); end
	Test.@testset "adaboost.jl (AdaBoost ensemble)" begin t_adaboost(); end
	Test.@testset "stump.jl (Decision stump classifier and regressor)" begin t_stump(); end
	Test.@testset "networklearner.jl (Network Learning)" begin t_networklearner(); end
end

if v"0.6" <= VERSION < v"0.7-"
	include("ext/t_dbscan.jl")
	include("ext/t_libsvm.jl")
	Test.@testset "[j4pr: /src/lib/ext] (Julia 0.6 ONLY)" begin
		Test.@testset "dbscan.jl (DBSCAN clustering)" begin t_dbscan(); end
		Test.@testset "libsvm.jl (LIBSVM classifier/regressor)" begin t_libsvm(); end
	end

	include("t_knn.jl")
	include("t_roc.jl")
	Test.@testset "[j4pr: /src/lib/sup] (Julia 0.6 ONLY)" begin
		Test.@testset "knn.jl (knn regression/classification)" begin t_knn(); end
		Test.@testset "roc.jl (ROC curves and operating points)" begin t_roc(); end
	end
end

# [/lib/unsup]
include("t_kernel.jl")
Test.@testset "[j4pr: /src/lib/unsup]" begin
	Test.@testset "kernel.jl (kernels)" begin t_kernel(); end
end

# [/exp]
include("exp/t_plotting.jl")
Test.@testset "[j4pr: /src/exp]" begin
	Test.@testset "plotting.jl" begin t_plotting(); end
end


text:
# bijectivity check
using Test
include("nice.jl")

@testset "nice" begin
    num_vars = 4
    model = random_nice_network(num_vars, 10, 3)
    z = randn(num_vars)
    x, _ = nice_network!(z, model)
    z_infer, _ = (~nice_network!)(x, model)
    @test z_infer ≈ z
    newparams = randn(nparameters(model))
    dispatch_params!(model, newparams)
    @test collect_params(model) ≈ newparams
    @test check_inv(logp!, (0.0, x, model))
end

@testset "nice logp" begin
    z1 = [0.5, 0.2]
    z2 = [-0.5, 1.2]
    model = random_nice_network(2, 10, 4)
    x1 = nice_network!(copy(z1), model)[1]
    x2 = nice_network!(copy(z2), model)[1]
    p1 = logp!(0.0, copy(x1), model)[1]
    p2 = logp!(0.0, copy(x2), model)[1]
    pz1 = exp(-sum(abs2, z1)/2)
    pz2 = exp(-sum(abs2, z2)/2)
    @test exp(p1 - p2) ≈ pz1/pz2
    @test nice_nll!(0.0, 0.0, hcat(x1, x2), model)[1] ≈ -log(pz1 * pz2)/2

    xs = hcat(x1, x2)
    gmodel = Grad(nice_nll!)(Val(1), 0.0, 0.0, copy(xs), model)[end]

    for i=1:10, j=1:4
        model[j].W2[i] -= 1e-4
        a = nice_nll!(0.0, 0.0, copy(xs), model)[1]
        model[j].W2[i] += 2e-4
        b = nice_nll!(0.0, 0.0, copy(xs), model)[1]
        model[j].W2[i] -= 1e-4
        ng = (b-a)/2e-4
        @test gmodel[j].W2[i].g ≈ ng
    end

    for i=1:10, j=1:4
        model[j].W1[i] -= 1e-4
        a = nice_nll!(0.0, 0.0, copy(xs), model)[1]
        model[j].W1[i] += 2e-4
        b = nice_nll!(0.0, 0.0, copy(xs), model)[1]
        model[j].W1[i] -= 1e-4
        ng = (b-a)/2e-4
        @test gmodel[j].W1[i].g ≈ ng
    end
end


text:
#!/usr/bin/env julia

#=
  Reads csv files and concatenates.
  Ex.:
      ./join_csv.jl *.csv output.csv
=#

function main(args)

    csv_data::Array{String} = []
    output_csv::String = args[end]

    # Adds header.
    open(args[1], "r") do f
        lines::Array{String} = readlines(f)
    line_counter::Int = 0
        for line::String in lines
            line_counter += 1
            if line_counter == 1
                        push!(csv_data, line * "\n")
                break
            end

        end
    end

    # reads files and adds lines to csv_data
    for file::String in args[1:end-1]
        # Reads file one by one.
        open(file, "r") do f
            # File parsing and converting to csv.
            lines::Array{String} = readlines(f)
            line_counter::Int = 0

            for line::String in lines
                line_counter += 1

                if line_counter == 1
                    if line * "\n" != csv_data[1]
                        println("Header of input csv files does not match!")
                        exit(1)
                    end
                end

                if line_counter != 1
                    push!(csv_data, line * "\n")
                end
            end
        end
    end

    # Write csv data to a file.
    csv_data_all::String = join(csv_data)
    csv_data_all = replace(csv_data_all, "\t", ",")
    open(output_csv, "w") do f
        write(f, csv_data_all)
    end
end

main(ARGS)

max_stars_repo_name: KarolisM/rnd-it-molbio-fidelity-umi

max_issues_repo_name: KarolisM/rnd-it-molbio-fidelity-umi

max_forks_repo_name: KarolisM/rnd-it-molbio-fidelity-umi


text:
using FullyThreadedTree
using Test

@testset "FullyThreadedTree.jl" begin
    # Verify that the cell_volume corresponding to all the cells cover the
    # domain exactly once
    function total_volume_via_cells(tree)
        vol = 0.0
        for cell ∈ cells(tree, filter = active)
            vol += volume(cell)
        end
        return vol
    end

    function total_firstMoment_via_cells(tree::Tree{N}) where N
        moment = zeros(N)
        for cell ∈ cells(tree, filter = active)
            moment += centroid(cell) * volume(cell)
        end
        return moment
    end

    # Verify that the cell_volume corresponding to all the faces cover the
    # domain exactly dim times (NB since boundary faces are inactive, we need
    # periodicity)
    function total_volume_via_faces(tree)
        vol = 0.0
        for face ∈ all_faces(tree, filter = active)
            vol += cell_volume(face)
        end
        return vol
    end

    for dim ∈ 1:3
        tree = Tree(rand(dim), periodic=ones(Bool, dim))
        @test total_volume_via_cells(tree) == 1.0
        @test total_firstMoment_via_cells(tree) ≈ tree.position
        @test total_volume_via_faces(tree) == dim

        refine!(tree)
        @test total_volume_via_cells(tree) == 1.0
        @test total_firstMoment_via_cells(tree) ≈ tree.position
        @test total_volume_via_faces(tree) == dim

        refine!(tree, recurse=true)
        @test total_volume_via_cells(tree) == 1.0
        @test total_firstMoment_via_cells(tree) ≈ tree.position
        @test total_volume_via_faces(tree) == dim

        refine!(tree.children[end].children[1])
        @test total_volume_via_cells(tree) == 1.0
        @test total_firstMoment_via_cells(tree) ≈ tree.position
        @test total_volume_via_faces(tree) == dim

        refine!(tree, recurse=true)
        @test total_volume_via_cells(tree) == 1.0
        @test total_firstMoment_via_cells(tree) ≈ tree.position
        @test total_volume_via_faces(tree) == dim
    end
end


text:
module MatrixTraits

end