text:
using LinearAlgebra
using Statistics
using Random

function coherence(X, ord=1, model=5, iter=200, ax=1)
	X = makebinary(X)

	if ord == 1
		X = allzeros(X)
		Y = ordinate(X, ax)
	end

	Abs = embedabs(Y)

	EAbs = zeros(Int, iter)
	for i = 1:iter
		null = randomnull(X, model)
		if ord == 1
			EX = allzeros(null)
			EY = ordinate(EX, ax)
		end
		EAbs[i] = embedabs(EY)
	end

	MA = mean(EAbs)
	SA = std(EAbs)

	# z-test
	return Abs, MA, SA
end

function turnover(X, ord=1, Comm=0, iter=200, ax=1)
	X = makebinary(X)

	if ord == 1
		X = allzeros(X)
		Y = ordinate(X, ax)
	end

	Y = boundfill(Y, Comm)
	Re = checkstat(Y)

	ERe = zeros(iter)
	for i = 1:iter
		null = replacenull(Y, Comm)
		ERe[i] = checkstat(null)
	end
	MR = mean(ERe)
	SR = std(ERe)

	return Re, MR, SR
end

function clumping(X, ord=1, Comm=0, ax=1)
	if Comm == 0
		X = transpose(X)
	end

	X = makebinary(X)

	if ord == 1
		X = allzeros(X)
		Y = ordinate(X)
	end

	r,c = size(Y)
	ComBnd = zeros(c,1)
	M = 0
	ComBndChi = 0

	for i = 1:r
		ind = findall(Y[i,:] .== 1)
		First = ind[1];
		Last = ind[length(ind)]
		for j = 1:c
			if First == j
				ComBnd[j] += 1
			end
			if Last == j
				ComBnd[j] += 1
			end
		end
	end

	TotComBnd = r * 2 - ComBnd[1] - ComBnd[c]
	ExpComBnd = TotComBnd / (c - 2)
	df = -1

	for i = 2:(c-1)
		M += ((ComBnd[i]/TotComBnd)*((ComBnd[i]-1)/(TotComBnd-1)))
		ComBndChi += ((ComBnd[i] - ExpComBnd)^2/ExpComBnd)
		df += 1
	end

	M *= c-2

	return M, ComBndChi, df
end

function replacenull(X, Comm)
	sites, species = size(X)
	null = zeros(Int, sites, species)
	if Comm == 0
		for i = 1:species
			ind = findall(X[:,i] .== 1)
			len = length(ind)
			rd = Int(ceil(rand()*(sites-len+1)))
			null[rd:(rd+len-1),i] .= 1
		end
	elseif Comm == 1
		for i = 1:sites
			ind = findall(X[i,:] .== 1)
			len = length(ind)
			rd = Int(ceil(rand()*(species-len+1)))
			null[i,rd:(rd+len-1)] .= 1
		end
	end
	return null
end

function checkstat(X)
	r,c = size(X)
	C = 0
	for i = 1:(c-1)
		Xi = X[:,i]
		R1 = sum(Xi)
		for j = (i+1):c
			Xj = X[:,j]
			S = sum(Xi.&Xj)
			R2 = sum(Xj)
			C += (R1-S) * (R2-S)
		end
	end
	return C
end

function boundfill(X, Comm)
	sites, species = size(X)
	Y = copy(X)
	if Comm == 0
		for i = 1:species
			ind = findall(X[:,i] .== 1)
			First = ind[1]
			Last = ind[length(ind)]
			Y[First:Last,i] .= 1
		end
	elseif Comm == 1
		for i = 1:sites
			ind = findall(X[i,:] .== 1)
			First = ind[1]
			Last = ind[length(ind)]
			Y[i,First:Last] .= 1
		end
	end
	return Y
end

function makebinary(X)
	Y = Int.(X .> 0)
	return Y
end

function allzeros(X, rc=3)
	Y = X
	if rc == 3 || rc == 1
		Rsum = sum(X, dims=2)
		Rind = findall(Rsum[:] .> 0)
		Y = X[Rind,:]
	end
	if rc == 3 || rc == 2
		Csum = sum(X, dims=1)
		Cind = findall(Csum[:] .> 0)
		Y = Y[:,Cind]
	end
	return Y
end

function ordinate(X, ax=1)
	V, W = ca(X)
	ir = sortperm(V[ax+1,:])
	ic = sortperm(W[ax+1,:])
	Y = X[ir,ic]
	Y = Y[size(Y,1):-1:1,:]
	return Y
end

function ca(X)
	r = sum(X, dims=2)
	c = sum(X, dims=1)
	N = sum(r)
	R = diagm(0 => r[:])
	C = diagm(0 => c[:])

	Risq = sqrt(inv(R))
	Cisq = sqrt(inv(C))

	M = Risq * X * Cisq
	Mt = transpose(M)
	P = M * Mt
	Q = Mt * M

	vals, vecs = eig(P)
	UP = transpose(vecs)
	vals, vecs = eig(Q)
	UQ = transpose(vecs)

	V = sqrt(N) * UP * Risq
	W = sqrt(N) * UQ * Cisq

	return V, W
end

function eig(X, n=size(X,1))
	vals, vecs = eigen(X)

	if !isreal(vals)
		mask = isreal.(vals)
		image_ = abs.(.!mask .* vals)
		real_ = mask .* vals
		vals = Float64.(real_ + image_)
	end
	if !isreal(vecs)
		mask = isreal.(vecs)
		image_ = abs.(.!mask .* vecs)
		real_ = mask .* vecs
		vecs = Float64.(real_ + image_)
	end

	ind = sortperm(-vals)
	vals = vals[ind]
	vecs = vecs[:,ind]

	for j = 1:size(vecs, 2)
		if sum(vecs[:,j]) < 0
			vecs[:,j] = -vecs[:,j];
		end
	end

	return vals[1:n], vecs[:,1:n]
end

function embedabs(X)
	sites, species = size(X)
	FirstSpecies, LastSpecies, FirstSite, LastSite = boundfind(X)
	Abs = 0
	for i = 1:sites
		for j = 1:species
			if X[i,j] == 0
				flag = 0
				if j > FirstSpecies[i] && j < LastSpecies[i]
					Abs += 1
					flag = 1
				end
				if flag == 0 && i > FirstSite[j] && i < LastSite[j]
					Abs += 1
				end
			end
		end
	end
	return Abs
end

function boundfind(X)
	r,c = size(X)
	FirstSpecies = zeros(r,1)
    LastSpecies = zeros(r,1)
    FirstSite = zeros(1,c)
	LastSite = zeros(1,c)
	for i = 1:r
        ind = findall(X[i,:] .== 1)
        FirstSpecies[i] = ind[1];
        LastSpecies[i] = ind[length(ind)];
	end
	for i = 1:c
        ind = findall(X[:,i] .== 1);
        FirstSite[i] = ind[1];
        LastSite[i] = ind[length(ind)];
	end
	return FirstSpecies, LastSpecies, FirstSite, LastSite
end

# only binary mode is implemented
function randomnull(X, model=1)
	r,c = size(X)

	Richness = sum(X, dims=2)
	Incidence = sum(X, dims=1)
	N = sum(Richness)

    FixRichness = ones(r,1)
    EqRichness = ones(r,1) * (1/r)
    PropRichness = Richness / N
    FixIncidence = ones(1,c)
    EqIncidence = ones(1,c) * (1/c)
	PropIncidence = Incidence / N

	null = zeros(r,c)
	if model == 1
		P = EqRichness * EqIncidence
		null = assignsp(P, N)
	elseif model == 2
		P = EqRichness * FixIncidence
		for i = 1:c
			Pi = reshape(P[:,i], (:,1))
			null[:,i] = assignsp(Pi, Incidence[i])
		end
	elseif model == 3
		P = FixRichness * EqIncidence
		for i = 1:r
			Pi = reshape(P[i,:], (1,:))
			null[i,:] = assignsp(Pi, Richness[i])
		end;
	elseif model == 4
		P = PropRichness * FixIncidence
		for i = 1:c
			Pi = reshape(P[:,i], (:,1))
			null[:,i] = assignsp(Pi, Incidence[i])
		end;
	elseif model == 5
		P = FixRichness * PropIncidence
		for i = 1:r
			Pi = reshape(P[i,:], (1,:))
			null[i,:] = assignsp(Pi, Richness[i])
		end
	elseif model == 6
		P = PropRichness * EqIncidence
        null = assignsp(P, N)
	elseif model == 7
		P = EqRichness * PropIncidence
		null = assignsp(P, N)
	elseif model == 8
		P = PropRichness * PropIncidence
		null = assignsp(P, N)
	elseif model == 9
		null = swap(X)
	elseif model == 10
		null = randnest(X)
	end

	return null
end

# not functionally idential to Swap.m, but similar and quicker
function swap(X)
	r,c = size(X)
	ir = randperm(r)
	return X[ir,:]
end

function randnest(X)
	r,c = size(X)
	Incidence = sum(X, dims=1)
	SpecFreq = Incidence / r
	null = ones(r, c)
	mask = rand(r, c) .< repeat(SpecFreq, 5)
	return mask .* null
end

function assignsp(P, N, con=1)
	r,c = size(P)
	null = zeros(r,c)
	X = P[:]

	X = X / sum(X)
	C = cumsum(X)

	while true
		for i = 1:N
			while true
				ind = findall(C .>= rand())
				if null[ind[1]] != 1
					null[ind[1]] = 1
					break
				end
			end
		end
		if con == 1
			break
		end
	end

	return null
end

max_stars_repo_name: Augustpan/fastEMS

max_issues_repo_name: Augustpan/fastEMS

max_forks_repo_name: Augustpan/fastEMS


text:
# struct LogitGating{T<:Array{Union{Nothing, Number}}} <: NonRandomGating
#     α::T
#     LogitGating{T}(α::T) where {T<:Array{Union{Nothing, Number}}} = new{T}(α::T)
# end

# function LogitGating(α::T; check_args=true) where {T <: Array{Union{Nothing, Number}}}
#     check_args # && @check_args(LogitGating, isa.(α, Number))
#     return LogitGating{T}(α)
# end

#### Outer constructors
# LogitGating(α::Array{Union{Nothing, Real}}) = LogitGating(promote(α)...)
# LogitGating(α::Array{Union{Nothing, Integer}}) = LogitGating(float(α))

# SHOULD BE ARRAY TYPE

function LogitGating(α, x; check_args = true)
    check_args && @check_args(LogitGating, size(α)[2] == size(x)[2])
    ax = x * α'
    rowsum = rowlogsumexp(ax) # logsumexp.(ax[row,:] for row in 1:size(ax)[1])
    return ax .- rowsum
    # return (x * α') .- logsumexp.((x * α')[row,:] for row in 1:size((x * α'))[1])
end

ext: jl

max_stars_repo_name: sparktseung/JuliaLRMoE

max_issues_repo_name: sparktseung/JuliaLRMoE

max_forks_repo_name: sparktseung/JuliaLRMoE


text:
using Cairo
using Colors
using Graphics

ctx = CairoContext(CairoRGBSurface(100, 100))

save(ctx)
rectangle(ctx, 0, 0, 100, 100)
set_source(ctx, parse(Colorant, "white"))
fill(ctx)
restore(ctx)

set_coords(ctx, 0, 0, 100, 100, -0.125, 1.125, 1.125, -0.125)
set_line_width(ctx, 5)

set_source(ctx, parse(Colorant, "red"))
move_to(ctx, 0, 0)
line_to(ctx, 1, 0)
line_to(ctx, 1, 1)
stroke(ctx)

set_source(ctx, parse(Colorant, "orange"))
move_to(ctx, 1, 1)
line_to(ctx, 0, 1)
line_to(ctx, 0, 0)
stroke(ctx)

write_to_png(ctx.surface, "bar.png")


text:
module SSIT

using JuMP
using ...JOH
using ...JOH.Matheur
using Dates

export SSIT_method, make_SSIT_method

""" container for SSIT formulations """
struct SSIT_method <: JOH.Matheur.Matheuristic
    tolerances::Vector{Number}
    times::Vector{Number}
    name::String
    num_threads::Int
	executor
end

function make_SSIT_method(tolerances, times,
		name, num_threads)
	SSIT_method(tolerances, times, name, num_threads, run_SSIT)
end

function save_log(solution, current_model, method, phase_index, id)
	p = mkpath("error_log/$(id)_$(phase_index)")
	open("$p/solution.dat", "w") do f
		print(f, value.(solution))
	end
	write_to_file(current_model, "$p/current_model.lp")
	open("$p/method.dat", "w") do f
		print(f, method)
	end
end

"""
Accept an MDMKP problem, an optional initial solution and associated generation
time, and an array of tolerances and a matched array of time limits. Run the
SSIT method on the problem, and record the results thereof.
"""
function run_SSIT(m::JuMP.Model, method::SSIT_method; id=1,
		error_handler=save_log)
	Matheur.set_threads!(m, method.num_threads)

	results_DF = Matheur.Model_DF()

	for i in 1:length(method.tolerances)
		Matheur.set_tolerance!(m, method.tolerances[i])
		time_limit = method.times[i]
		Matheur.set_time!(m, time_limit)

		elapsed_time = Matheur.silent_optimize!(m)

		row = Matheur.get_DF_row(m, elapsed_time=elapsed_time, index=i)
		push!(results_DF, row)

		if termination_status(m) == MOI.OPTIMAL || termination_status(m) ==
				MOI.INFEASIBLE
			break
		end
	end

	results_DF
end

end

max_stars_repo_name: Dibillilia/JuliaOptHeuristics

max_issues_repo_name: Dibillilia/JuliaOptHeuristics

max_forks_repo_name: Dibillilia/JuliaOptHeuristics


text:
using DiffEqBase, OrdinaryDiffEq, StochasticDiffEq, Sundials
using Plots; plotly()

############ Spatial Parameters

const x_start = -100
const x_end   = 400
const y_start = 0
const y_end   = 100
const dx = 5
const dy = 5
const N = Int((x_end-x_start) / dx + 1)
const M = Int((y_end-y_start) / dy +1)
const X = repmat(collect(x_start:dx:x_end)',M,1)
const Y = repmat(collect(y_start:dy:y_end),1,N)

############ RA Parameters

const DRA = 250.46
const β = 1
const kA = 0.002
const kdeg = 50
const kmax = 1
const n = 2
const xf = 400

const kp = 0.1
const gamma = 100
const mon = 3.0
const moff = 0.0013
const rdeg1 = 0.0001
const rdeg2 = 0.0001
const jalpha = 50.0
const jbeta = .10
const bpdeg1 = 0.0001
const d = 1
const e = 1
const Vbp = 1e-3
const Vr = 2e-2
const ϵout = 0.1
const ϵin = 0.1
const ϵR = 0.1

############ Setup Diffusion Matrices
const Ax = Tridiagonal([1.0 for i in 1:N-1],[-2.0 for i in 1:N],[1.0 for i in 1:N-1])
const Ay = Tridiagonal([1.0 for i in 1:M-1],[-2.0 for i in 1:M],[1.0 for i in 1:M-1])
Ax[2,1] = 2
Ax[end-1,end] = 2
Ay[1,2] = 2
Ay[end,end-1] = 2

Ax ./= dx^2
Ay ./= dy^2

############# Spatial Constants

const Vmax = 20.0
V(x) = ifelse(x>xf-40,Vmax,zero(typeof(Vmax)))
const VRA = V.(X)
no_cyp(x) = ifelse(x<0 || (xf-40<x && x<=xf),true,false)
const NCYP_kmax = no_cyp.(X)

u0 = zeros(M,N,6)

const Ax_cache = zeros(M,N)
const Ay_cache = zeros(M,N)
const diffRA = zeros(M,N)

function ra_gradient(du,u,p,t)
  RAout = @view u[:,:,1]
  RAin = @view u[:,:,2]
  R = @view u[:,:,3]
  RAR = @view u[:,:,4]
  BP = @view u[:,:,5]
  RABP = @view u[:,:,6]
  dRAout = @view du[:,:,1]
  dRAin = @view du[:,:,2]
  dR = @view du[:,:,3]
  dRAR = @view du[:,:,4]
  dBP = @view du[:,:,5]
  dRABP = @view du[:,:,6]

  A_mul_B!(Ax_cache,RAout,Ax)
  A_mul_B!(Ay_cache,Ay,RAout)

  Threads.@threads for i in eachindex(RAin)
    @inbounds diffRA[i] = DRA*(Ax_cache[i] + Ay_cache[i])
    @inbounds dRAout[i]  = VRA[i] - β*RAout[i] + kp*RAin[i] + diffRA[i]
    @inbounds dRAin[i] = β*RAout[i] - kp*RAin[i] - kdeg*(RAR[i]/(gamma+RAR[i]))*RAin[i] - mon*RAin[i].*BP[i] + moff*RABP[i] - rdeg1*RAin[i]
    @inbounds dR[i]    = Vr - rdeg2*R[i]- jalpha*RABP[i].*R[i] + jbeta*BP[i].*RAR[i]
    @inbounds dRAR[i]    = jalpha*RABP[i].*R[i] - jbeta*BP[i].*RAR[i]
    @inbounds dBP[i]     = Vbp - bpdeg1*BP[i] - mon*RAin[i].*BP[i] + moff*RABP[i] + jalpha*RABP[i].*R[i] - jbeta*BP[i].*RAR[i] + ((d.*RAR[i])./(e+RAR[i]))
    @inbounds dRABP[i]   = mon*RAin[i]*BP[i] - moff*RABP[i] - jalpha*RABP[i]*R[i] + jbeta*BP[i]*RAR[i]
  end
  nothing
end

################ Add Stochasticity

println("Solve the gradient SDE")
function ra_noise(du,u,p,t)
  RAout = @view u[:,:,1]
  RAin = @view u[:,:,2]
  RAR = @view u[:,:,4]
  dRAout = @view du[:,:,1]
  dRAin = @view du[:,:,2]
  dRAR = @view du[:,:,4]

  dRAout .= ϵout .* RAout
  dRAin  .= ϵin  .* RAin
  dRAR  .= ϵR  .* RAR
  nothing
end

u0 = zeros(M,N,6)
tspan2 = (0.0,500.0)
prob = SDEProblem(ra_gradient,ra_noise,u0,tspan2)

println("Solve with SOSRI")
@time noisy_ra_sol = solve(prob,SOSRI(),
                           save_everystep=false,progress_steps=10_000,
                           progress=true,abstol=1e-1,reltol=1e-2)

@time noisy_ra_sol = solve(prob,SRIW1(),
                           save_everystep=false,progress_steps=10_000,
                           progress=true,abstol=1e-5,reltol=1e-3)

@time noisy_ra_sol = solve(prob,SOSRI2(),
                           save_everystep=false,progress_steps=10_000,
                           progress=true,abstol=1e-3,reltol=1e-3)

println("Solve with EM")
# dt = 1/10000 fails
for i in 1:10
    @time noisy_ra_sol = solve(prob,EM(),dt=1/20000,
                              save_everystep=false,progress_steps=10_000,
                              progress=true)
end

# Instead try to estimate the total time

tspan3 = (0.0,1/100)
prob2 = SDEProblem(ra_gradient,ra_noise,u0,tspan3)

# LOL No.

@time noisy_ra_sol = solve(prob2,ImplicitEM(),dt=1/80000,
                          save_everystep=false,progress_steps=1,
                          progress=true)

@time noisy_ra_sol = solve(prob2,ImplicitRKMil(),dt=1/80000,
                        save_everystep=false,progress_steps=1,
                        progress=true)

################ Solve ODE

println("Solve the ODE")
tspan = (0.0,500.0)
prob_ode = ODEProblem(ra_gradient,u0,tspan)
@time ra_sol = solve(prob_ode,CVODE_BDF(linear_solver = :GMRES),save_everystep=false,
                     abstol=1e-7,reltol=1e-4)

du = zeros(N,M,6)
ra_gradient(0.0,ra_sol[end],du)
maximum(du)


text:
using mitamp
using Test

@testset "mitamp.jl" begin
    # Write your tests here.
end


text:
module RandomStuff

import Random

Random.rand(::Type{String}, length::Int = 8) = Random.randstring(length)

Random.rand(::Type{Symbol}, length::Int = 8) = Symbol(rand(String, length))

Random.rand(::Type{Pair{T,R}}) where {T,R} = Pair(rand(T), rand(R))

Random.rand(::Type{Dict{T,R}}) where {T,R} = Dict(rand(T) => rand(R))

end # module


text:
import FlowFarm; const ff = FlowFarm
using DelimitedFiles

# set initial turbine x and y locations
turbine_x = [-3.0, 0.0, 3.0, 0.0, 0.0, -1.5, 0.0, 1.5, 0.0].*80.0
turbine_y = [0.0, 3.0, 0.0, -3.0, 0.0, 0.0, 1.5, 0.0, -1.5].*80.0

# calculate the number of turbines
nturbines = length(turbine_x)

# set turbine base heights
turbine_z = zeros(nturbines)

# set turbine yaw values
turbine_yaw = zeros(nturbines)

# set turbine design parameters
rotor_diameter = zeros(nturbines) .+ 80.0 # m
hub_height = zeros(nturbines) .+ 70.0   # m
cut_in_speed = zeros(nturbines) .+4.  # m/s
cut_out_speed = zeros(nturbines) .+25.  # m/s
rated_speed = zeros(nturbines) .+16.  # m/s
rated_power = zeros(nturbines) .+2.0E6  # W
generator_efficiency = zeros(nturbines) .+0.944

# rotor swept area sample points (normalized by rotor radius)
rotor_points_y = [0.0]
rotor_points_z = [0.0]

# set flow parameters
wind_speed = 8.0
air_density = 1.1716  # kg/m^3
ambient_ti = 0.077
shearexponent = 0.15
winddirections = [275.0*pi/180.0, 0.0, pi]
windspeeds = [wind_speed, wind_speed, wind_speed]
windprobabilities = [1.0/3.0,1.0/3.0,1.0/3.0]
ambient_tis = [ambient_ti, ambient_ti, ambient_ti]
measurementheight = [hub_height[1], hub_height[1], hub_height[1]]

# load power curve
powerdata = readdlm("inputfiles/niayifar_vestas_v80_power_curve_observed.txt",  ',', skipstart=1)
pvelpoints = powerdata[:,1]
powerpoints = powerdata[:,2]*1E6

# initialize power model
power_model = ff.PowerModelPowerPoints(pvelpoints, powerpoints)
power_models = Vector{typeof(power_model)}(undef, nturbines)
for i = 1:nturbines
    power_models[i] = power_model
end

# load thrust curve
ctdata = readdlm("inputfiles/predicted_ct_vestas_v80_niayifar2016.txt",  ',', skipstart=1)
ctvelpoints = ctdata[:,1]
ctpoints = ctdata[:,2]

# initialize thrust model
ct_model = ff.ThrustModelCtPoints(ctvelpoints, ctpoints)
ct_models = Vector{typeof(ct_model)}(undef, nturbines)
for i = 1:nturbines
    ct_models[i] = ct_model
end

# initialize wind shear model
wind_shear_model = ff.PowerLawWindShear(shearexponent)

# get sorted indecies
sorted_turbine_index = sortperm(turbine_x)

# initialize the wind resource definition
windresource = ff.DiscretizedWindResource(winddirections, windspeeds, windprobabilities, measurementheight, air_density, ambient_tis, wind_shear_model)

# set up wake and related models
wakedeficitmodel = ff.GaussYaw()
wakedeflectionmodel = ff.GaussYawDeflection()
wakecombinationmodel = ff.LinearLocalVelocitySuperposition()
localtimodel = ff.LocalTIModelNoLocalTI()

# initialize model set
model_set = ff.WindFarmModelSet(wakedeficitmodel, wakedeflectionmodel, wakecombinationmodel, localtimodel)


text:
# PolyChord Specific Settings
struct PolyChord
    loglike::Function
    prior::Function
    ndims::Cint
    nderived::Cint
    num_repeats::Cint
    do_clustering::Bool
    precision_crit::Cdouble
    base_dir::String
    file_root::String
    write_resume::Bool
    read_resume::Bool
    write_live::Bool
    write_dead::Bool
    write_stats::Bool
    equals::Bool
    posteriors::Bool
    cluster_posteriors::Bool
    update_files::Cint
    boost_posterior::Cdouble
end

function PolyChord(loglike::Function, nparams::Int, name::String;
                   prior::Function = identity,
                   multimodal::Bool = true,
                   nderived::Int = 0,
                   update_every::Int = 1000,
                   write_output_files::Bool = true,
                   work_dir::String = ".")

end

function polychord_loglike(cube_::Ptr{Cdouble}, ndims::Cint,
                           pars_::Ptr{Cdouble}, nderived::Cint)
    cube = unsafe_wrap(Array, cube_, ndims)
    return lnew
end

function run(S::PolyChord; nlive::Int=25*S.ndims, ztol=0.1, resume=true, verbosity=0)

    loglike = cfunction(multinest_loglike, Cdouble, (Ptr{Cdouble}, Cint, Ptr{Cdouble}, Cint))

    root_dir = dirname(S.root)
    println(root_dir)
    isdir(root_dir) || mkdir(root_dir)

    ccall(multinest_ptr, Void, ( Ref{Cint}, Ref{Cint}, Ref{Cint},
          Ref{Cint}, Ref{Cdouble}, Ref{Cdouble}, Ref{Cint}, Ref{Cint},
          Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cdouble}, Ptr{UInt8},
          Ref{Cint}, Ptr{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint},
          Ref{Cdouble}, Ref{Cint}, Ptr{Void}, Ptr{Void}, Any ),
          S.ins, S.mmodal, S.ceff, nlive, ztol, S.efr,
          S.ndims, S.npar, S.nclspar, S.maxmodes, S.updint, S.mode_ztol,
          S.root, S.seed, S.pwrap, verbosity, resume, S.outfile, S.initmpi,
          S.logzero, S.maxiter, loglike, dumper, S)
end


text:
### A Pluto.jl notebook ###
# v0.15.1

using Markdown
using InteractiveUtils

# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
    quote
        local el = $(esc(element))
        global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : missing
        el
    end
end

# ╔═╡ 92e150f0-f5f3-11eb-33a3-c39993e395ef
using NeXLCore

# ╔═╡ 489dd119-d9e6-46cd-ac3d-5e1d6b3c0bb5
using Gadfly, PlutoUI  # Load plotting and UI libraries

# ╔═╡ b2e92442-ada2-457c-bbb5-b824fcfbfdcf
md"
## Mass Absorption Coefficients

This notebook generates an interactive plot of X-ray mass absorption coefficients.
"

# ╔═╡ 10444fa1-c990-41e3-b742-52e709de6f6b
md"
Select an element using the slider.
"

# ╔═╡ f0c903b0-1485-49fa-9e08-27189b405d63
@bind zz Slider(1:92)

# ╔═╡ 77ec16f4-c285-4136-9e7b-376b1f68c74a
plot(NeXLCore.FFASTDB, elements[zz])

# ╔═╡ 00000000-0000-0000-0000-000000000001
PLUTO_PROJECT_TOML_CONTENTS = """
[deps]
Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004"
NeXLCore = "93a0284f-3680-435e-8d39-dd6e52a1dbc8"
PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8"

[compat]
Gadfly = "~1.3.3"
NeXLCore = "~0.2.6"
PlutoUI = "~0.7.9"
"""

# ╔═╡ 00000000-0000-0000-0000-000000000002
PLUTO_MANIFEST_TOML_CONTENTS = """
# This file is machine-generated - editing it directly is not advised

[[AbstractFFTs]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "485ee0867925449198280d4af84bdb46a2a404d0"
uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c"
version = "1.0.1"

[[Adapt]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "84918055d15b3114ede17ac6a7182f68870c16f7"
uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
version = "3.3.1"

[[ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"

[[Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"

[[AxisAlgorithms]]
deps = ["LinearAlgebra", "Random", "SparseArrays", "WoodburyMatrices"]
git-tree-sha1 = "a4d07a1c313392a77042855df46c5f534076fab9"
uuid = "13072b0f-2c55-5437-9ae7-d433b7a33950"
version = "1.0.0"

[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[BoteSalvatICX]]
deps = ["Requires"]
git-tree-sha1 = "c8da8dc6ca8566e210dfb1ed7f07e70ccd61d871"
uuid = "fe54227b-96c7-489b-9963-dd1ce2905f30"
version = "2.0.0"

[[CSV]]
deps = ["Dates", "Mmap", "Parsers", "PooledArrays", "SentinelArrays", "Tables", "Unicode"]
git-tree-sha1 = "b83aa3f513be680454437a0eee21001607e5d983"
uuid = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
version = "0.8.5"

[[Calculus]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "f641eb0a4f00c343bbc32346e1217b86f3ce9dad"
uuid = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9"
version = "0.5.1"

[[CategoricalArrays]]
deps = ["DataAPI", "Future", "JSON", "Missings", "Printf", "RecipesBase", "Statistics", "StructTypes", "Unicode"]
git-tree-sha1 = "1562002780515d2573a4fb0c3715e4e57481075e"
uuid = "324d7699-5711-5eae-9e2f-1d82baa6b597"
version = "0.10.0"

[[ChainRulesCore]]
deps = ["Compat", "LinearAlgebra", "SparseArrays"]
git-tree-sha1 = "bdc0937269321858ab2a4f288486cb258b9a0af7"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "1.3.0"

[[ColorTypes]]
deps = ["FixedPointNumbers", "Random"]
git-tree-sha1 = "024fe24d83e4a5bf5fc80501a314ce0d1aa35597"
uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
version = "0.11.0"

[[Colors]]
deps = ["ColorTypes", "FixedPointNumbers", "Reexport"]
git-tree-sha1 = "417b0ed7b8b838aa6ca0a87aadf1bb9eb111ce40"
uuid = "5ae59095-9a9b-59fe-a467-6f913c188581"
version = "0.12.8"

[[CommonSolve]]
git-tree-sha1 = "68a0743f578349ada8bc911a5cbd5a2ef6ed6d1f"
uuid = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2"
version = "0.2.0"

[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "344f143fa0ec67e47917848795ab19c6a455f32c"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "3.32.0"

[[CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"

[[Compose]]
deps = ["Base64", "Colors", "DataStructures", "Dates", "IterTools", "JSON", "LinearAlgebra", "Measures", "Printf", "Random", "Requires", "Statistics", "UUIDs"]
git-tree-sha1 = "c6461fc7c35a4bb8d00905df7adafcff1fe3a6bc"
uuid = "a81c6b42-2e10-5240-aca2-a61377ecd94b"
version = "0.9.2"

[[ConstructionBase]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "f74e9d5388b8620b4cee35d4c5a618dd4dc547f4"
uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
version = "1.3.0"

[[Contour]]
deps = ["StaticArrays"]
git-tree-sha1 = "9f02045d934dc030edad45944ea80dbd1f0ebea7"
uuid = "d38c429a-6771-53c6-b99e-75d170b6e991"
version = "0.5.7"

[[CoordinateTransformations]]
deps = ["LinearAlgebra", "StaticArrays"]
git-tree-sha1 = "6d1c23e740a586955645500bbec662476204a52c"
uuid = "150eb455-5306-5404-9cee-2592286d6298"
version = "0.6.1"

[[CoupledFields]]
deps = ["LinearAlgebra", "Statistics", "StatsBase"]
git-tree-sha1 = "6c9671364c68c1158ac2524ac881536195b7e7bc"
uuid = "7ad07ef1-bdf2-5661-9d2b-286fd4296dac"
version = "0.2.0"

[[Crayons]]
git-tree-sha1 = "3f71217b538d7aaee0b69ab47d9b7724ca8afa0d"
uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
version = "4.0.4"

[[DataAPI]]
git-tree-sha1 = "ee400abb2298bd13bfc3df1c412ed228061a2385"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.7.0"

[[DataFrames]]
deps = ["Compat", "DataAPI", "Future", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrettyTables", "Printf", "REPL", "Reexport", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"]
git-tree-sha1 = "d785f42445b63fc86caa08bb9a9351008be9b765"
uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
version = "1.2.2"

[[DataStructures]]
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
git-tree-sha1 = "4437b64df1e0adccc3e5d1adbc3ac741095e4677"
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
version = "0.18.9"

[[DataValueInterfaces]]
git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464"
version = "1.0.0"

[[Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[DelimitedFiles]]
deps = ["Mmap"]
uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"

[[Dierckx]]
deps = ["Dierckx_jll"]
git-tree-sha1 = "5fefbe52e9a6e55b8f87cb89352d469bd3a3a090"
uuid = "39dd38d3-220a-591b-8e3c-4c3a8c710a94"
version = "0.5.1"

[[Dierckx_jll]]
deps = ["CompilerSupportLibraries_jll", "Libdl", "Pkg"]
git-tree-sha1 = "a580560f526f6fc6973e8bad2b036514a4e3b013"
uuid = "cd4c43a9-7502-52ba-aa6d-59fb2a88580b"
version = "0.0.1+0"

[[Distances]]
deps = ["LinearAlgebra", "Statistics", "StatsAPI"]
git-tree-sha1 = "abe4ad222b26af3337262b8afb28fab8d215e9f8"
uuid = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
version = "0.10.3"

[[Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[Distributions]]
deps = ["FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SparseArrays", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns"]
git-tree-sha1 = "a837fdf80f333415b69684ba8e8ae6ba76de6aaa"
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
version = "0.24.18"

[[DocStringExtensions]]
deps = ["LibGit2"]
git-tree-sha1 = "a32185f5428d3986f47c2ab78b1f216d5e6cc96f"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.8.5"

[[Downloads]]
deps = ["ArgTools", "LibCURL", "NetworkOptions"]
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"

[[EarCut_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "92d8f9f208637e8d2d28c664051a00569c01493d"
uuid = "5ae413db-bbd1-5e63-b57d-d24a61df00f5"
version = "2.1.5+1"

[[FFAST]]
deps = ["CSV", "DataFrames", "Requires"]
git-tree-sha1 = "24869b1eff1eaa7f7dee1a52e4b9fece34b44bb4"
uuid = "10506e09-08cd-5f0b-aee5-631de1bcc925"
version = "2.0.4"

[[FFTW]]
deps = ["AbstractFFTs", "FFTW_jll", "LinearAlgebra", "MKL_jll", "Preferences", "Reexport"]
git-tree-sha1 = "f985af3b9f4e278b1d24434cbb546d6092fca661"
uuid = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
version = "1.4.3"

[[FFTW_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "3676abafff7e4ff07bbd2c42b3d8201f31653dcc"
uuid = "f5851436-0d7a-5f13-b9de-f02708fd171a"
version = "3.3.9+8"

[[FileIO]]
deps = ["Pkg", "Requires", "UUIDs"]
git-tree-sha1 = "256d8e6188f3f1ebfa1a5d17e072a0efafa8c5bf"
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
version = "1.10.1"

[[FillArrays]]
deps = ["LinearAlgebra", "Random", "SparseArrays"]
git-tree-sha1 = "693210145367e7685d8604aee33d9bfb85db8b31"
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
version = "0.11.9"

[[FixedPointNumbers]]
deps = ["Statistics"]
git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc"
uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
version = "0.8.4"

[[Formatting]]
deps = ["Printf"]
git-tree-sha1 = "8339d61043228fdd3eb658d86c926cb282ae72a8"
uuid = "59287772-0a20-5a39-b81b-1366585eb4c0"
version = "0.4.2"

[[Future]]
deps = ["Random"]
uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"

[[Gadfly]]
deps = ["Base64", "CategoricalArrays", "Colors", "Compose", "Contour", "CoupledFields", "DataAPI", "DataStructures", "Dates", "Distributions", "DocStringExtensions", "Hexagons", "IndirectArrays", "IterTools", "JSON", "Juno", "KernelDensity", "LinearAlgebra", "Loess", "Measures", "Printf", "REPL", "Random", "Requires", "Showoff", "Statistics"]
git-tree-sha1 = "96da4818e4d481a29aa7d66aac1eb778432fb89a"
uuid = "c91e804a-d5a3-530f-b6f0-dfbca275c004"
version = "1.3.3"

[[GeometryBasics]]
deps = ["EarCut_jll", "IterTools", "LinearAlgebra", "StaticArrays", "StructArrays", "Tables"]
git-tree-sha1 = "15ff9a14b9e1218958d3530cc288cf31465d9ae2"
uuid = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
version = "0.3.13"

[[Grisu]]
git-tree-sha1 = "53bb909d1151e57e2484c3d1b53e19552b887fb2"
uuid = "42e2da0e-8278-4e71-bc24-59509adca0fe"
version = "1.0.2"

[[Hexagons]]
deps = ["Test"]
git-tree-sha1 = "de4a6f9e7c4710ced6838ca906f81905f7385fd6"
uuid = "a1b4810d-1bce-5fbd-ac56-80944d57a21f"
version = "0.2.0"

[[IndirectArrays]]
git-tree-sha1 = "c2a145a145dc03a7620af1444e0264ef907bd44f"
uuid = "9b13fd28-a010-5f03-acff-a1bbcff69959"
version = "0.5.1"

[[IntelOpenMP_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "d979e54b71da82f3a65b62553da4fc3d18c9004c"
uuid = "1d5cc7b8-4909-519e-a0f8-d0f5ad9712d0"
version = "2018.0.3+2"

[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[Interpolations]]
deps = ["AxisAlgorithms", "LinearAlgebra", "OffsetArrays", "Random", "Ratios", "SharedArrays", "SparseArrays", "StaticArrays", "WoodburyMatrices"]
git-tree-sha1 = "1e0e51692a3a77f1eeb51bf741bdd0439ed210e7"
uuid = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
version = "0.13.2"

[[InvertedIndices]]
deps = ["Test"]
git-tree-sha1 = "15732c475062348b0165684ffe28e85ea8396afc"
uuid = "41ab1584-1d38-5bbf-9106-f11c6c58b48f"
version = "1.0.0"

[[IterTools]]
git-tree-sha1 = "05110a2ab1fc5f932622ffea2a003221f4782c18"
uuid = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
version = "1.3.0"

[[IteratorInterfaceExtensions]]
git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856"
uuid = "82899510-4779-5014-852e-03e436cf321d"
version = "1.0.0"

[[JLLWrappers]]
deps = ["Preferences"]
git-tree-sha1 = "642a199af8b68253517b80bd3bfd17eb4e84df6e"
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
version = "1.3.0"

[[JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "8076680b162ada2a031f707ac7b4953e30667a37"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.2"

[[Juno]]
deps = ["Base64", "Logging", "Media", "Profile"]
git-tree-sha1 = "07cb43290a840908a771552911a6274bc6c072c7"
uuid = "e5e0dc1b-0480-54bc-9374-aad01c23163d"
version = "0.8.4"

[[KernelDensity]]
deps = ["Distributions", "DocStringExtensions", "FFTW", "Interpolations", "StatsBase"]
git-tree-sha1 = "591e8dc09ad18386189610acafb970032c519707"
uuid = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b"
version = "0.6.3"

[[LaTeXStrings]]
git-tree-sha1 = "c7f1c695e06c01b95a67f0cd1d34994f3e7db104"
uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
version = "1.2.1"

[[LazyArtifacts]]
deps = ["Artifacts", "Pkg"]
uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3"

[[LibCURL]]
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"

[[LibCURL_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"

[[LibGit2]]
deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"

[[LibSSH2_jll]]
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"

[[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[[LinearAlgebra]]
deps = ["Libdl"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[[Loess]]
deps = ["Distances", "LinearAlgebra", "Statistics"]
git-tree-sha1 = "b5254a86cf65944c68ed938e575f5c81d5dfe4cb"
uuid = "4345ca2d-374a-55d4-8d30-97f9976e7612"
version = "0.5.3"

[[LogExpFunctions]]
deps = ["DocStringExtensions", "LinearAlgebra"]
git-tree-sha1 = "7bd5f6565d80b6bf753738d2bc40a5dfea072070"
uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
version = "0.2.5"

[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[MKL_jll]]
deps = ["Artifacts", "IntelOpenMP_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "Pkg"]
git-tree-sha1 = "c253236b0ed414624b083e6b72bfe891fbd2c7af"
uuid = "856f044c-d86e-5d09-b602-aeab76dc8ba7"
version = "2021.1.1+1"

[[MacroTools]]
deps = ["Markdown", "Random"]
git-tree-sha1 = "0fb723cd8c45858c22169b2e42269e53271a6df7"
uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
version = "0.5.7"

[[Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"

[[Measurements]]
deps = ["Calculus", "LinearAlgebra", "Printf", "RecipesBase", "Requires"]
git-tree-sha1 = "31c8c0569b914111c94dd31149265ed47c238c5b"
uuid = "eff96d63-e80a-5855-80a2-b1b0885c5ab7"
version = "2.6.0"

[[Measures]]
git-tree-sha1 = "e498ddeee6f9fdb4551ce855a46f54dbd900245f"
uuid = "442fdcdd-2543-5da2-b0f3-8c86c306513e"
version = "0.3.1"

[[Media]]
deps = ["MacroTools", "Test"]
git-tree-sha1 = "75a54abd10709c01f1b86b84ec225d26e840ed58"
uuid = "e89f7d12-3494-54d1-8411-f7d8b9ae1f27"
version = "0.5.0"

[[Missings]]
deps = ["DataAPI"]
git-tree-sha1 = "4ea90bd5d3985ae1f9a908bd4500ae88921c5ce7"
uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
version = "1.0.0"

[[Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"

[[NeXLCore]]
deps = ["BoteSalvatICX", "CSV", "Colors", "CoordinateTransformations", "DataFrames", "Dierckx", "FFAST", "FileIO", "GeometryBasics", "LaTeXStrings", "LinearAlgebra", "NeXLUncertainties", "PeriodicTable", "PhysicalConstants", "Pkg", "Printf", "QuadGK", "Random", "Reexport", "Requires", "StaticArrays", "Statistics", "Unitful"]
git-tree-sha1 = "2d5223af8025e56e1ef15eb86b95e040fc2c3ff9"
uuid = "93a0284f-3680-435e-8d39-dd6e52a1dbc8"
version = "0.2.6"

[[NeXLUncertainties]]
deps = ["DataFrames", "Distributions", "Formatting", "LaTeXStrings", "LinearAlgebra", "Printf", "Random", "Statistics"]
git-tree-sha1 = "f7ffd91efbb6426734819732b187fe4894ebd6d3"
uuid = "7127f3d6-1721-46bc-bb38-8fc703dd438e"
version = "0.2.5"

[[NetworkOptions]]
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"

[[OffsetArrays]]
deps = ["Adapt"]
git-tree-sha1 = "5cc97a6f806ba1b36bac7078b866d4297ae8c463"
uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
version = "1.10.4"

[[OpenSpecFun_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "13652491f6856acfd2db29360e1bbcd4565d04f1"
uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e"
version = "0.5.5+0"

[[OrderedCollections]]
git-tree-sha1 = "85f8e6578bf1f9ee0d11e7bb1b1456435479d47c"
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
version = "1.4.1"

[[PDMats]]
deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse"]
git-tree-sha1 = "4dd403333bcf0909341cfe57ec115152f937d7d8"
uuid = "90014a1f-27ba-587c-ab20-58faa44d9150"
version = "0.11.1"

[[Parsers]]
deps = ["Dates"]
git-tree-sha1 = "bfd7d8c7fd87f04543810d9cbd3995972236ba1b"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "1.1.2"

[[PeriodicTable]]
deps = ["Base64", "Test", "Unitful"]
git-tree-sha1 = "067ef5738ef3157f29749c32b64f0ff9b3d07ab2"
uuid = "7b2266bf-644c-5ea3-82d8-af4bbd25a884"
version = "1.1.0"

[[PhysicalConstants]]
deps = ["Measurements", "Roots", "Unitful"]
git-tree-sha1 = "2bc26b693b5cbc823c54b33ea88a9209d27e2db7"
uuid = "5ad8b20f-a522-5ce9-bfc9-ddf1d5bda6ab"
version = "0.2.1"

[[Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[PlutoUI]]
deps = ["Base64", "Dates", "InteractiveUtils", "JSON", "Logging", "Markdown", "Random", "Reexport", "Suppressor"]
git-tree-sha1 = "44e225d5837e2a2345e69a1d1e01ac2443ff9fcb"
uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
version = "0.7.9"

[[PooledArrays]]
deps = ["DataAPI", "Future"]
git-tree-sha1 = "cde4ce9d6f33219465b55162811d8de8139c0414"
uuid = "2dfb63ee-cc39-5dd5-95bd-886bf059d720"
version = "1.2.1"

[[Preferences]]
deps = ["TOML"]
git-tree-sha1 = "00cfd92944ca9c760982747e9a1d0d5d86ab1e5a"
uuid = "21216c6a-2e73-6563-6e65-726566657250"
version = "1.2.2"

[[PrettyTables]]
deps = ["Crayons", "Formatting", "Markdown", "Reexport", "Tables"]
git-tree-sha1 = "0d1245a357cc61c8cd61934c07447aa569ff22e6"
uuid = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
version = "1.1.0"

[[Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[Profile]]
deps = ["Printf"]
uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"

[[QuadGK]]
deps = ["DataStructures", "LinearAlgebra"]
git-tree-sha1 = "12fbe86da16df6679be7521dfb39fbc861e1dc7b"
uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
version = "2.4.1"

[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"

[[Random]]
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[Ratios]]
git-tree-sha1 = "37d210f612d70f3f7d57d488cb3b6eff56ad4e41"
uuid = "c84ed2f1-dad5-54f0-aa8e-dbefe2724439"
version = "0.4.0"

[[RecipesBase]]
git-tree-sha1 = "b3fb709f3c97bfc6e948be68beeecb55a0b340ae"
uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
version = "1.1.1"

[[Reexport]]
git-tree-sha1 = "5f6c21241f0f655da3952fd60aa18477cf96c220"
uuid = "189a3867-3050-52da-a836-e630ba90ab69"
version = "1.1.0"

[[Requires]]
deps = ["UUIDs"]
git-tree-sha1 = "4036a3bd08ac7e968e27c203d45f5fff15020621"
uuid = "ae029012-a4dd-5104-9daa-d747884805df"
version = "1.1.3"

[[Rmath]]
deps = ["Random", "Rmath_jll"]
git-tree-sha1 = "bf3188feca147ce108c76ad82c2792c57abe7b1f"
uuid = "79098fc4-a85e-5d69-aa6a-4863f24498fa"
version = "0.7.0"

[[Rmath_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "68db32dff12bb6127bac73c209881191bf0efbb7"
uuid = "f50d1b31-88e8-58de-be2c-1cc44531875f"
version = "0.3.0+0"

[[Roots]]
deps = ["CommonSolve", "Printf"]
git-tree-sha1 = "52a5d9ab3fc404993593c79576ce2af68b965ede"
uuid = "f2b01f46-fcfa-551c-844a-d8ac1e96c665"
version = "1.1.0"

[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"

[[SentinelArrays]]
deps = ["Dates", "Random"]
git-tree-sha1 = "a3a337914a035b2d59c9cbe7f1a38aaba1265b02"
uuid = "91c51154-3ec4-41a3-a24f-3f23e20d615c"
version = "1.3.6"

[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

[[SharedArrays]]
deps = ["Distributed", "Mmap", "Random", "Serialization"]
uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383"

[[Showoff]]
deps = ["Dates", "Grisu"]
git-tree-sha1 = "91eddf657aca81df9ae6ceb20b959ae5653ad1de"
uuid = "992d4aef-0814-514b-bc4d-f2e9a6c4116f"
version = "1.0.3"

[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[SortingAlgorithms]]
deps = ["DataStructures"]
git-tree-sha1 = "b3363d7460f7d098ca0912c69b082f75625d7508"
uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
version = "1.0.1"

[[SparseArrays]]
deps = ["LinearAlgebra", "Random"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[[SpecialFunctions]]
deps = ["ChainRulesCore", "LogExpFunctions", "OpenSpecFun_jll"]
git-tree-sha1 = "508822dca004bf62e210609148511ad03ce8f1d8"
uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
version = "1.6.0"

[[StaticArrays]]
deps = ["LinearAlgebra", "Random", "Statistics"]
git-tree-sha1 = "3fedeffc02e47d6e3eb479150c8e5cd8f15a77a0"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.2.10"

[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[[StatsAPI]]
git-tree-sha1 = "1958272568dc176a1d881acb797beb909c785510"
uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
version = "1.0.0"

[[StatsBase]]
deps = ["DataAPI", "DataStructures", "LinearAlgebra", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"]
git-tree-sha1 = "fed1ec1e65749c4d96fc20dd13bea72b55457e62"
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
version = "0.33.9"

[[StatsFuns]]
deps = ["LogExpFunctions", "Rmath", "SpecialFunctions"]
git-tree-sha1 = "30cd8c360c54081f806b1ee14d2eecbef3c04c49"
uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
version = "0.9.8"

[[StructArrays]]
deps = ["Adapt", "DataAPI", "StaticArrays", "Tables"]
git-tree-sha1 = "000e168f5cc9aded17b6999a560b7c11dda69095"
uuid = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
version = "0.6.0"

[[StructTypes]]
deps = ["Dates", "UUIDs"]
git-tree-sha1 = "e36adc471280e8b346ea24c5c87ba0571204be7a"
uuid = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
version = "1.7.2"

[[SuiteSparse]]
deps = ["Libdl", "LinearAlgebra", "Serialization", "SparseArrays"]
uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"

[[Suppressor]]
git-tree-sha1 = "a819d77f31f83e5792a76081eee1ea6342ab8787"
uuid = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
version = "0.2.0"

[[TOML]]
deps = ["Dates"]
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"

[[TableTraits]]
deps = ["IteratorInterfaceExtensions"]
git-tree-sha1 = "c06b2f539df1c6efa794486abfb6ed2022561a39"
uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c"
version = "1.0.1"

[[Tables]]
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "TableTraits", "Test"]
git-tree-sha1 = "d0c690d37c73aeb5ca063056283fde5585a41710"
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
version = "1.5.0"

[[Tar]]
deps = ["ArgTools", "SHA"]
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"

[[Test]]
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[[Unitful]]
deps = ["ConstructionBase", "Dates", "LinearAlgebra", "Random"]
git-tree-sha1 = "a981a8ef8714cba2fd9780b22fd7a469e7aaf56d"
uuid = "1986cc42-f94f-5a68-af5c-568840ba703d"
version = "1.9.0"

[[WoodburyMatrices]]
deps = ["LinearAlgebra", "SparseArrays"]
git-tree-sha1 = "59e2ad8fd1591ea019a5259bd012d7aee15f995c"
uuid = "efce3f68-66dc-5838-9240-27a6d6f5f9b6"
version = "0.5.3"

[[Zlib_jll]]
deps = ["Libdl"]
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"

[[nghttp2_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"

[[p7zip_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
"""

# ╔═╡ Cell order:
# ╟─b2e92442-ada2-457c-bbb5-b824fcfbfdcf
# ╠═92e150f0-f5f3-11eb-33a3-c39993e395ef
# ╠═489dd119-d9e6-46cd-ac3d-5e1d6b3c0bb5
# ╟─10444fa1-c990-41e3-b742-52e709de6f6b
# ╟─f0c903b0-1485-49fa-9e08-27189b405d63
# ╠═77ec16f4-c285-4136-9e7b-376b1f68c74a
# ╟─00000000-0000-0000-0000-000000000001
# ╟─00000000-0000-0000-0000-000000000002


text:
abstract DirichletPrior
type UniformPrior <: DirichletPrior
    α::Float64
    UniformPrior(α::Float64=1.0) = new(α)
end
type BDeuPrior <: DirichletPrior
    #=
    Assigns equal scores to Markov equivalent structures

    α_ijk = x/{q_i * r_i} ∀ j, k and some given x

    see DMU section 2.4.3
    =#

    x::Float64

    BDeuPrior(x::Float64=1.0) = new(x)
end

Base.print(io::IO, p::UniformPrior) = Base.print(io, "UniformPrior(%.2f)", p.α)
Base.print(io::IO, p::BDeuPrior) = @printf(io, "BDeuPrior(%.2f)", p.x)

function Base.get{I<:Integer, J<:Integer}(p::UniformPrior,
    var_index::Integer,
    nintervals::AbstractVector{I}, # [nvars]
    parents::AbstractVector{J},    # [nvars]
    )

    r = nintervals[var_index]
    q = isempty(parents) ? 1 : prod(nintervals[parents])
    α = p.α

    fill(α, r, q)::Matrix{Float64}
end
function Base.get{I<:Integer, J<:Integer}(p::BDeuPrior,
    var_index::Integer,
    nintervals::AbstractVector{I}, # [nvars]
    parents::AbstractVector{J},    # [nvars]
    )

    x = p.x
    r = nintervals[var_index]
    q = isempty(parents) ? 1 : prod(nintervals[parents])

    α = x / (r*q)

    fill(α, r, q)::Matrix{Float64}
end


text:
using PPLM
using Documenter

DocMeta.setdocmeta!(PPLM, :DocTestSetup, :(using PPLM); recursive=true)

makedocs(;
    modules=[PPLM],
    authors="Adarsh Kumar",
    repo="https://github.com/adarshkumar712/PPLM.jl/blob/{commit}{path}#{line}",
    sitename="PPLM.jl",
    format=Documenter.HTML(;
        prettyurls=get(ENV, "CI", "false") == "true",
        canonical="https://adarshkumar712.github.io/PPLM.jl",
        assets=String[],
    ),
    pages=[
        "Home" => "index.md",
        "How does it work?" => "how.md",
        "GPT2: Tokenization and Generation" => "gpt2.md",
        "Bag Of Words Model" => "bow.md",
        "Discriminator Model" => "discrim.md",
        "Discriminator Training" => "discrim_train.md",
        "API" => "api.md",
        "Contact Info" => "contact.md",
    ],
)

deploydocs(;
    repo="github.com/AdarshKumar712/PPLM.jl",
    devbranch = "main",
)


text:
# These tests require an FT device which supports D2XX to be connected
#
# By Reuben Hill 2019, Gowerlabs Ltd, reuben@gowerlabs.co.uk
#
# Copyright (c) Gowerlabs Ltd.

module TestWrapper

using Test
using LibFTD2XX.Wrapper
using LibFTD2XX.Util

@testset "wrapper" begin

  # FT_CreateDeviceInfoList tests...
  numdevs = FT_CreateDeviceInfoList()
  @test numdevs > 0

  # FT_GetDeviceInfoList tests...
  devinfolist, numdevs2 = FT_GetDeviceInfoList(numdevs)
  @test numdevs2 == numdevs
  @test length(devinfolist) == numdevs

  description = ntuple2string(devinfolist[1].description)

  if Sys.iswindows() # should not have a locid on windows
    @test devinfolist[1].locid == 0
  end

  # FT_GetDeviceInfoDetail tests...
  idx, flags, typ, id, locid, serialnumber, description, fthandle = FT_GetDeviceInfoDetail(0)

  @test idx == 0
  @test flags == devinfolist[1].flags
  @test typ == devinfolist[1].typ
  @test id == devinfolist[1].id
  @test locid == devinfolist[1].locid
  @test serialnumber == ntuple2string(devinfolist[1].serialnumber)
  @test description == ntuple2string(devinfolist[1].description)
  @test Wrapper._ptr(fthandle) == devinfolist[1].fthandle_ptr

  # FT_ListDevices tests...
  numdevs2 = Ref{UInt32}()
  retval = FT_ListDevices(numdevs2, Ref{UInt32}(), FT_LIST_NUMBER_ONLY)
  @test retval == nothing
  @test numdevs2[] == numdevs

  devidx = Ref{UInt32}(0)
  buffer = pointer(Vector{Cchar}(undef, 64))
  @test_throws ErrorException FT_ListDevices(devidx, buffer, FT_LIST_BY_INDEX|FT_OPEN_BY_SERIAL_NUMBER)
  @test description != unsafe_string(buffer)

  # FT_Open tests...
  handle = FT_Open(0)
  @test handle isa FT_HANDLE
  @test Wrapper._ptr(handle) != C_NULL
  FT_Close(handle)

  # FT_OpenEx tests...
  # by description
  if !isempty(description)
  	handle = FT_OpenEx(description, FT_OPEN_BY_DESCRIPTION)
  	@test handle isa FT_HANDLE
  	@test Wrapper._ptr(handle) != C_NULL
  	FT_Close(handle)
  end
  # by serialnumber
  if !isempty(serialnumber)
  	handle = FT_OpenEx(serialnumber, FT_OPEN_BY_SERIAL_NUMBER)
  	@test handle isa FT_HANDLE
  	@test Wrapper._ptr(handle) != C_NULL
  	FT_Close(handle)
  end

  # FT_Close tests...
  handle = FT_Open(0)
  retval = FT_Close(handle)
  @test retval == nothing
  @test_throws FT_STATUS_ENUM FT_Close(handle) # can't close twice...

  # FT_Read tests...
  handle = FT_Open(0)
  buffer = zeros(UInt8, 5)
  nread = FT_Read(handle, buffer, 0) # read 0 bytes
  @test nread == 0
  @test buffer == zeros(UInt8, 5)
  @test_throws AssertionError FT_Read(handle, buffer, 6) # read 5 bytes
  @test_throws AssertionError FT_Read(handle, buffer, -1) # read -1 bytes
  FT_Close(handle)
  @test_throws FT_STATUS_ENUM FT_Read(handle, buffer, 0)

  # FT_Write tests...
  handle = FT_Open(0)
  buffer = ones(UInt8, 5)
  nwr = FT_Write(handle, buffer, 0) # write 0 bytes
  @test nwr == 0
  @test buffer == ones(UInt8, 5)
  nwr = FT_Write(handle, buffer, 2) # write 2 bytes
  @test nwr == 2
  @test buffer == ones(UInt8, 5)
  @test_throws AssertionError FT_Write(handle, buffer, 6) # write 6 bytes
  @test_throws AssertionError FT_Write(handle, buffer, -1) # write -1 bytes
  FT_Close(handle)
  @test_throws FT_STATUS_ENUM FT_Write(handle, buffer, 0)

  # FT_SetDataCharacteristics tests...
  handle = FT_Open(0)
  retval = FT_SetDataCharacteristics(handle, FT_BITS_8, FT_STOP_BITS_1, FT_PARITY_NONE)
  @test retval == nothing
  # other combinations...
  FT_SetDataCharacteristics(handle, FT_BITS_7, FT_STOP_BITS_1, FT_PARITY_NONE)
  FT_SetDataCharacteristics(handle, FT_BITS_8, FT_STOP_BITS_2, FT_PARITY_NONE)
  FT_SetDataCharacteristics(handle, FT_BITS_8, FT_STOP_BITS_1, FT_PARITY_EVEN)
  FT_SetDataCharacteristics(handle, FT_BITS_8, FT_STOP_BITS_1, FT_PARITY_ODD)
  FT_SetDataCharacteristics(handle, FT_BITS_8, FT_STOP_BITS_1, FT_PARITY_MARK)
  FT_SetDataCharacteristics(handle, FT_BITS_8, FT_STOP_BITS_1, FT_PARITY_SPACE)
  # Bad values
  @test_throws AssertionError FT_SetDataCharacteristics(handle, ~(FT_BITS_8 | FT_BITS_7), FT_STOP_BITS_1, FT_PARITY_NONE)
  @test_throws AssertionError FT_SetDataCharacteristics(handle, FT_BITS_8, ~(FT_STOP_BITS_1 | FT_STOP_BITS_2), FT_PARITY_NONE)
  @test_throws AssertionError FT_SetDataCharacteristics(handle, FT_BITS_8, FT_STOP_BITS_1, ~(FT_PARITY_NONE | FT_PARITY_EVEN))
  # closed handle
  FT_Close(handle)
  @test_throws FT_STATUS_ENUM FT_SetDataCharacteristics(handle, FT_BITS_8, FT_STOP_BITS_1, FT_PARITY_NONE)

  # FT_SetTimeouts tests...
  handle = FT_Open(0)
  FT_SetBaudRate(handle, 9600)
  timeout_read, timeout_wr = 200, 100 # milliseconds
  FT_SetTimeouts(handle, timeout_read, timeout_wr)
  buffer = zeros(UInt8, 5000);
  tread = 1000 * @elapsed nread = FT_Read(handle, buffer, 5000)
  twr = 1000 * @elapsed nwr = FT_Write(handle, buffer, 5000)
  @test timeout_read < 1.5*tread
  @test timeout_wr < 1.5*twr
  @test_throws InexactError FT_SetTimeouts(handle, timeout_read, -1)
  @test_throws InexactError FT_SetTimeouts(handle, -1, timeout_wr)
  FT_Close(handle)
  @test_throws FT_STATUS_ENUM FT_SetTimeouts(handle, timeout_read, timeout_wr)

  # FT_GetModemStatus tests
  handle = FT_Open(0)
  flags = FT_GetModemStatus(handle)
  @test flags isa DWORD
  FT_Close(handle)
  @test_throws FT_STATUS_ENUM FT_GetModemStatus(handle)

  # FT_GetQueueStatus tests
  handle = FT_Open(0)
  nbrx = FT_GetQueueStatus(handle)
  @test nbrx isa DWORD
  FT_Close(handle)
  @test_throws FT_STATUS_ENUM FT_GetQueueStatus(handle)

  # FT_GetDeviceInfo tests
  id_buf = id
  serialnumber_buf = serialnumber
  description_buf = description
  handle = FT_Open(0)
  typ, id, serialnumber, description = FT_GetDeviceInfo(handle)
  @test typ isa FT_DEVICE
  @test serialnumber == serialnumber_buf
  @test description == description_buf
  FT_Close(handle)
  @test_throws FT_STATUS_ENUM FT_GetDeviceInfo(handle)

  # FT_GetDriverVersion tests
  if Sys.iswindows()
    handle = FT_Open(0)
    version = FT_GetDriverVersion(handle)
    @test version isa DWORD
    @test version > 0
    @test (version >> 24) & 0xFF == 0x00 # 4th byte should be 0 according to docs
    FT_Close(handle)
    @test_throws FT_STATUS_ENUM FT_GetDriverVersion(handle)
  else
    handle = FT_Open(0)
    @test_throws UndefVarError FT_GetDriverVersion(handle)
    FT_Close(handle)
  end

  # FT_GetLibraryVersion tests
  if Sys.iswindows()
    version = FT_GetLibraryVersion()
    @test version isa DWORD
    @test version > 0
    @test (version >> 24) & 0xFF == 0x00 # 4th byte should be 0 according to docs
  else
    @test_throws UndefVarError FT_GetLibraryVersion()
  end

  # FT_GetStatus tests
  handle = FT_Open(0)
  nbrx, nbtx, eventstatus = FT_GetStatus(handle)
  @test nbrx isa DWORD
  @test nbtx isa DWORD
  @test eventstatus isa DWORD
  FT_Close(handle)
  @test_throws FT_STATUS_ENUM FT_GetStatus(handle)

  # FT_SetBreakOn tests
  handle = FT_Open(0)
  retval = FT_SetBreakOn(handle)
  @test retval == nothing
  FT_Close(handle)
  @test_throws FT_STATUS_ENUM FT_SetBreakOn(handle)

  # FT_SetBreakOff tests
  handle = FT_Open(0)
  retval = FT_SetBreakOff(handle)
  @test retval == nothing
  FT_Close(handle)
  @test_throws FT_STATUS_ENUM FT_SetBreakOff(handle)

  # FT_Purge tests
  handle = FT_Open(0)
  retval = FT_Purge(handle, FT_PURGE_RX|FT_PURGE_TX)
  @test retval == nothing
  nbrx, nbtx, eventstatus = FT_GetStatus(handle)
  nbrx_2 = FT_GetQueueStatus(handle)
  @test nbrx == nbtx == nbrx_2 == 0
  FT_Purge(handle, FT_PURGE_RX)
  FT_Purge(handle, FT_PURGE_TX)
  @test_throws AssertionError FT_Purge(handle, ~(FT_PURGE_RX))
  @test_throws AssertionError FT_Purge(handle, ~(FT_PURGE_TX))
  @test_throws AssertionError FT_Purge(handle, ~(FT_PURGE_RX | FT_PURGE_TX))
  FT_Close(handle)
  @test_throws FT_STATUS_ENUM FT_Purge(handle, FT_PURGE_RX|FT_PURGE_TX)

  # FT_StopInTask and FT_RestartInTask tests
  handle = FT_Open(0)
  retval = FT_StopInTask(handle)
  @test retval == nothing
  nbrx, nbtx, eventstatus = FT_GetStatus(handle)
  sleep(0.1)
  nbrx_2, nbtx, eventstatus = FT_GetStatus(handle)
  @test nbrx == nbrx_2
  retval = FT_RestartInTask(handle)
  @test retval == nothing
  FT_Close(handle)
  @test_throws FT_STATUS_ENUM FT_StopInTask(handle)
  @test_throws FT_STATUS_ENUM FT_RestartInTask(handle)

  # FT_FlowControl tests
  handle = FT_Open(0)
  @test_throws AssertionError FT_SetFlowControl(handle, 0xFF, 0x00, 0x01)
  @test_throws InexactError FT_SetFlowControl(handle, FT_FLOW_NONE, 0x00, -1)
  FT_Close(handle)
  @test_throws FT_STATUS_ENUM FT_SetFlowControl(handle, FT_FLOW_NONE, 0x00, 0x00)

  # FT_SetDtr, FT_ClrDtr, FT_SetRts and FT_ClrRts tests
  handle = FT_Open(0)
  retval = FT_SetDtr(handle)
  @test retval == nothing
  retval = FT_ClrDtr(handle)
  @test retval == nothing
  retval = FT_SetRts(handle)
  @test retval == nothing
  retval = FT_ClrRts(handle)
  @test retval == nothing
  FT_Close(handle)
  @test_throws FT_STATUS_ENUM FT_SetDtr(handle)
  @test_throws FT_STATUS_ENUM FT_ClrDtr(handle)
  @test_throws FT_STATUS_ENUM FT_SetRts(handle)
  @test_throws FT_STATUS_ENUM FT_ClrRts(handle)

  # FT_EventNotification tests

  # FT_SetChars tests
  handle = FT_Open(0)
  @test_throws InexactError FT_SetChars(handle, 0x00, 0x00, 0x00, -1)
  FT_Close(handle)
  @test_throws FT_STATUS_ENUM FT_SetChars(handle, 0x00, 0x00, 0x00, 0x00)

  # FT_SetLatencyTimer and FT_GetLatencyTimer tests
  handle = FT_Open(0)
  FT_SetLatencyTimer(handle, 0xAC)
  retval = FT_GetLatencyTimer(handle)
  @test retval==0xAC
  @test_throws InexactError FT_SetLatencyTimer(handle, 300)
  FT_Close(handle)
  @test_throws FT_STATUS_ENUM FT_SetLatencyTimer(handle, 128)

  # FT_SetBitMode tests
  handle = FT_Open(0)
  @test_throws AssertionError FT_SetBitMode(handle, 0x00, 0xFF)
  @test_throws InexactError FT_SetBitMode(handle, -1, FT_MODE_RESET)
  FT_Close(handle)
  @test_throws FT_STATUS_ENUM FT_SetBitMode(handle, 0x00, FT_MODE_RESET)
  # FT_GetBitMode doesn't return the bit mode, but the pin status. So we can't check against that.

end

end # module TestWrapper


text:
abstract type LocalFieldParameter end
abstract type EisensteinLocalField <: LocalFieldParameter end
abstract type UnramifiedLocalField <: LocalFieldParameter end
abstract type GenericLocalField <: LocalFieldParameter end

mutable struct LocalField{S, T} <: Field
  defining_polynomial::Generic.Poly{S}
  S::Symbol
  precision::Int
  traces_basis::Vector{S}
  ramification_index::Int
  inertia_degree::Int
  uniformizer::Generic.Poly{S}
  residue_field_map

  function LocalField{S, T}(f::Generic.Poly{S}, s::Symbol) where {S <: FieldElem, T <: LocalFieldParameter}
    z = new{S, T}()
    z.defining_polynomial = f
    z.S = s
    z.precision = precision(f)
    z.ramification_index = -1
    z.inertia_degree = -1
    return z
  end
end

mutable struct LocalFieldElem{S, T} <: FieldElem
  parent::LocalField{S, T}
  data::Generic.Poly{S}
  precision::Int
end

mutable struct CompletionMap{S, T} <: Map{AnticNumberField, S, HeckeMap, CompletionMap{S, T}}
  header::MapHeader{AnticNumberField, S}
  P::NfOrdIdl
  prim_img::T
  inv_img::Tuple{nf_elem, nf_elem}
  precision::Int

  function CompletionMap(K::AnticNumberField, L::LocalField{qadic, EisensteinLocalField},
                          img::LocalFieldElem{qadic, EisensteinLocalField},
                          inv_img::Tuple{nf_elem, nf_elem}, precision::Int)
    z = new{LocalField{qadic, EisensteinLocalField}, LocalFieldElem{qadic, EisensteinLocalField}}()
    z.header = MapHeader(K, L)
    z.prim_img = img
    z.inv_img = inv_img
    z.precision = precision
    return z
  end

  function CompletionMap(K::AnticNumberField, L::LocalField{padic, EisensteinLocalField},
                          img::LocalFieldElem{padic, EisensteinLocalField},
                          inv_img::nf_elem, precision::Int)
    z = new{LocalField{padic, EisensteinLocalField}, LocalFieldElem{padic, EisensteinLocalField}}()
    z.header = MapHeader(K, L)
    z.prim_img = img
    z.inv_img = (zero(K), inv_img)
    z.precision = precision
    return z
  end

  function CompletionMap(K::AnticNumberField, L::FlintQadicField,
                          img::qadic,
                          inv_img::nf_elem, precision::Int)
    z = new{FlintQadicField, qadic}()
    z.header = MapHeader(K, L)
    z.prim_img = img
    z.inv_img = (inv_img, zero(K))
    z.precision = precision
    return z
  end
end


text:
function linear_index(IND)
  J = round(Int,floor(-.5 + .5 * sqrt(1 + 8 * (IND - 1))) + 2)
  I = round(Int,J .* (3 - J) / 2 + IND - 1)
  return I, J
end


text:
export Euler

"""
    Euler()

This uses the explicit Euler method for prediction, also known as the
tangent predictor.
"""
struct Euler <: AbstractPredictor end
struct EulerCache <: AbstractPredictorCache end

cache(::Euler, H, x, ẋ, t) = EulerCache()

function predict!(
    xnext,
    cache::EulerCache,
    H::HomotopyWithCache,
    x,
    t,
    Δt,
    ẋ,
    ::JacobianMonitor,
)
    @inbounds for i = 1:length(x)
        xnext[i] = x[i] + Δt * ẋ[i]
    end
    nothing
end

order(::EulerCache) = 2


text:
abstract type Outbound end

function JSON.Writer.CompositeTypeWrapper(t::Outbound)
    fns = collect(fieldnames(typeof(t)))
    dels = Int[]
    for i = 1:length(fns)
        f = fns[i]
        if getfield(t, f) isa Missing
            push!(dels, i)
        end
    end
    deleteat!(fns, dels)
    JSON.Writer.CompositeTypeWrapper(t, Tuple(fns))
end

function field_allows_missing(field::Expr)
    field.head == :(::) && field.args[2] isa Expr &&
    field.args[2].head == :curly && field.args[2].args[1] == :Union &&
    last(field.args[2].args) == :Missing
end
function field_type(field::Expr)
    if field.args[2] isa Expr && field.args[2].head == :curly && field.args[2].args[1] == :Union
        return field.args[2].args[2]
    else
        return field.args[2]
    end
end

macro dict_readable(arg)
    tname = arg.args[2] isa Expr ? arg.args[2].args[1] : arg.args[2]
    ex = quote
        $((arg))

        function $((tname))(dict::Dict)
        end
    end
    fex = :($((tname))())
    for field in arg.args[3].args
        if !(field isa LineNumberNode)
            fieldname = string(field.args[1])
            fieldtype = field_type(field)
            if fieldtype isa Expr && fieldtype.head == :curly && fieldtype.args[2] != :Any
                f = :($(fieldtype.args[2]).(dict[$fieldname]))
            elseif fieldtype != :Any
                f = :($(fieldtype)(dict[$fieldname]))
            else
                f = :(dict[$fieldname])
            end
            if field_allows_missing(field)
                f = :(haskey(dict,$fieldname) ? $f : missing)
            end
            push!(fex.args, f)
        end
    end
    push!(ex.args[end].args[2].args, fex)
    return esc(ex)
end

include("basic.jl")
include("document.jl")
include("completion.jl")
include("formatting.jl")
include("hover.jl")
include("goto.jl")
include("highlight.jl")
include("signature.jl")
include("symbols.jl")
include("features.jl")
include("configuration.jl")
include("initialize.jl")

mutable struct CancelParams
    id::Union{String,Int64}
end
CancelParams(d::Dict) = CancelParams(d["id"])


text:
using Rectangle

function tree_get_data(t::IntervalTree{K, V}) where {K, V}
    karr = Vector{Interval{K}}()
    varr = Vector{V}()

    arr = collect(Iterator(t))
    for p in arr
        push!(karr, p[1])
        push!(varr, p[2])
    end
    return karr, varr
end

function intervalvalidity(t::IntervalTree)
    it = Iterator(t)
    next = iterate(it)
    valid = false
    while next !== nothing
        d, n = next
        valid = isnil(t, n) ||
            (isnil(t, n.l) && isnil(t, n.r) && n.k.submax == n.k.i.hi)   ||
            (isnil(t, n.l) && n.k.submax == max(n.k.i.hi, n.r.k.submax)) ||
            (isnil(t, n.r) && n.k.submax == max(n.k.i.hi, n.l.k.submax)) ||
            (n.k.submax == max(n.k.i.hi, n.l.k.submax, n.r.k.submax))    || break
        next = iterate(it, n)
    end
    return valid
end

function intersectvalidity(t, res, q)
    arr = [i for i in collect(Iterator(t)) if Rectangle.overlaps(i[1], q)]
    println(length(arr), ":", length(res))
    return arr == res
end

@testset "Interval Trees" begin
    @test string(Interval(0, 1)) == "(0, 1)"
    @test string(Rectangle.IntervalKey(Interval(0, 1))) == "(0, 1, 1)"
    a = [(26, 26), (25, 30), (19, 20), (17, 20), (16, 21),
         (15, 23), (8, 9),   (6,  10), ( 5,  8), ( 0,  3)]

    t = IntervalTree{Int, Int}()

    @test isempty(t)

    for i=1:lastindex(a)
        insert!(t, a[i][1], a[i][2], i*10)
    end

    @test collect(Iterator(t)) ==
        [Interval(0, 3)=>100,   Interval(5, 8)=>90,   Interval(6, 10)=>80,
         Interval(8, 9)=>70,   Interval(15, 23)=>60, Interval(16, 21)=>50,
         Interval(17, 20)=>40, Interval(19, 20)=>30, Interval(25, 30)=>20,
         Interval(26, 26)=>10]
    @test !intersects(t, Interval(4, 4))
    @test intersects(t, Interval(7, 8))
    @test intersect(t, Interval(7, 18)) ==
        [Interval(5, 8)=>90,   Interval(6, 10)=>80, Interval(8, 9)=>70,
         Interval(15, 23)=>60, Interval(16, 21)=>50, Interval(17, 20)=>40]
    t[Interval(16, 21)] = 110
    @test 110 == t[Interval(16, 21)]
    @test intervalvalidity(t)
    @test parentvalidity(t)
    @test bstvalidity(t)
    @test rbvalidity(t)
    @test length(t) == 10
    @test !isempty(t)
    @test maximum(t) == (Interval(26,26)=>10)
    @test minimum(t) == (Interval(0, 3)=>100)
    data = tree_get_data(t)
    aa = [Interval(x...) for x in sort(a)]
    @test data[1] == aa
    @test delete!(t, Interval(16, 21)) == (Interval(16,21)=>110)
    @test delete!(t, Interval(100, 110)) === nothing
    @test intervalvalidity(t)
    @test parentvalidity(t)
    @test bstvalidity(t)
    @test rbvalidity(t)
    data = tree_get_data(t)
    @test sort(data[2]) == [10, 20, 30, 40, 60, 70, 80, 90, 100]
    empty!(t)
    @test isempty(t)

    @testset "Non-unique" begin
        t.unique = false
        n = 10000
        a = Vector{Interval{Int}}()
        for i = 1:n
            j = rand(1:1000)
            k = rand(j:1000)
            push!(a, Interval(j, k))
        end
        for i = 1:n
            insert!(t, a[i].lo, a[i].hi, i)
        end
        @test length(t) == n
        @test intervalvalidity(t)
        @test parentvalidity(t)
        @test bstvalidity(t)
        @test rbvalidity(t)

        qlo = rand(1:1000)
        qhi = rand(qlo:1000)
        res = intersect(t, Interval(qlo, qhi))

        @test intersectvalidity(t, res, Interval(qlo, qhi))

        for i = 1:div(n, 2)
            @assert delete!(t, a[i]) !== nothing
        end
        @test length(t) == div(n, 2)
        @test intervalvalidity(t)
        @test rbvalidity(t)
        @test parentvalidity(t)
        @test bstvalidity(t)

        for i = 1:div(n, 2)
            insert!(t, a[i].lo, a[i].hi, i)
        end
        @test length(t) == n
        @test intervalvalidity(t)
        @test rbvalidity(t)
        @test parentvalidity(t)
        @test bstvalidity(t)
    end
end


text:
using DelimitedFiles
using Dates

wikiEVDraw = DelimitedFiles.readdlm("../Assets/wikipediaEVDraw.csv", ',')

# we have to convert the whole date column
# from "25 Nov 2015" to 2015-11-25T00:00:00
# Dates.DateTime(wikiEVDraw[1,1], "d u y")

date_column = wikiEVDraw[:,1]

for idx = 1:length(date_column)
    date_column[idx] = Dates.DateTime(date_column[idx], "d u y")
end

# convert it in an incremental "day",
# starting from epidemic day 0 (22 March 2014)
# that is the 54 element

daysincemar22(x) = Dates.datetime2rata(x) - Dates.datetime2rata(date_column[54])
epidays = Array{Int64}(undef,54)
for idx = 1:length(date_column)
    epidays[idx] = daysincemar22(date_column[idx])
end

# update the whole column
wikiEVDraw[:,1] = epidays

# write the new CSV file
DelimitedFiles.writedlm("../Assets/WikipediaEVDdatesconverted.csv", wikiEVDraw, ',')


text:
module TestGeom

include("preamble.jl")

@testset "SPoint3D" begin
    @test_throws ArgumentError SPoint3D(rand(4, 10), 3)
    @test_throws BoundsError SPoint3D(rand(3, 10), 11)
    A = rand(Float32, 3, 10)
    @test @inferred(SPoint3D(A, 5)) == A[:, 5]
    @test eltype(A) === Float32
    @test eltype(@inferred(SPoint3D{Float64}(A, 5))) === Float64
end

@testset "MPoint3D" begin
    @test_throws ArgumentError MPoint3D(rand(4, 10), 3)
    @test_throws BoundsError MPoint3D(rand(3, 10), 11)
    A = rand(Float32, 3, 10)
    @test @inferred(MPoint3D(A, 5)) == A[:, 5]
    @test eltype(A) === Float32
    @test eltype(@inferred(MPoint3D{Float64}(A, 5))) === Float64
end

end # module


text:
@testset "Testing Compiler" begin
    # Make sure that type conversion works correctly.
    x = rand(Float32, 2, 2)
    @test OneDNN.tracetype(x) == Mjolnir.Shape{typeof(x)}(size(x))
end


text:
using LinearAlgebra
using LightGraphs
using NPZ
using SpinGlassPEPS
using Logging
using ArgParse
using CSV
using Test

function M2graph(M::Matrix{Float64}, sgn::Int = 1)
    size(M,1) == size(M,2) || error("matrix not squared")
    L = size(M,1)

    D = Dict{Tuple{Int64,Int64},Float64}()
    for j ∈ 1:size(M, 1)
        for i ∈ 1:j
            if (i == j)
                push!(D, (i,j) => M[j,i])
            elseif M[j,i] != 0.
                push!(D, (i,j) => M[i,j]+M[j,i])
            end
        end
    end
    ising_graph(D, sgn)
end

disable_logging(LogLevel(0))

s = ArgParseSettings("description")
  @add_arg_table! s begin
    "file"
    help = "the file name"
    arg_type = String
  end
file = parse_args(s)["file"]
println(file)

data = npzread(file)
number_of_states = minimum([length(data["energies"][1,:]), 150])
examples = length(data["energies"][:,1])
println("examples = ", examples)

β = 3.

for k in 1:examples

    println(" ..................... SAMPLE =  ", k, "  ...................")
    Mat_of_interactions = data["Js"][k,:,:]
    degeneracy = (0. in diag(Mat_of_interactions))

    states_given = 0
    try
        if !degeneracy
            states_given = data["states"][k,:,:]
        end
    catch
        0
    end

    energies_given = data["energies"][k,:,:]

    g = M2graph(Mat_of_interactions, -1)
    grid_size = isqrt(size(Mat_of_interactions, 1))

    ################ exact method ###################

    fg = factor_graph(
        g,
        spectrum=brute_force,
        cluster_assignment_rule=super_square_lattice((grid_size, grid_size, 1))
    )

    control_params = Dict(
       "bond_dim" => typemax(Int),
       "var_tol" => 1E-12,
       "sweeps" => 4.
   )

    peps = PEPSNetwork(grid_size, grid_size, fg, β, :NW, control_params)
    println("size of peps = ", peps.size)
    print("peps time  = ")

    @time sols = low_energy_spectrum(peps, number_of_states + 2)

    for i in 1:number_of_states

        @test sols.energies[i] ≈ energies_given[i]
        if states_given != 0
            f(i) = (i == 2) ? -1 : 1
            @test map(f, sols.states[i]) == states_given[i,:]
        end
    end

    ############### approximated methods  ################
    χ = 2
    χ = typemax(Int)

    control_params = Dict(
       "bond_dim" => χ,
       "var_tol" => 1E-7,
       "sweeps" => 4.
   )

    print("approx peps  ")

    peps = PEPSNetwork(grid_size, grid_size, fg, β, :NW, control_params)

    @time sols_approx = low_energy_spectrum(peps, number_of_states + 2)

    for i in 1:number_of_states

        @test sols_approx.energies[i] ≈ energies_given[i]
        if states_given != 0
            f(i) = (i == 2) ? -1 : 1
            @test map(f, sols_approx.states[i]) == states_given[i,:]
        end
    end

    print("peps larger T")
    s1 = ceil(Int, grid_size/2)

    if grid_size % 2 == 0
        rule = super_square_lattice((s1, 2, s1, 2, 1))
    else
        rule = Dict{Int, Int}(1 => 1, 2 => 1, 6 => 1, 7 => 1)
        push!(rule, (3 => 2), (4 => 2), (8 => 2), (9 => 2), (5 => 3), (10 => 3))
        push!(rule, (11 => 4), (12 => 4), (16 => 4), (17 => 4), (13 => 5), (14 => 5))
        push!(rule, (18 => 5), (19 => 5), (15 => 6), (20 => 6), (21 => 7), (22 => 7))
        push!(rule, (23 => 8), (24 => 8), (25 => 9))
    end

    fg = factor_graph(
        g,
        cluster_assignment_rule=rule,
        spectrum=brute_force,
    )
    peps = PEPSNetwork(s1, s1, fg, β, :NW, control_params)

    println("size of peps = ", peps.size)

    @time sols_large = low_energy_spectrum(peps, number_of_states + 2)

    for i in 1:number_of_states

        @test sols_large.energies[i] ≈ energies_given[i]
        #TODO we need to know how to read states from clusters
        #if states_given != 0
        #    @test sols_large.states[i] == states_given[i,:]
        #end
    end

    print("peps larger T, limited spectrum")
    D = Dict{Int, Int}()
    for v in vertices(g)
        push!(D, (v => 15))
    end
    fg = factor_graph(
        g,
        D,
        cluster_assignment_rule=rule,
        spectrum=brute_force,
    )

    peps = PEPSNetwork(s1, s1, fg, β, :NW, control_params)

    @time sols_spec = low_energy_spectrum(peps, number_of_states+2)

    for i in 1:minimum([number_of_states, 65])
        @test sols_spec.energies[i] ≈ energies_given[i]
        #TODO we need to know how to read states from clusters
        #if states_given != 0
        #    @test sols_spec.states[i] == states_given[i,:]
        #end
    end
end


text:
# dormand prince
struct DormandPrince45 <: AbstractAdaptiveExplicitSolver
end

function order(::DormandPrince45)::Int
    return 5
end

function n_intermediates(::DormandPrince45)
    return 7 # to be checked
end

function n_temporaries(::DormandPrince45)
    return 5
end

function stepper!(ode_solver::DormandPrince45, ode_fcn, stepper_options, stepper_temp::StepperTemporaries)

    # renaming for better readability
    t          = stepper_temp.t_old;
	x          = stepper_temp.x_old;
	dt         = stepper_temp.dt;
    n_prob_dim = n_dim(stepper_temp)

    # views into the temporaries
    k1 = view(stepper_temp.der_x, 1:n_prob_dim, 1)
    k2 = view(stepper_temp.der_x, 1:n_prob_dim, 2)
    k3 = view(stepper_temp.der_x, 1:n_prob_dim, 3)
    k4 = view(stepper_temp.der_x, 1:n_prob_dim, 4)
    k5 = view(stepper_temp.der_x, 1:n_prob_dim, 5)
    k6 = view(stepper_temp.der_x, 1:n_prob_dim, 6)
    k7 = view(stepper_temp.der_x, 1:n_prob_dim, 7)

    x2 = view(stepper_temp.x_tmp, 1:n_prob_dim, 1)
    x3 = view(stepper_temp.x_tmp, 1:n_prob_dim, 2)
    x4 = view(stepper_temp.x_tmp, 1:n_prob_dim, 3)
    x5 = view(stepper_temp.x_tmp, 1:n_prob_dim, 4)
    x6 = view(stepper_temp.x_tmp, 1:n_prob_dim, 5)

    # intermediate steps
	t2 = t + 1/5 * dt
    @. x2 = x + 1/5 * dt * k1
    ode_fcn(k2, t2, x2)

    t3 = t + 3/10 * dt
    @. x3 = x + dt * (3/40 * k1 + 9/40 * k2)
	ode_fcn(k3, t3, x3)

    t4 = t + 4/5 * dt
    @. x4 = x + dt * (44/45 * k1 - 56/15 * k2 + 32/9 * k3)
	ode_fcn(k4, t4, x4)

    t5 = t + 8/9 * dt
    @. x5 = x + dt * (19372/6561 * k1 - 25360/2187 * k2 + 64448/6561 * k3 - 212/729 * k4)
    ode_fcn(k5, t5, x5)

    t6 = t + dt
    @. x6 = x + dt * (9017/3168 * k1 -355/33 * k2 + 46732/5247 * k3 + 49/176 * k4 - 5103/18656 * k5)
    ode_fcn(k6, t6, x6)

    # new step
	stepper_temp.t_new    = t + dt
	@. stepper_temp.x_new = x + dt * (35/384*k1 + 500/1113 * k3 + 125/192 * k4 - 2187/6784* k5 + 11/84 * k6)
	ode_fcn(k7, stepper_temp.t_new, stepper_temp.x_new)

    # error estimation
	@. stepper_temp.x_est = x + dt * (5179/57600 * k1 + 7571/16695 * k3 + 393/640 * k4 - 92097/339200 * k5 + 187/2100 * k6 + 1/40 * k7)

end

max_stars_repo_name: HomoModelicus/julia

max_issues_repo_name: HomoModelicus/julia

max_forks_repo_name: HomoModelicus/julia


text:
module WaveletScattering

using DataStructures
using Mocha

include("domain.jl")
include("group.jl")
include("waveletclass.jl")
include("path.jl")
include("meta.jl")
include("spec.jl")
include("spec1d.jl")
include("spec2d.jl")
include("filter.jl")
include("fourier1dfilter.jl")
include("weighting.jl")
include("behavior.jl")
include("morlet1d.jl")
include("bank.jl")
include("bank1d.jl")
include("bank2d.jl")
include("node.jl")
include("blob.jl")
include("invariant.jl")
include("pointwise.jl")
include("modulus.jl")
include("log1p.jl")
include("pointwise-call.jl")
include("symbols.jl")

# Mocha
include("inputlayer.jl")
include("pointwiselayer.jl")
include("fourierlayer.jl")
include("waveletlayer.jl")
include("invfourierlayer.jl")
include("poolinglayer.jl")
include("scatteringlayer.jl")
include("layerstate.jl")
include("inputlayerstate.jl")
include("pointwiselayerstate.jl")
include("fourierlayerstate.jl")
include("waveletlayerstate.jl")
include("invfourierlayerstate.jl")
include("poolinglayerstate.jl")
include("scatteringlayerstate.jl")

end