text:
"""
    expected_number_of_cluster_2PD(n::N, θ::T, σ::T, ntrunc::N)

Compute the expected number of clusters for a 2-parameter Poisson Dirichlet prior, by direct computation up to ntrunc. If ntrunc = n, this is an exact computation, if it turns out to be too long and that you expect large values of k to have a very small mass, you can set ntrunc < n.

# Examples
```julia-repl
julia> GibbsTypePriors.expected_number_of_cluster_2PD(100, 1.0, 0.1, 50)
[6.66854572439020053533515735851452973224981540358173684266962825487333967458307765332656984810574842651474015538338720078320799873773484654474045662876311930900255401608438351708575902470003695195472950846209930364916574756258195906978792735380469732399701637049873218563662828748041941268348464936340484967657964701446269020409816292488646213414168246181455914819473889600572869116478059869754289011725089446116537699336280040328071818457251209457817657352446105060779361083211752873341183127245705781828124887118172387163760512916480460420221393531464292989217584922021599146160085328610112860589003070634636891323889965306715193866013221311176472638005617254383323549220868258800194958774473369822418060972802272418739639187815136375304624761993600634276521918590366043000203183869628505847657460467697757436062460229633428422536373014978545251585715765523999626897145245442686109681053275710369838774705588337309829622003283045093978444359731445140597337593964250873138081266774967152048772255402727067611679080157130189967995998175559036833194024776309971929261058416278658972582841062606599798273409641275608450341917573868433271832671690077444780385449073553422161933216384683216622982317479233488903563505597263456144403253067578054817554552829561347839958925083869536682307196235440701185373357913481953704617618446181220385427221091372427837808950835111324692924861139724884562284189627629669549533418733062442369593806837235861863804283010342172306883655302995511580660111634 +/- 5.95e-1485]

```
"""

expected_number_of_cluster_2PD(n::N, θ::T, σ::T, ntrunc::N) where {T<:Number, N<:Integer} = Pkn_2PD_arb.(1:ntrunc, n, θ, σ) |> ar -> map(*, ar, 1:ntrunc) |> sum
expected_number_of_cluster_2PD(n::N, θ::T, σ::T) where {T<:Number, N<:Integer} = expected_number_of_cluster_2PD(n, θ, σ, n)

expected_number_of_cluster_stable(n::N, σ::T, ntrunc::N) where {T<:Number, N<:Integer} = expected_number_of_cluster_2PD(n, 0., σ, ntrunc)
expected_number_of_cluster_stable(n, σ) = expected_number_of_cluster_stable(n, σ, n)

function expected_number_of_clusters_Dirichlet(n::Int64, theta::Float64, ntrunc::Int64)
    return Pkn_Dirichlet_arb.(1:ntrunc, n, theta) |> ar -> map(*, ar, 1:ntrunc) |> sum
end

expected_number_of_clusters_Dirichlet(n::Int64, theta::Float64) = expected_number_of_clusters_Dirichlet(n, theta, n)

function expected_number_of_clusters_PD_direct(n::N, θ::T, σ::T)::T where {T<:Number, N<:Integer}
    return (θ/σ)*(prod([(θ + σ + i -1)/(θ + i -1) for i in 1:n]) -1)
end

function variance_number_of_clusters_PD_direct(n::N, θ::T, σ::T)::T where {T<:Number, N<:Integer}
           if n==1
               return 0
           else
               E_prev =  expected_number_of_clusters_PD_direct(n-1, θ, σ)
               add_term  =  (E_prev*((n-1)*σ - θ*σ) + (n-1)*θ -  σ*σ*(E_prev^2))/ (n- 1 + θ)^2
               return    variance_number_of_clusters_PD_direct(n-1, θ, σ)*(n - 1 + θ + 2*σ)/ (n - 1 + θ) + add_term
           end
       end

function expected_number_of_clusters_Dirichlet_direct(n::N, theta::T) where {T<:Number, N<:Integer}
   return sum( RR(theta)// (RR(theta + i)) for i in 0:(n-1))
end

function variance_number_of_clusters_Dirichlet_direct(n::N, theta::T) where {T<:Number, N<:Integer}
   return sum((RR(theta)*RR(i))//((RR(theta +i))^2) for i in 0:(n-1))
end

function expected_number_of_clusters_Dirichlet_Multinomial_direct(n::N, H::N, theta::T) where {T<:Number, N<:Integer}
    return RR(H) - ((RR(H) -1)*exp( log(risingfac(RR(theta + 1) - RR(theta)//RR(H),n-1)) - log(risingfac(RR(theta + 1),n-1))))
end

expected_number_of_clusters_Dirichlet_Multinomial(n::Int64, H::Int64, theta::Float64) = expected_number_of_clusters_Dirichlet_Multinomial_direct(n, H, theta)

function expected_number_of_clusters_NGG(n::Int64, theta::Float64, σ, ntrunc::Int64)
    return Pkn_NGG_robust.(1:ntrunc, n, theta,σ) |> ar -> map(*, ar, 1:ntrunc) |> sum
end

expected_number_of_clusters_NGG(n::Int64, theta::Float64, sigma::Float64) = expected_number_of_clusters_NGG(n, theta, sigma, n)

function expected_number_of_clusters_PYM(n::Int64, H::Int64, theta::Float64, σ, ntrunc::Int64)
    return Pkn_PDM_arb.(1:ntrunc, n,H,  theta,σ) |> ar -> map(*, ar, 1:ntrunc) |> sum
end
expected_number_of_clusters_PYM(n::Int64, H::Int64, theta::Float64, sigma::Float64) = expected_number_of_clusters_PYM(n, H, theta,  sigma, n)

function expected_number_of_clusters_DPM(n::Int64, H::Int64, theta::Float64, ntrunc::Int64)
    return Pkn_Dirichlet_mult_arb.(1:ntrunc, n,H, theta) |> ar -> map(*, ar, 1:ntrunc) |> sum
end

expected_number_of_clusters_DPM(n::Int64,H::Int64, theta::Float64) = expected_number_of_clusters_DPM(n, H, theta, n)

function expected_number_of_clusters_NGGM(n::Int64,H::Int64, theta::Float64, σ, ntrunc::Int64)
    return Pkn_NGGM_arb.(1:ntrunc, n, H, theta,σ ) |> ar -> map(*, ar, 1:ntrunc) |> sum
end

expected_number_of_clusters_NGGM(n::Int64, H::Int64, theta::Float64, sigma::Float64) = expected_number_of_clusters_NGGM(n, H, theta, sigma, n)

function variance_number_of_clusters(n, exp_nk, pk)
    x = ((1:n).-exp_nk).^2
    v_nk= pk |> ar -> map(*, ar, x) |> sum
    return v_nk
end

variance_number_of_clusters_Dirichlet(n::N, theta::T) where {T<:Number, N<:Integer} = variance_number_of_clusters(n, expected_number_of_clusters_Dirichlet(n, theta), Pkn_Dirichlet_arb.(1:n, n, theta))

variance_number_of_clusters_PD(n::N, theta::T, σ::T) where {T<:Number, N<:Integer} = variance_number_of_clusters(n, expected_number_of_cluster_2PD(n, theta, σ, n) , Pkn_2PD_arb.(1:n, n, theta, σ))

variance_number_of_clusters_NGG(n::N, β::T, σ::T) where {T<:Number, N<:Integer} = variance_number_of_clusters(n, expected_number_of_clusters_NGG(n,  β, σ, n) ,  Pkn_NGG_robust.(1:n, n, β, σ; verbose = false))

variance_number_of_clusters_PYM(n::N,  H::N,  theta::T, σ::T) where {T<:Number, N<:Integer} = variance_number_of_clusters(n, expected_number_of_clusters_PYM(n, H, theta, σ, n) , Pkn_PDM_arb.(1:n, n, H, theta, σ))

variance_number_of_clusters_DPM(n::N, H::N,  theta::T) where {T<:Number, N<:Integer} = variance_number_of_clusters(n, expected_number_of_clusters_DPM(n, H, theta, n) , Pkn_Dirichlet_mult_arb.(1:n, n, H, theta))

variance_number_of_clusters_NGGM(n::N, H::N, β::T, σ::T) where {T<:Number, N<:Integer} = variance_number_of_clusters(n, expected_number_of_clusters_NGGM(n,H,  β, σ, n) , Pkn_NGGM_arb.(1:n, n,H, β, σ))

#aliases

"""
    E_2PD(n::N, θ::T, σ::T, ntrunc::N) where {T<:Number, N<:Integer}

Compute the expected number of clusters for a 2-parameter Poisson Dirichlet (also known as Pitman-Yor) prior, by direct computation up to ntrunc (optional argument). If ntrunc = n, this is an exact computation, if it turns out to be too long and that you expect large values of k to have a very small mass, you can set ntrunc < n.

See also: [`E_stable`](@ref), [`E_Dirichlet`](@ref)

# Examples
```julia-repl
julia> E_2PD(10, 0., 0.4)
[2.797180108800000146227991769541811614624157201057103170680445069708107636422615452406497920159297853634382963614055479173158069186418337497999385184360757154429265052398107259805621680470326929725738226729222577234589857779643629658552208848284173508026015152904404059960898279167641852826517393043262627617296658490156505882278711266617066316092443733068941404176241441191328628518109412653612525798394207094225161730723863943059051559749653061842655787927469646092504262924194335937500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +/- 5.60e-1504]

```
"""
E_2PD = expected_number_of_cluster_2PD
"""
    E_PY(n::N, θ::T, σ::T, ntrunc::N) where {T<:Number, N<:Integer}

Compute the expected number of clusters for a 2-parameter Poisson Dirichlet (also known as Pitman-Yor) prior, by direct computation up to ntrunc (optional argument). If ntrunc = n, this is an exact computation, if it turns out to be too long and that you expect large values of k to have a very small mass, you can set ntrunc < n.

See also: [`E_stable`](@ref), [`E_Dirichlet`](@ref)

# Examples
```julia-repl
julia> E_PY(10, 0., 0.4)
[2.797180108800000146227991769541811614624157201057103170680445069708107636422615452406497920159297853634382963614055479173158069186418337497999385184360757154429265052398107259805621680470326929725738226729222577234589857779643629658552208848284173508026015152904404059960898279167641852826517393043262627617296658490156505882278711266617066316092443733068941404176241441191328628518109412653612525798394207094225161730723863943059051559749653061842655787927469646092504262924194335937500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +/- 5.60e-1504]
```
"""
E_PY = expected_number_of_cluster_2PD

"""
    E_stable(n::N, σ::T, ntrunc::N) where {T<:Number, N<:Integer}

Compute the expected number of clusters for a stable process prior, by direct computation up to ntrunc (optional argument). If ntrunc = n, this is an exact computation, if it turns out to be too long and that you expect large values of k to have a very small mass, you can set ntrunc < n.

See also: [`E_2PD`](@ref), [`E_PY`](@ref), [`E_Dirichlet`](@ref)

# Examples
```julia-repl
julia> E_stable(10, 0.1)
[1.317283550395312519640862117090075082018602293487207173467704662870901710848586072338941448910368160445217137507034833714840735500227050610150306349069777704715852016445662205119280375270463908555026018111545594765430207866848367807193962524362807035164072216472928669667852836537566353834476540485547750703723020476001586935706322137304949274062823739150683831653442615917431013917124081952539061271081947740823646018757470139485514508444060324299094553588058194998344774262477585580199956893920898437500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +/- 3.11e-1504]
```
"""
E_stable = expected_number_of_cluster_stable

"""
    E_Dirichlet(n::Int64, theta::Float64, ntrunc::Int64) where {T<:Number, N<:Integer}

Compute the expected number of clusters for a Dirichlet process prior, by direct computation up to ntrunc (optional argument). If ntrunc = n, this is an exact computation, if it turns out to be too long and that you expect large values of k to have a very small mass, you can set ntrunc < n.

See also: [`E_2PD`](@ref), [`E_PY`](@ref), [`E_Dirichlet`](@ref)

# Examples
```julia-repl
julia> E_Dirichlet(10, 0.1)
[1.268596929750522509742103226956398537873085771068571987249592902594795125483947571993880681026641323980721322458062759352392652070330423992468334489803280561487543428122167951021050245266305309523058564612943664653252207376397838984299562945184833920280935894433175454443126982970639290683556142832194488231242118732857777980590412149473759072393894727632777788161259891977237151762150827584780251361172323905738003873059388785341902756850617870450223561134319542176310553349557774240878171574220754051744934444300894535698176817305606825219444113035080791544948019245009777904858615486457170596230701700442717181550577165517662854019961542802495771529879961515496294626049466523909595586762943163930430217545909261330315605742950990173838708604216021274909891705176168468804148449172143254354356340463428016703770246922776019535931638474836624991339643912739739155983869915380851777840945184932873827598663416040011548041974534069037590952150058854019536415499847894848546456328154482639606353077562701342572112539079860044162733170338151051198333830112116544872721287500485113210068274289193032913781410170370106620574401702474340286414131137704367213615618055699430142941143725875436243075702238831256061567411589207476227140330551796033541896922138410130961176340540611096374126740677494288946208178976360070364810387616678096999963421007697822481144326548283583125899364975944100495982998923214048037871138961099375953420318323202550711433054734568046848016758259884095392920728021289115618089199446 +/- 3.29e-1504]
```
"""
E_Dirichlet = expected_number_of_clusters_Dirichlet

"""
E_Dirichlet_multinomial(n::Int64, H::Int64, theta::Float64)

Compute the expected number of clusters for a Dirichlet multinomial process prior, by direct computation.

See also: [`E_2PD`](@ref), [`E_PY`](@ref), [`E_Dirichlet`](@ref)

# Examples
```julia-repl
julia> E_Dirichlet_multinomial(10, 100, 0.1)
[1.2656198162956772044281139501986927560433432728249122838425730172917885456449577827427008029228648259324405450086120700424973872000807961506603125307279025537242800655018045456602670686498182692474826633664464115235080215898472900952036550627041716785370528159699434712650478858211550875546889849261932677562210539024382120856358213274564755169450936766976570333960375938859697028794265405113640006664727462826608028138839169641099450481107571846157530356973423234055102728639482073500720704136233393619357481270310535710377065205775169940077201221510804987245517636551404267972023813211580038972156633810136183697393064520817775221063908711964263522664950624308457120306025925387379275923942136270897436033458705818234588085139913056512529232468622444652256833999355158680011588243488293212125219256186831657014880823083507939645291608505348675502280911274616411712947835536355953711660880159199373720426086123356305436213390603071455111185650982260902472122664033660119541657216813260172107093430967366682626224504543299165643378000241500081885141581110118882802768709028242369726903819960113281002024998943691846080945815486592637086008328168328728610378061578868271472321782307974248638152860658274353781599750807686673500116117928362282072347758716494140304291667565972106364885408051864566662844174074858554185933039304044771000481636810876029924186732368911110789843512235516072634447141633207673761126531255242098046844231863703453219915420808518114669566034153258871751844111589780197562620084 +/- 3.81e-1502]
```
"""
E_Dirichlet_multinomial = expected_number_of_clusters_Dirichlet_Multinomial

"""
   E_NGG(n::Int64, beta::Float64, sigma::Float64)
Compute the expected number of clusters for a Normalized generalized gamma process prior.
See also: [`E_2PD`](@ref), [`E_PY`](@ref), [`E_Dirichlet`](@ref)
# Examples
```julia-repl
julia> E_NGG(10, 1.0, 0.1)
[1.379200522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951 +/- 4.01e-1504]
```
"""
E_NGG =expected_number_of_clusters_NGG

"""
   E_PYM(n::Int64, beta::Float64, sigma::Float64)
Compute the expected number of clusters for a Pitman-Yor multinomial process prior.
See also: [`E_2PD`](@ref), [`E_PY`](@ref), [`E_Dirichlet`](@ref)
# Examples
```julia-repl
julia> E_PYM(10, 1.0, 0.1)
[1.379200522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951 +/- 4.01e-1504]
```
"""
E_PYM =expected_number_of_clusters_PYM

"""
   V_PY(n::Int64, theta::Float64, sigma::Float64)
Compute the variance for the number of clusters for σ, by recursion.
See also: [`E_2PD`](@ref), [`E_PY`](@ref), [`E_Dirichlet`](@ref)
# Examples
```julia-repl
julia> V_PY(10, 1.0, 0.2)
2.2826090179905956
```
"""

V_PY  = variance_number_of_clusters_PD_direct

"""
   V_Dirichlet(n::Int64, theta::Float64)
Compute the variance for the number of clusters for Dirichlet process prior.
See also: [`E_2PD`](@ref), [`E_PY`](@ref), [`E_Dirichlet`](@ref)
# Examples
```julia-repl
julia> V_Dirichlet(10, 1.0)
[1.379200522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951 +/- 4.01e-1504]
```
"""

V_Dirichlet  = variance_number_of_clusters_Dirichlet_direct

"""
   V_NGG(n::Int64, beta::Float64, sigma::Float64)
Compute the variance for the number of clusters for Normalized generalized gamma process prior.
See also: [`E_2PD`](@ref), [`E_PY`](@ref), [`E_Dirichlet`](@ref)
# Examples
```julia-repl
julia> V_NGG(10, 1.0, 0.1)
[1.379200522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951373141849332325522801713277903754094230284706475182665658856135046611237087427563618039808515998992189468379944570420760896951 +/- 4.01e-1504]
```
"""
V_NGG = variance_number_of_clusters_NGG

variance_number_of_clusters_NGG(n::N, beta::T, sigma::T) where {T<:Number, N<:Integer} = variance_number_of_clusters(n, expected_number_of_clusters_NGG(n,  beta, sigma, n) ,  Pkn_NGG_robust.(1:n, n, beta, sigma; verbose = false))

variance_number_of_clusters_PYM(n::N, theta::T, σ::T) where {T<:Number, N<:Integer} = variance_number_of_clusters(n, expected_number_of_clusters_PYM(n, theta, σ, n) , Pkn_PDM_arb.(1:n, n, theta, σ))

variance_number_of_clusters_DPM(n::N, theta::T) where {T<:Number, N<:Integer} = variance_number_of_clusters(n, expected_number_of_clusters_DPM(n, theta, n) , Pkn_Dirichlet_mult_arb.(1:n, n, theta))

variance_number_of_clusters_NGGM(n::N, beta::T, sigma::T) where {T<:Number, N<:Integer} = variance_number_of_clusters(n, Pkn_NGGM_arb(n, beta, sigma, n) , Pkn_NGGM_arb.(1:n, n, beta, sigma))

max_stars_repo_name: konkam/GibbsTypePriors

max_issues_repo_name: konkam/GibbsTypePriors

max_forks_repo_name: konkam/GibbsTypePriors


text:
function rm_trd_loess(
    x::Neuro1DRealSignal;
    span::Float64 = 0.75)::Neuro1DRealSignal

    x_ = copy(x)
    r, c = size(x_)
    idx = convert(Vector{Float64}, [1:1:r; ])

    for i = 1:c
        c_loess = loess(idx, x_[:, i], span = span)
        c_trend = Loess.predict(c_loess, idx)

        x_[:, i] = x_[:, i] .- c_trend
    end

    Neuro1DRealSignal(
        signal = x_,
        sample_rate = x.sample_rate
    )
end

function rm_trd_linear(x::Neuro1DRealSignal)::Neuro1DRealSignal
    r, c = size(x.signal)
    idx = convert(Vector{Float64}, [1:1:r; ])

    βs = cov(x.signal, idx) ./ var(idx)

    Neuro1DRealSignal(
        signal = x.signal - idx * βs',
        sample_rate = x.sample_rate
    )
end

function rm_trd(
    x::Neuro1DRealSignal,
    method = :loess;
    kwargs...)::Neuro1DRealSignal

    if method == :loess
        rm_trd_loess(x; kwargs...)
    elseif method == :linear
        rm_trd_linear(x)
    else
        throw(ArgumentError("invalid method"))
    end
end

ext: jl


text:
#-------------poor-julia.jl----------------------------------------------------#
#
# Purpose: This code is supposed to be slow in julia
#
#------------------------------------------------------------------------------#

type Loc
    x::Array{Float64}
    y::Array{Float64}
end

num = 1000
rad = 1

# this integrates the area of a circle
pos = Loc([0.0],[0.0])
count = 0
for i = 1:num
    push!(pos.x, rand())
    push!(pos.y, rand())
    if (pos.x[i] * pos.x[i] + pos.y[i] * pos.y[i] < rad*rad)
        count += 1.0
    end
end

println("The area of your circle is: ", (count / num) * rad*rad*4)

max_stars_repo_name: vchuravy/skillpill-julia

max_issues_repo_name: oist/skillpill-julia

max_forks_repo_name: oist/skillpill-julia


text:
using Pkg
tempdir = mktempdir()
Pkg.activate(tempdir)
Pkg.develop(PackageSpec(path=joinpath(@__DIR__, "..")))
Pkg.add(["BenchmarkTools", "SCS", "ECOS", "PkgBenchmark"])
Pkg.resolve()

using Convex: Convex
using SCS: SCSSolver
using ECOS: ECOSSolver
using BenchmarkTools

include("benchmarks/benchmarks.jl") # defines module Benchmarks

const SUITE = BenchmarkGroup()

SUITE["SCS"] = Benchmarks.suite(p -> Convex.solve!(p, SCSSolver(verbose=0)))
SUITE["ECOS"] = Benchmarks.suite(p -> Convex.solve!(p, ECOSSolver(verbose=0));
    exclude = [r"sdp", r"SDP"])
SUITE["formulation"] = Benchmarks.suite(Convex.conic_problem)


text:
using MultivariatePolynomials
using DynamicPolynomials
using SemialgebraicSets
using JuMP

import MultivariateMoments.moment_matrix
import SemialgebraicSets.inequalities

# Pirates an AlgebraicSet as a workaround for a design problem.
function SemialgebraicSets.inequalities(::AlgebraicSet)
	[]
end

struct Moments
        maxdegree::Integer
        domain::AbstractSemialgebraicSet
end
struct MomentsVar{T}
        maxdegree::Integer
        pvars::Vector{PolyVar{T}}
        mvars::AbstractArray{VariableRef,1}
        model
end
function JuMP.build_variable(_error, info, s::Moments; extra_kw_args...)
        return s
end

"""
Creates truncated moment matrices M_t(μ), and localizing matrices M_t(gμ),
where _g_ is a polynomial-like type, _μ_ is a measure, and _t_ is an integer.

Lasserre, Jean-Bernard. (2004). Global Optimization With Polynomials And The
Problem Of Moments. SIAM Journal on Optimization. 11. 10.1137/S1052623400366802.
"""
function moment_matrix(m::MomentsVar)
	ys = reverse(monomials(m.pvars, 0:m.maxdegree÷2))
	MomentMatrix(value.(linearize.(m, ys * ys')), ys)
end
function moment_matrix(m::MomentsVar, t::Integer)
	ys = reverse(monomials(m.pvars, 0:t÷2))
	linearize.(m, ys * ys')
end
function moment_matrix(m::MomentsVar, t::Integer, g::Polynomial)
	round_up_even(i::Integer) = (i + 1) & ~(1)
	tg = round_up_even(maxdegree(g))
	ys = reverse(monomials(m.pvars, 0:t÷2-tg÷2))
	linearize.(m, ys * ys' * g)
end

function JuMP.add_variable(model, s::Moments, name::String)
        pvars = variables(s.domain)
        monos = monomials(pvars, 0:s.maxdegree)
        mvars = @variable(model, [monos], base_name = name)
        mseq = MomentsVar(s.maxdegree, pvars, mvars, model)

        Mt = moment_matrix(mseq, s.maxdegree)
        Mi = moment_matrix.(mseq, s.maxdegree, inequalities(s.domain))
        Me = moment_matrix.(mseq, s.maxdegree, equalities(s.domain))

        @constraint(model, mvars[end] == 1)
        @constraint(model, Mt in PSDCone())
        @constraint(model, [i in Mi], i in PSDCone())
        @constraint(model, [i in Me], i .== zero(i))

        return mseq
end

"""
Computes the expectation of a polynomial-like type with respect to a truncated
moment sequence.
"""
linearize(m::MomentsVar, t::Term) = coefficient(t) * linearize(m, monomial(t))
linearize(m::MomentsVar, t::Polynomial) = sum(linearize.(m, terms(t)))
function linearize(m::MomentsVar, mono::Monomial)
	# workaround DynamicPolynomials' type instability

        if m.pvars == variables(mono)
                m.mvars[mono]
        else
                x = m.pvars
                ty = subs(mono, x => ones(length(x)))
                y = variables(ty)
                tx = subs(mono, y => ones(length(y)))

                ty * m.mvars[tx]
        end
end

Base.broadcastable(x::MomentsVar) = Ref(x)


text:
module Sampling
    using ArrayViews

    import Base: getindex, length, show, rand, rand!

    export

    # samplebase
    VariateForm, Univariate, Multivariate, Matrixvariate,
    ValueSupport, Discrete, Continuous,
    Sampleable,

    # randi
    RandIntSampler, randi,

    # categorical
    AliasTable, numcategories,

    # binomial
    BinomialGeomSampler, BinomialTPESampler, BinomialPolySampler,
    BinomialAliasSampler,

    # poisson
    PoissonCountSampler, PoissonADSampler,

    # exponential
    ExponentialSampler, randexp,

    # gamma
    GammaMTSampler

    # source files
    include("samplebase.jl")
    include("randi.jl")
    include("categorical.jl")
    include("binomial.jl")
    include("exponential.jl")
    include("gamma.jl")
    include("poisson.jl")

end # module


text:
function lerp(x::Real, lo::Real, hi::Real)
    return hi*x + (1-x)*lo
end

function transform_domain(x::Vector)
    ϵ   = eps(Float64)
    res = clamp.(x, ϵ, 1-ϵ)

    i = 1
    res[i]   = 2^lerp(x[i],   -6, 2.0)  # Δt
    res[i+1] = 2^lerp(x[i+1], -7, 0.0)  # ρ
    res[i+2] = lerp(x[i+2],   2, 8)    # niters
    i += 3

    res[i]   = 2^lerp(x[i],   -6, 2.0) # Δt
    res[i+1] = 2^lerp(x[i+1], -7, 0.0) # ρ
    res[i+2] = lerp(x[i+2],    2, 8)   # niters
    res[i+3] = 2^lerp(x[i+3], -6, 4)   # σ
    res[i+4] = lerp(x[i+4],    0, 1)   # α
    res[i+5] = lerp(x[i+5],    1, 2)   # β
    i += 6

    res[i]   = 2^lerp(x[i],   -6, 2.0) # Δt
    res[i+1] = 2^lerp(x[i+1], -7, 0.0) # ρ
    res[i+2] = lerp(x[i+2],    2, 9)   # niters
    res[i+3] = 2^lerp(x[i+3], -6, 4)   # σ
    res[i+4] = lerp(x[i+4],    0, 1)   # α
    res[i+5] = lerp(x[i+5],    1, 2)   # β
    i += 6

    res[i]   = 2^lerp(x[i],   -6, 2.0) # Δt
    res[i+1] = 2^lerp(x[i+1], -7, 0.0) # ρ
    res[i+2] = lerp(x[i+2],    2, 8)   # niters
    res[i+3] = 2^lerp(x[i+3], -6, 4)   # σ
    res[i+4] = lerp(x[i+4],    0, 1)   # α
    res[i+5] = lerp(x[i+5],    1, 2)   # β
    i += 6

    res
end

function reduce_speckle(img, θ)
    M = size(img, 1)
    N = size(img, 2)

    M_pad = 2^4 * ceil(Int, M / 2^4)
    N_pad = 2^4 * ceil(Int, N / 2^4)

    img_pad           = zeros(Float32, M_pad, N_pad)
    img_pad[1:M, 1:N] = img

    device = CUDA.CuDevice(0)
    factor = 2
    pyr    = Images.gaussian_pyramid(img_pad, 4, factor, Float32(16.0))
    pyr    = laplacian_pyramid(pyr, factor)
    i      = 1

    x      = srad(CUDA.CuArray(pyr[1]), θ[i], θ[i+1], floor(Int, θ[i+2]); device=device)
    i     += 3

    x      = srad(CUDA.CuArray(pyr[2]), θ[i], θ[i+1], floor(Int, θ[i+2]); device=device)
    pyr[2] = homo_contrast(x, θ[i+3], θ[i+4], θ[i+5]; device=device)
    i     += 6

    x      = srad(CUDA.CuArray(pyr[3]), θ[i], θ[i+1], floor(Int, θ[i+2]); device=device)
    pyr[3] = homo_contrast(x, θ[i+3], θ[i+4], θ[i+5]; device=device)
    i     += 6

    x      = srad(CUDA.CuArray(pyr[4]), θ[i], θ[i+1], floor(Int, θ[i+2]); device=device)
    pyr[4] = homo_contrast(x, θ[i+3], θ[i+4], θ[i+5]; device=device)

    img_pad = synthesize_pyramid(pyr, 2)
    img     = img_pad[1:M, 1:N]
    img     = img / maximum(img)
    img     = clamp.(img, Float32(0.0), Float32(1.0))

    img[isnan.(img)] .= 0.0
    img
end


text:
module PowSysMod

using MathProgComplex
using JuMP
using MAT
using LightXML

include("PowSysMod_body.jl")

export load_OPFproblems
export introduce_Sgenvariables!
export build_Problem!
export build_globalpb!
export pb_cplx2real
export get_JuMP_cartesian_model
export write_solutions
export read_solution_point_GOC
export cplx2real
export Point
export add_coord!
export MatpowerInput, MatpowerSimpleInput, IIDMInput, GOCInput

end


text:
#
# This file is a part of MolecularGraph.jl
# Licensed under the MIT License http://opensource.org/licenses/MIT
#

export
    SvgCanvas,
    tosvg,
    drawsvg,
    initcanvas!

using Printf

mutable struct SvgCanvas <: Canvas
    fontweight::String
    fontfamily::String
    fontsize::Float64
    bgcolor::Color
    opacity::Float64

    mbwidthf::Float64
    wedgewidthf::Float64
    wavewidthf::Float64
    triminnerf::Float64
    trimoverlapf::Float64
    annotsizef::Float64
    scalef::Float64
    paddingX::Float64
    paddingY::Float64

    viewboxW::Float64
    viewboxH::Float64

    bgelements::Vector{String}
    elements::Vector{String}
    coords::Matrix{Float64}
    valid::Bool

    function SvgCanvas()
        canvas = new()
        canvas.fontweight = "normal"
        canvas.fontfamily = "Helvetica"
        canvas.fontsize = 14.0
        canvas.bgcolor = Color(255.0, 255.0, 255.0)
        canvas.opacity = 0.0

        canvas.mbwidthf = 0.15
        canvas.wedgewidthf = 0.3
        canvas.wavewidthf = 0.2
        canvas.triminnerf = 0.2
        canvas.trimoverlapf = 0.3
        canvas.annotsizef = 0.7
        canvas.scalef = 30.0 # suitable for fontsize=14 and default line width
        canvas.paddingX = 30.0
        canvas.paddingY = 30.0

        canvas.bgelements = []
        canvas.elements = []
        canvas.valid = false
        return canvas
    end
end

svgcolor(c::Color) = @sprintf "rgb(%d, %d, %d)" c.r c.g c.b
svgcoords(p::Point2D) = @sprintf "x=\"%.2f\" y=\"%.2f\"" p.x p.y
svgcirclecoords(p::Point2D) = @sprintf "cx=\"%.2f\" cy=\"%.2f\"" p.x p.y
svgcoords(s::Segment
    ) = @sprintf "x1=\"%.2f\" y1=\"%.2f\" x2=\"%.2f\" y2=\"%.2f\"" s.u.x s.u.y s.v.x s.v.y
svgtransform(tf::Array{Float64,2}
    ) = @sprintf "%.2f %.2f %.2f %.2f %.2f %.2f" tf[1] tf[2] tf[4] tf[5] tf[7] tf[8]

function tosvg(canvas::Canvas, width::Int, height::Int)
    vbWf = @sprintf "%.2f" canvas.viewboxW
    vbHf = @sprintf "%.2f" canvas.viewboxH
    bgc = svgcolor(canvas.bgcolor)
    header = """<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     version="1.2" baseProfile="tiny"
     text-rendering="geometricPrecision"
     preserveAspectRatio="xMidYMid meet"
     font-weight="$(canvas.fontweight)"
     font-family="$(canvas.fontfamily)"
     width="$(width)" height="$(height)"
     viewBox="0 0 $(vbWf) $(vbHf)">
    """
    bg = """<rect x="0" y="0" width="$(vbWf)" height="$(vbHf)"
     fill="$(bgc)" opacity="$(canvas.opacity)"/>
    """
    endsvg = "</svg>\n"
    return join([header, bg, canvas.bgelements..., canvas.elements..., endsvg], "")
end

"""
    drawsvg(mol::GraphMol, width::Int, height::Int)

Generate molecular structure image as a SVG format string.

`width` and `height` specifies the size of the image (width and height
attribute of svg tag).
"""
function drawsvg(mol::UndirectedGraph, width::Int, height::Int; kwargs...)
    canvas = SvgCanvas()
    draw2d!(canvas, mol; kwargs...)
    if haskey(kwargs, :highlight)
        sethighlight!(canvas, kwargs[:highlight])
    end
    if haskey(kwargs, :atomindex) && kwargs[:atomindex]
        drawatomindex!(canvas, mol)
    end
    return tosvg(canvas, width, height)
end

"""
    boundary(mol::GraphMol, coords::AbstractArray{Float64}
        ) -> (top, left, width, height, unit)

Get boundaries and an appropriate bond length unit for the molecule drawing
canvas.
"""
function boundary(mol::GraphMol, coords::AbstractArray{Float64})
    (left, right) = extrema(x_components(coords))
    (bottom, top) = extrema(y_components(coords))
    width = right - left
    height = top - bottom
    dists = []
    # Size unit
    for (u, v) in edgesiter(mol)
        d = Geometry.distance(Point2D(coords, u), Point2D(coords, v))
        if d > 0.0001  # Remove overlapped
            push!(dists, d)
        end
    end
    if isempty(dists)
        long = max(width, height)
        unit = long > 0.0001 ? long / sqrt(nodecount(mol)) : 1
    else
        unit = median(dists) # Median bond length
    end
    return (top, left, width, height, unit)
end

boundary(view::SubgraphView, coords::AbstractArray{Float64}
    ) = boundary(view.graph, coords)

"""
    initcanvas!(canvas::Canvas, coords::AbstractArray{Float64}, boundary::Tuple)

Move and adjust the size of the molecule for drawing.
"""
function initcanvas!(
        canvas::Canvas, coords::AbstractArray{Float64}, boundary::Tuple)
    isempty(coords) && return
    (top, left, width, height, unit) = boundary
    sf = canvas.scalef / unit
    pd = [canvas.paddingX canvas.paddingY]
    canvas.coords = (coords .- [left top]) .* [1 -1] .* sf .+ pd
    canvas.viewboxW = width * sf + canvas.paddingX * 2
    canvas.viewboxH = height * sf + canvas.paddingY * 2
    canvas.valid = true
    return
end

function trimbond(canvas, seg, uvis, vvis)
    if uvis && vvis
        return trim_uv(seg, canvas.trimoverlapf * 2)
    elseif uvis
        return trim_u(seg, canvas.trimoverlapf)
    elseif vvis
        return trim_v(seg, canvas.trimoverlapf)
    end
    return seg
end

function singlebond!(canvas, seg, ucolor, vcolor, uvis, vvis)
    seg_ = trimbond(canvas, seg, uvis, vvis)
    drawline!(canvas, seg_, ucolor, vcolor)
    return
end

function wedged!(canvas, seg, ucolor, vcolor, uvis, vvis)
    seg_ = trimbond(canvas, seg, uvis, vvis)
    drawwedge!(canvas, seg_, ucolor, vcolor)
    return
end

function dashedwedged!(canvas, seg, ucolor, vcolor, uvis, vvis)
    seg_ = trimbond(canvas, seg, uvis, vvis)
    drawdashedwedge!(canvas, seg_, ucolor, vcolor)
    return
end

function wavesingle!(canvas, seg, ucolor, vcolor, uvis, vvis)
    seg_ = trimbond(canvas, seg, uvis, vvis)
    drawwave!(canvas, seg_, ucolor, vcolor)
    return
end

function doublebond!(canvas, seg, ucolor, vcolor, uvis, vvis)
    dist = canvas.scalef * canvas.mbwidthf / 2
    seg_ = trimbond(canvas, seg, uvis, vvis)
    seg1 = translate(seg_, pi / 2, dist)
    seg2 = translate(seg_, -pi / 2, dist)
    drawline!(canvas, seg1, ucolor, vcolor)
    drawline!(canvas, seg2, ucolor, vcolor)
    return
end

function crossdouble!(canvas, seg, ucolor, vcolor, uvis, vvis)
    dist = canvas.scalef * canvas.mbwidthf / 2
    seg_ = trimbond(canvas, seg, uvis, vvis)
    cw = translate(seg_, pi / 2, dist)
    ccw = translate(seg_, -pi / 2, dist)
    drawline!(canvas, Segment(cw.u, ccw.v), ucolor, vcolor)
    drawline!(canvas, Segment(ccw.u, cw.v), ucolor, vcolor)
    return
end

function ringdouble!(canvas, seg, ucolor, vcolor, uvis, vvis, direction)
    seg_ = trimbond(canvas, seg, uvis, vvis)
    dist = canvas.scalef * canvas.mbwidthf
    segin = trim_uv(translate(seg_, direction, dist), canvas.triminnerf)
    drawline!(canvas, seg_, ucolor, vcolor)
    drawline!(canvas, segin, ucolor, vcolor)
    return
end

# NOTE: the direction is reversed due to x-axis reflection
clockwisedouble!(canvas, seg, ucolor, vcolor, uvis, vvis
    ) = ringdouble!(canvas, seg, ucolor, vcolor, uvis, vvis, pi / 2)
counterdouble!(canvas, seg, ucolor, vcolor, uvis, vvis
    ) = ringdouble!(canvas, seg, ucolor, vcolor, uvis, vvis, -pi / 2)

function triplebond!(canvas, seg, ucolor, vcolor, uvis, vvis)
    dist = canvas.scalef * canvas.mbwidthf
    seg_ = trimbond(canvas, seg, uvis, vvis)
    seg1 = translate(seg_, pi / 2, dist)
    seg2 = translate(seg_, -pi / 2, dist)
    drawline!(canvas, seg_, ucolor, vcolor)
    drawline!(canvas, seg1, ucolor, vcolor)
    drawline!(canvas, seg2, ucolor, vcolor)
    return
end

const BOND_DRAWER = Dict(
    1 => Dict(
        0 => singlebond!,
        1 => wedged!,
        6 => dashedwedged!,
        4 => wavesingle!
    ),
    2 => Dict(
        0 => clockwisedouble!,
        1 => counterdouble!,
        2 => doublebond!,
        3 => crossdouble!
    ),
    3 => Dict(
        0 => triplebond!
    )
)

setbond!(
    canvas, order, notation, seg, ucolor, vcolor, uvis, vvis
) = BOND_DRAWER[order][notation](canvas, seg, ucolor, vcolor, uvis, vvis)

function setbondhighlight!(canvas, seg, color)
    cds = svgcoords(seg)
    c = svgcolor(color)
    elem = """<line $(cds) stroke="$(c)" stroke-width="10" stroke-linecap="round"/>
    """
    push!(canvas.bgelements, elem)
    return
end

function atomsymbol!(canvas, pos, atomsymbol, color, implicith, charge;
                     direction=:right, anchor=""" text-anchor="end" """,
                     xoffset=0)
    xy = svgcoords(pos + (xoffset, canvas.fontsize/2))
    small = round(Int, canvas.fontsize * 0.7)
    content = atommarkup(
        atomsymbol, charge, implicith, direction,
        """<tspan baseline-shift="-25%" font-size="$(small)">""", "</tspan>",
        """<tspan baseline-shift="50%" font-size="$(small)">""", "</tspan>"
    )
    c = svgcolor(color)
    elem = """<text $(xy) font-size="$(canvas.fontsize)"
     fill="$(c)"$(anchor)>$(content)</text>
    """
    push!(canvas.elements, elem)
    return
end

setatomright!(canvas, pos, sym, color, hcnt, charge) = atomsymbol!(
    canvas, pos, sym, color, hcnt, charge,
    direction=:left, xoffset=canvas.fontsize/2
)

setatomcenter!(canvas, pos, sym, color, hcnt, charge) = atomsymbol!(
    canvas, pos, sym, color, hcnt, charge, anchor=""" text-anchor="middle" """)

setatomleft!(canvas, pos, sym, color, hcnt, charge) = atomsymbol!(
    canvas, pos, sym, color, hcnt, charge,
    anchor=" ", xoffset=canvas.fontsize/-2
)

function setatomnote!(canvas, pos, text, color, bgcolor)
    size = round(Int, canvas.fontsize * canvas.annotsizef)
    bxy = svgcoords(pos)
    txy = svgcoords(pos + (0, size))
    c = svgcolor(color)
    bc = svgcolor(bgcolor)
    elem = """<g>
     <rect $(bxy) width="$(size)" height="$(size)" rx="$(size/2)" ry="$(size/2)" fill="$(bc)" />
     <text $(txy) font-size="$(size)" fill="$(c)">$(text)</text>
    </g>
    """
    push!(canvas.elements, elem)
    return
end

function setatomhighlight!(canvas, pos, color)
    size = round(Int, canvas.fontsize * 1.2)
    xy = svgcoords(pos - (size / 2, size / 2))
    c = svgcolor(color)
    elem = """
     <rect $(xy) width="$(size)" height="$(size)" rx="$(size/2)" ry="$(size/2)" fill="$(c)" />
    """
    push!(canvas.bgelements, elem)
    return
end

function drawline!(canvas, seg, color; isdashed=false)
    option = isdashed ? """ stroke-dasharray="10,10" """ : " "
    coords = svgcoords(seg)
    c = svgcolor(color)
    elem = """<line $(coords) stroke="$(c)"$(option)/>"""
    push!(canvas.elements, elem)
    return
end

function drawline!(canvas, seg, ucolor, vcolor; isdashed=false)
    ucolor == vcolor && return drawline!(canvas, seg, ucolor, isdashed=isdashed)
    option = isdashed ? """ stroke-dasharray="10,10" """ : " "
    mid = midpoint(seg)
    coords1 = svgcoords(Segment(seg.u, mid))
    coords2 = svgcoords(Segment(mid, seg.v))
    uc = svgcolor(ucolor)
    vc = svgcolor(vcolor)
    elem = """<line $(coords1) stroke="$(uc)"$(option)/>
    <line $(coords2) stroke="$(vc)"$(option)/>
    """
    push!(canvas.elements, elem)
    return
end

drawdashedline!(canvas, seg, ucolor, vcolor) = drawline!(
    canvas, seg, ucolor, vcolor, isdashed=true)

function drawwedge!(canvas, seg, color)
    """ u ◀ v """
    d = Geometry.distance(seg)
    scalef = Point2D(d, d / 2 * canvas.wedgewidthf)
    rotatef = unitvector(seg)
    translf = seg.u
    svgtf = svgtransform(transformmatrix(scalef, rotatef, translf))
    c = svgcolor(color)
    elem = """<polygon points="0,0 1,1 1,-1" fill="$(c)" transform="matrix($(svgtf))"/>
    """
    push!(canvas.elements, elem)
    return
end

function drawwedge!(canvas, seg, ucolor, vcolor)
    """ u ◀ v """
    ucolor == vcolor && return drawwedge!(canvas, seg, ucolor)
    d = Geometry.distance(seg)
    scalef = Point2D(d, d / 2 * canvas.wedgewidthf)
    rotatef = unitvector(seg)
    translf = seg.u
    svgtf = svgtransform(transformmatrix(scalef, rotatef, translf))
    uc = svgcolor(ucolor)
    vc = svgcolor(vcolor)
    elem = """<g stroke-width="0.3" transform="matrix($(svgtf))">
     <polygon points="0,0 0.5,-0.5 0.5,0.5" fill="$(uc)"/>
     <polygon points="0.5,-0.5 0.5,0.5 1,1 1,-1" fill="$(vc)"/>
     </g>
    """
    push!(canvas.elements, elem)
    return
end

function drawdashedwedge!(canvas, seg, color)
    """ u ◁ v """
    d = Geometry.distance(seg)
    scalef = Point2D(d / 7, d / 14 * canvas.wedgewidthf)
    rotatef = unitvector(seg)
    translf = seg.u
    svgtf = svgtransform(transformmatrix(scalef, rotatef, translf))
    c = svgcolor(color)
    elem = """<g stroke="$(c)" stroke-width="0.3" transform="matrix($(svgtf))">
     <line x1="0" y1="1" x2="0" y2="-1" />
     <line x1="1" y1="2" x2="1" y2="-2" />
     <line x1="2" y1="3" x2="2" y2="-3" />
     <line x1="3" y1="4" x2="3" y2="-4" />
     <line x1="4" y1="5" x2="4" y2="-5" />
     <line x1="5" y1="6" x2="5" y2="-6" />
     <line x1="6" y1="7" x2="6" y2="-7" />
     <line x1="7" y1="8" x2="7" y2="-8" />
    </g>
    """
    push!(canvas.elements, elem)
    return
end

function drawdashedwedge!(canvas, seg, ucolor, vcolor)
    """ u ◁ v """
    ucolor == vcolor && return drawdashedwedge!(canvas, seg, ucolor)
    d = Geometry.distance(seg)
    scalef = Point2D(d / 7, d / 14 * canvas.wedgewidthf)
    rotatef = unitvector(seg)
    translf = seg.u
    svgtf = svgtransform(transformmatrix(scalef, rotatef, translf))
    uc = svgcolor(ucolor)
    vc = svgcolor(vcolor)
    elem = """<g stroke-width="0.3" transform="matrix($(svgtf))">
     <line x1="0" y1="1" x2="0" y2="-1" stroke="$(uc)" />
     <line x1="1" y1="2" x2="1" y2="-2" stroke="$(uc)" />
     <line x1="2" y1="3" x2="2" y2="-3" stroke="$(uc)" />
     <line x1="3" y1="4" x2="3" y2="-4" stroke="$(uc)" />
     <line x1="4" y1="5" x2="4" y2="-5" stroke="$(vc)" />
     <line x1="5" y1="6" x2="5" y2="-6" stroke="$(vc)" />
     <line x1="6" y1="7" x2="6" y2="-7" stroke="$(vc)" />
     <line x1="7" y1="8" x2="7" y2="-8" stroke="$(vc)" />
    </g>
    """
    push!(canvas.elements, elem)
    return
end

function drawwave!(canvas, seg, color)
    d = Geometry.distance(seg)
    scalef = Point2D(d / 7, d / 2 * canvas.wedgewidthf)
    rotatef = unitvector(seg)
    translf = seg.u
    svgtf = svgtransform(transformmatrix(scalef, rotatef, translf))
    c = svgcolor(color)
    elem = """<polyline points="0,0 0.5,0 1,1 2,-1 3,1 4,-1 5,1 6,-1 6.5,0 7,0"
     stroke="$(c)" stroke-width="0.2" fill="none" transform="matrix($(svgtf))"/>
    """
    push!(canvas.elements, elem)
    return
end

function drawwave!(canvas, seg, ucolor, vcolor)
    ucolor == vcolor && return drawwave!(canvas, seg, ucolor)
    d = Geometry.distance(seg)
    scalef = Point2D(d / 7, d / 2 * canvas.wedgewidthf)
    rotatef = unitvector(seg)
    translf = seg.u
    svgtf = svgtransform(transformmatrix(scalef, rotatef, translf))
    uc = svgcolor(ucolor)
    vc = svgcolor(vcolor)
    elem = """<g stroke-width="0.2" fill="none" transform="matrix($(svgtf))">
     <polyline points="0,0 0.5,0 1,1 2,-1 3,1 3.5,0" stroke="$(uc)" />
     <polyline points="3.5,0 4,-1 5,1 6,-1 6.5,0 7,0" stroke="$(vc)" />
     </g>
    """
    push!(canvas.elements, elem)
    return
end


text:
import Pkg
Pkg.activate(@__DIR__)

import JSON
import Downloads: download

version = v"1.52.0"

mdb = joinpath(@__DIR__, "mimedb.jlon")

_source_preference = ("nginx", "apache", nothing, "iana")

# Check if there's a new version and alert the user, don't automatically take
# it as the format of the JSON may change
begin
    url = "https://registry.npmjs.org/mime-db/"
    d   = JSON.parse(read(download(url), String))
    vs  = sort([VersionNumber(k) => v for (k, v) in d["versions"]]; by=first)

    latest_version = last(vs)[1]

    if version == latest_version
        @info "✅  The version matches the latest version of the mime DB."
    else
        @info """
            ❗ There's a new version $(latest_version) of the mime DB. You
            might want to check whether the JSON format has changed. Assuming
            it hasn't, you can replace the `version` assignment at the
            top of mimedb/update.jl to $(latest_version).
            """
    end
end

begin
    @info "📩  downloading the DB..."
    url = "https://cdn.jsdelivr.net/gh/jshttp/mime-db@$(version)/db.json"
    d   = JSON.parse(read(download(url), String))
    _mimedb = let
        # https://github.com/jshttp/mime-db/issues/194
        d["text/javascript"], d["application/javascript"] = d["application/javascript"], d["text/javascript"]

        d["text/julia"] = Dict{String,Any}(
            "charset" => "UTF-8",
            "compressible" => true,
            "extensions" => ["jl"],
        )

        d
    end

    @info "👷  constructing the ext2mime and mime2ext maps..."

    _ext2mime = Dict{String,String}()
    _mime2ext = Dict{String,Vector}()

    # Ported straight from https://github.com/jshttp/mime-types/blob/2.1.35/index.js#L154
    for (mime_str, val) in _mimedb
        mime = mime_str

        exts = get(val, "extensions", nothing)
        if exts === nothing
            continue
        end
        _mime2ext[mime] = exts

        src = get(val, "source", nothing)
        for ex in exts
            if haskey(_ext2mime, ex)
                other_src = get(_mimedb[identity(_ext2mime[ex])], "source", nothing)

                from = findfirst(isequal(other_src), _source_preference)
                to = findfirst(isequal(src), _source_preference)

                if (
                    !(_ext2mime[ex] isa MIME"application/octet-stream") &&
                    (
                        from > to ||
                        (from == to && startswith(identity(_ext2mime[ex]), "application/")
                        )
                    )
                )
                    # skip the remapping
                    continue
                end
            end
            _ext2mime[ex] = mime
        end
    end

    @info "✏  writing to file $mdb..."
    open(mdb, "w") do f
        write(f, string(
            (_mimedb, _ext2mime, _mime2ext)
            )
        )
    end
    @info "✅  all done with mime DB version $version."
end

max_stars_repo_name: fonsp/MIMEs

max_issues_repo_name: fonsp/MIMEs

max_forks_repo_name: fonsp/MIMEs


text:
module BIREFRINGENT
using ..AGFFileReader: Glass, GlassID, AGF
export CDSE, BATIO3, SRMOO4_E, AGASS3_E, TAS, CALCITE, CAWO4_E, MGF2_E, TE, MGF2, CUGAS2_E, CAWO4, CDS, LIYF4_E, QUARTZ_E, TEO2_E, BATIO3_E, LIYF4, AGGAS2, CDSE_E, ADP_E, TE_E, LAF3, LAF3_E, TEO2, BBO, BBO_E, KDP, ZNGEP2_E, LINBO3_E, ALN_E, CAMOO4, CDS_E, AL2O3_E, TAS_E, CAMOO4_E, PBMOO4_E, KDP_E, YVO4, ZNO_E, AL2O3, PBMOO4, CUGAS2, SRMOO4, ADP, ALN, BEO, AGGASE2, ZNGEP2, CDGEAS2, AGGAS2_E, CALCITE_E, CDGEAS2_E, LIO3, ZNO, AGASS3, LIO3_E, LINBO3, QUARTZ, BEO_E, AGGASE2_E, YVO4_E

const CDSE = Glass(GlassID(AGF, 935), 9, 4.2243, 1.768, 0.227, 3.12, 3380.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 22.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 4.9, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const BATIO3 = Glass(GlassID(AGF, 936), 2, 4.187, 0.049729, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4, 0.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 2.427266, -1.0, -1.0, 0, 12.296883, 0, 1.0, 0)
const SRMOO4_E = Glass(GlassID(AGF, 937), 2, 2.4923, 0.02214144, 0.105, 20.647936, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.45, 2.4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.913456, -1.0, -1.0, 0, 28.381356, 0, 1.0, 0)
const AGASS3_E = Glass(GlassID(AGF, 938), 7, 6.364, 0.342, 0.09, 0.0011, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.59, 4.6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const TAS = Glass(GlassID(AGF, 939), 2, 10.21, 0.197136, 0.522, 625.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const CALCITE = Glass(GlassID(AGF, 940), 6, 0.8559, 0.00345744, 0.8391, 0.019881, 0.0009, 0.038809, 0.6845, 49.070025, 0.0, 0.0, 0.2, 2.2, 1.05e-6, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.658643, -1.0, -1.0, 0, 48.541403, 0, 2.711, 0)
const CAWO4_E = Glass(GlassID(AGF, 941), 2, 2.6041, 0.01901641, 4.1237, 456.719641, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.45, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.937211, -1.0, -1.0, 0, 33.304949, 0, 1.0, 0)
const MGF2_E = Glass(GlassID(AGF, 942), 2, 0.41344023, 0.00135737865, 0.50497499, 0.00823767166, 2.4904862, 565.10774, 0.0, 0.0, 0.0, 0.0, 0.2, 7.04, -2.3e-6, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.389557, -1.0, -1.0, 0, 104.857428, 0, 1.0, 0)
const TE = Glass(GlassID(AGF, 943), 9, 18.5346, 4.3289, 3.981, 3.78, 11813.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 14.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 27.5, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const MGF2 = Glass(GlassID(AGF, 944), 2, 0.48755108, 0.0018821784, 0.39875031, 0.00895188847, 2.3120353, 566.135591, 0.0, 0.0, 0.0, 0.0, 0.2, 7.04, -2.5e-7, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 9.4, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.377744, -1.0, -1.0, 0, 106.217612, 0, 3.171, 0)
const CUGAS2_E = Glass(GlassID(AGF, 945), 9, 4.3165, 1.8692, 0.1364, 1.7575, 738.43, 0.0, 0.0, 0.0, 0.0, 0.0, 0.55, 11.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const CAWO4 = Glass(GlassID(AGF, 946), 2, 2.5493, 0.01814409, 0.92, 116.964225, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.45, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.920414, -1.0, -1.0, 0, 34.953592, 0, 1.0, 0)
const CDS = Glass(GlassID(AGF, 947), 2, 3.9658282, 0.0558036869, 0.18113874, 0.233146066, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.51, 1.4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const LIYF4_E = Glass(GlassID(AGF, 948), 9, 1.31021, 0.84903, 0.00876, 0.53607, 134.9566, 0.0, 0.0, 0.0, 0.0, 0.0, 0.23, 2.6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.476472, -1.0, -1.0, 0, 88.935059, 0, 1.0, 0)
const QUARTZ_E = Glass(GlassID(AGF, 949), 1, 2.38421862, -0.0120653449, 0.011013843, 0.00012886313, 1.68747314e-7, 4.92022338e-8, 0.0, 0.0, 0.0, 0.0, 0.18, 0.71, -1.638e-5, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.553398, -1.0, -1.0, 0, 68.797763, 0, 0.0, 0)
const TEO2_E = Glass(GlassID(AGF, 950), 2, 2.823, 0.01800964, 1.542, 0.06922161, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 2.430453, -1.0, -1.0, 0, 15.474561, 0, 1.0, 0)
const BATIO3_E = Glass(GlassID(AGF, 951), 2, 4.064, 0.044521, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4, 0.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 2.380271, -1.0, -1.0, 0, 13.963107, 0, 1.0, 0)
const LIYF4 = Glass(GlassID(AGF, 952), 9, 1.38757, 0.70757, 0.00931, 0.18849, 50.99741, 0.0, 0.0, 0.0, 0.0, 0.0, 0.23, 2.6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.453776, -1.0, -1.0, 0, 93.549426, 0, 1.0, 0)
const AGGAS2 = Glass(GlassID(AGF, 953), 9, 3.628, 2.1686, 0.1003, 2.7153, 950.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.49, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const CDSE_E = Glass(GlassID(AGF, 954), 9, 4.2009, 1.8875, 0.2171, 3.6461, 3629.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 22.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const ADP_E = Glass(GlassID(AGF, 955), 2, 1.162166, 0.0085932421, 12.01997, 831.8239, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4, 1.06, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.478797, -1.0, -1.0, 0, 61.616939, 0, 1.0, 0)
const TE_E = Glass(GlassID(AGF, 956), 9, 29.5222, 9.3068, 2.5766, 9.235, 13521.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 14.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const LAF3 = Glass(GlassID(AGF, 957), 2, 1.5376, 0.00776161, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.35, 0.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.604046, -1.0, -1.0, 0, 80.83154, 0, 1.0, 0)
const LAF3_E = Glass(GlassID(AGF, 958), 2, 1.5149, 0.00770884, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.35, 0.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.596715, -1.0, -1.0, 0, 81.256833, 0, 1.0, 0)
const TEO2 = Glass(GlassID(AGF, 959), 2, 2.584, 0.01800964, 1.157, 0.06959044, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 2.274935, -1.0, -1.0, 0, 16.22277, 0, 1.0, 0)
const BBO = Glass(GlassID(AGF, 960), 7, 2.7405, 0.0184, 0.0179, 0.0155, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.22, 1.06, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.670737, -1.0, -1.0, 0, 52.593907, 0, 1.0, 0)
const BBO_E = Glass(GlassID(AGF, 961), 7, 2.373, 0.0128, 0.0156, 0.0044, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.22, 1.06, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.552518, -1.0, -1.0, 0, 61.321496, 0, 1.0, 0)
const KDP = Glass(GlassID(AGF, 962), 2, 1.256618, 0.0084478168, 33.89909, 1113.904, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4, 1.06, -9.718e-5, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 22.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.509182, -1.0, -1.0, 0, 56.224997, 0, 2.339, 0)
const ZNGEP2_E = Glass(GlassID(AGF, 963), 9, 4.6332, 5.3422, 0.1426, 1.458, 662.55, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const LINBO3_E = Glass(GlassID(AGF, 964), 9, 2.32468, 2.2565, 0.0441, 14.503, 671.587225, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4, 3.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 2.214539, -1.0, -1.0, 0, 20.455966, 0, 1.0, 0)
const ALN_E = Glass(GlassID(AGF, 965), 9, 3.0729, 1.6173, 0.030485, 4.139, 225.9009, 0.0, 0.0, 0.0, 0.0, 0.0, 0.22, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 2.200116, -1.0, -1.0, 0, 44.15554, 0, 1.0, 0)
const CAMOO4 = Glass(GlassID(AGF, 966), 2, 2.784, 0.02199289, 1.2425, 134.003776, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.45, 3.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.992539, -1.0, -1.0, 0, 28.832428, 0, 1.0, 0)
const CDS_E = Glass(GlassID(AGF, 967), 2, 3.97478769, 0.0502969611, 0.26680809, 0.218030956, 0.00074077, 0.259235138, 0.0, 0.0, 0.0, 0.0, 0.51, 1.4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const AL2O3_E = Glass(GlassID(AGF, 968), 2, 1.5039759, 0.00548026323, 0.55069141, 0.0147994281, 6.5927379, 402.89514, 0.0, 0.0, 0.0, 0.0, 0.2, 5.5, 2.2e-5, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.760096, -1.0, -1.0, 0, 72.988091, 0, 1.0, 0)
const TAS_E = Glass(GlassID(AGF, 969), 2, 8.993, 0.197136, 0.308, 625.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const CAMOO4_E = Glass(GlassID(AGF, 970), 2, 2.8045, 0.02377764, 1.0055, 134.003776, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.45, 3.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 2.002336, -1.0, -1.0, 0, 26.628162, 0, 1.0, 0)
const PBMOO4_E = Glass(GlassID(AGF, 971), 2, 3.52555, 0.03222025, 0.2066, 0.105865637, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.44, 1.08, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 2.277375, -1.0, -1.0, 0, 15.77258, 0, 1.0, 0)
const KDP_E = Glass(GlassID(AGF, 972), 2, 1.131091, 0.00814598, 5.75675, 811.7537, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4, 1.06, -0.0001008, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 39.200001, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.468324, -1.0, -1.0, 0, 68.984949, 0, 2.339, 0)
const YVO4 = Glass(GlassID(AGF, 973), 7, 3.77834, 0.069736, 0.04724, 0.0108133, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.63, 1.55, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const ZNO_E = Glass(GlassID(AGF, 974), 8, 2.80333, 0.9447, 0.09024016, 0.00714, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.45, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 2.019875, -1.0, -1.0, 0, 12.436859, 0, 1.0, 0)
const AL2O3 = Glass(GlassID(AGF, 975), 2, 1.4313493, 0.0052799261, 0.65054713, 0.0142382647, 5.3414021, 325.017834, 0.0, 0.0, 0.0, 0.0, 0.2, 5.5, 1.8e-5, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 6.65, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.768172, -1.0, -1.0, 0, 72.308589, 0, 1.0, 0)
const PBMOO4 = Glass(GlassID(AGF, 976), 2, 3.54642, 0.0342916324, 0.5827, 0.11400077, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.44, 1.08, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 2.40988, -1.0, -1.0, 0, 10.949945, 0, 1.0, 0)
const CUGAS2 = Glass(GlassID(AGF, 977), 9, 3.9064, 2.3065, 0.1149, 1.5479, 738.43, 0.0, 0.0, 0.0, 0.0, 0.0, 0.55, 11.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const SRMOO4 = Glass(GlassID(AGF, 978), 2, 2.4839, 0.02105401, 0.1015, 21.187609, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.45, 2.4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.908806, -1.0, -1.0, 0, 29.94765, 0, 1.0, 0)
const ADP = Glass(GlassID(AGF, 979), 2, 1.29899, 0.0089232927, 43.17364, 1188.531, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4, 1.06, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.523454, -1.0, -1.0, 0, 52.25678, 0, 1.0, 0)
const ALN = Glass(GlassID(AGF, 980), 9, 3.1399, 1.3786, 0.02941, 3.861, 225.9009, 0.0, 0.0, 0.0, 0.0, 0.0, 0.22, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 2.154291, -1.0, -1.0, 0, 50.733102, 0, 1.0, 0)
const BEO = Glass(GlassID(AGF, 981), 2, 1.92274, 0.0062536464, 1.24209, 94.3443116, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.44, 7.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.718619, -1.0, -1.0, 0, 93.251706, 0, 1.0, 0)
const AGGASE2 = Glass(GlassID(AGF, 982), 9, 4.6453, 2.2057, 0.1879, 1.8377, 1600.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.73, 13.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const ZNGEP2 = Glass(GlassID(AGF, 983), 9, 4.4733, 5.2658, 0.1338, 1.4909, 662.55, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const CDGEAS2 = Glass(GlassID(AGF, 984), 9, 10.1064, 2.2988, 1.0872, 1.6247, 1370.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.4, 11.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const AGGAS2_E = Glass(GlassID(AGF, 985), 9, 4.0172, 1.5274, 0.131, 2.1699, 950.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.49, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const CALCITE_E = Glass(GlassID(AGF, 986), 2, 1.0856, 0.0062362609, 0.0988, 0.020164, 0.317, 131.515024, 0.0, 0.0, 0.0, 0.0, 0.2, 3.3, 2.59e-5, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.486494, -1.0, -1.0, 0, 79.064587, 0, 2.711, 0)
const CDGEAS2_E = Glass(GlassID(AGF, 987), 9, 11.8018, 1.2152, 2.6971, 1.6922, 1370.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.4, 11.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const LIO3 = Glass(GlassID(AGF, 988), 9, 2.03132, 1.37623, 0.0350823, 1.06745, 169.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const ZNO = Glass(GlassID(AGF, 989), 8, 2.81418, 0.87968, 0.09253764, 0.00711, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.45, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 6.5, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 2.003385, -1.0, -1.0, 0, 12.424016, 0, 1.0, 0)
const AGASS3 = Glass(GlassID(AGF, 990), 7, 7.483, 0.474, 0.09, 0.0019, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.63, 4.6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const LIO3_E = Glass(GlassID(AGF, 991), 9, 1.83086, 1.08807, 0.031381, 0.554582, 158.76, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const LINBO3 = Glass(GlassID(AGF, 992), 9, 2.39198, 2.51118, 0.047089, 7.1333, 272.316004, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4, 3.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 2.300158, -1.0, -1.0, 0, 18.711921, 0, 1.0, 0)
const QUARTZ = Glass(GlassID(AGF, 993), 1, 2.35676495, -0.0113996924, 0.0108741656, 3.32066914e-5, 1.08609346e-5, -3.10123984e-7, 0.0, 0.0, 0.0, 0.0, 0.18, 0.71, -1.487e-5, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.544296, -1.0, -1.0, 0, 70.132045, 0, 0.0, 0)
const BEO_E = Glass(GlassID(AGF, 994), 2, 1.96939, 0.00737881, 1.67389, 109.824112, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.44, 7.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.734106, -1.0, -1.0, 0, 79.335058, 0, 1.0, 0)
const AGGASE2_E = Glass(GlassID(AGF, 995), 9, 5.2912, 1.397, 0.2845, 1.9282, 1600.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.73, 13.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [(0.334, 1.0, 25.0), (0.35, 1.0, 25.0), (0.365, 1.0, 25.0), (0.37, 1.0, 25.0), (0.38, 1.0, 25.0), (0.39, 1.0, 25.0), (0.4, 1.0, 25.0), (0.42, 1.0, 25.0), (0.46, 1.0, 25.0), (0.5, 1.0, 25.0), (0.66, 1.0, 25.0), (1.06, 1.0, 25.0), (1.529, 1.0, 25.0), (2.325, 1.0, 25.0)], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
const YVO4_E = Glass(GlassID(AGF, 996), 7, 4.59905, 0.110534, 0.04813, 0.0122676, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.63, 1.55, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0, -1.0, [], 1.0, -1.0, -1.0, 0, 0.0, 0, 1.0, 0)
end # module

max_stars_repo_name: rambunctiousapple/GlassCat

max_issues_repo_name: rambunctiousapple/GlassCat

max_forks_repo_name: rambunctiousapple/GlassCat


text:
"""
The default Updater for a POMCPPlanner.

When a new observation is recieved from the main simulation, a RootUpdater simply updates the
root node for the action decision on the next time step to the child of the current root node
corresponding to the observation. That way, all the information from the tree is preserved.
"""
type RootUpdater{U<:POMDPs.Updater} <: POMDPs.Updater{BeliefNode}
    node_belief_updater::U # updates the belief between nodes if necessary
end

# version with a particle reinvigorator
function update{R<:ParticleReinvigorator,A,O}(updater::RootUpdater{R}, b_old::BeliefNode, a::A, o::O, b=nothing)
    if !haskey(b_old.children[a].children, o)
        new_collection = handle_unseen_observation(updater.node_belief_updater,
                                                   b_old, a, o)
        new_node = ObsNode(o, 0, new_collection, Dict{A,ActNode{A,O,ObsNode{typeof(new_collection),A,O}}}())
        b_old.children[a].children[o] = new_node
    end
    b_new = b_old.children[a].children[o]

    reinvigorate!(b_new.B,
                  updater.node_belief_updater,
                  b_old, a, o)

    return b_new
end

# version with a user-supplied belief updater
function update{A,O}(updater::RootUpdater, b_old::BeliefNode, a::A, o::O, b=nothing)
    if !haskey(b_old.children[a].children, o)
        # if there is no node for the observation, attempt to create one
        new_belief = update(updater.node_belief_updater, b_old.B, a, o)
        new_node = ObsNode(o, 0, new_belief, Dict{A,ActNode{A,O,ObsNode{typeof(new_belief),A,O}}}())
        b_old.children[a].children[o] = new_node
    end

    return b_old.children[a].children[o]
end

updater(policy::POMCPPlanner) = RootUpdater(policy.node_belief_updater)
create_belief(updater::RootUpdater) = RootNode(0, create_belief(updater.node_belief_updater), Dict{Any,ActNode}())
create_belief{R<:ParticleReinvigorator}(updater::RootUpdater{R}) = RootNode(0, nothing, Dict{Any,ActNode}())

initialize_belief(up::RootUpdater, b, new_belief::BeliefNode) = new_belief
initialize_belief(up::RootUpdater, b) = RootNode(0, b, Dict{Any,ActNode}())
initialize_belief(::RootUpdater, n::RootNode) = n

function rand(rng::AbstractRNG, d::BeliefNode, s)
    rand(rng, d.B, s)
end

function rand(rng::AbstractRNG, d::BeliefNode)
    rand(rng, d.B)
end


text:
using ..ChemistryFeaturization.AbstractType: AbstractFeatureDescriptor
export AbstractAtomFeatureDescriptor,
    AbstractPairFeatureDescriptor, AbstractEnvironmentFeatureDescriptor

abstract type AbstractAtomFeatureDescriptor <: AbstractFeatureDescriptor end
abstract type AbstractPairFeatureDescriptor <: AbstractFeatureDescriptor end
abstract type AbstractEnvironmentFeatureDescriptor <: AbstractFeatureDescriptor end


text:
using GeometricIntegrators
using GeometricIntegrators.TestProblems.HarmonicOscillatorProblem
using Test

set_config(:nls_atol_break, Inf)
set_config(:nls_rtol_break, Inf)
set_config(:nls_stol_break, Inf)

Δt = 0.1
nt = 100000
ns = 100

nsave = 1
nwrte = 100000

h5file = "test.hdf5"

ode = harmonic_oscillator_ode(vcat(rand(1,ns), zeros(1,ns)))
#tab = getTableauImplicitMidpoint()
tab = getTableauERK4()

sim = Simulation(ode, tab, Δt, "Serial Harmonic Oscillator Test", h5file, nt; nsave=nsave, nwrite=nwrte)
run!(sim)
rm(h5file)

sim = Simulation(ode, tab, Δt, "Serial Harmonic Oscillator Test", h5file, nt; nsave=nsave, nwrite=nwrte)
@time run!(sim)
rm(h5file)

sim = ParallelSimulation(ode, tab, Δt, "Parallel Harmonic Oscillator Test", h5file, nt; nsave=nsave, nwrite=nwrte)
run!(sim)
rm(h5file)

sim = ParallelSimulation(ode, tab, Δt, "Parallel Harmonic Oscillator Test", h5file, nt; nsave=nsave, nwrite=nwrte)
@time run!(sim)
rm(h5file)


text:
# Configuration for running simple neutral copy error simulation
#=
Recommended command line to run:
>  julia neutral.jl examples/sn_example2
=#
export simtype
@everywhere simtype = 3
@everywhere const N = 5        # population size
const mutstddev = 0.04
const ngens = 6
const initial_value = 1.0
const num_trials=3
const record_interval = 2
const use_population=true
const save_populations=true
const conformist_probability=1.0


text:
module Deprecated

using Test
using DataFramesMeta
using Statistics

const ≅ = isequal

@testset "@based_on" begin
    df = DataFrame(
        g = [1, 1, 1, 2, 2],
        i = 1:5,
        t = ["a", "b", "c", "c", "e"],
        y = [:v, :w, :x, :y, :z],
        c = [:g, :quote, :body, :transform, missing]
        )

    m = [100, 200, 300, 400, 500]

    gq = :g
    iq = :i
    tq = :t
    yq = :y
    cq = :c

    gr = "g"
    ir = "i"
    tr = "t"
    yr = "y"
    cr = "c"

    gd = groupby(df, :g)

    n_str = "new_column"
    n_sym = :new_column
    n_space = "new column"

    @test @based_on(gd, n = mean(:i)).n == [2.0, 4.5]
    @test @based_on(gd, n = mean(:i) + mean(:g)).n == [3.0, 6.5]
    @test @based_on(gd, n = first(:t .* string.(:y))).n == ["av", "cy"]
    @test @based_on(gd, n = first(Symbol.(:y, ^(:t)))).n == [:vt, :yt]
    @test @based_on(gd, n = first(Symbol.(:y, ^(:body)))).n == [:vbody, :ybody]
    @test @based_on(gd, body = :i).body == df.i
    @test @based_on(gd, transform = :i).transform == df.i
    @test @based_on(gd, (n1 = [first(:i)], n2 = [first(:y)])).n1 == [1, 4]

    @test @based_on(gd, n = mean(cols(iq))).n == [2.0, 4.5]
    @test @based_on(gd, n = mean(cols(iq)) + mean(cols(gq))).n == [3.0, 6.5]
    @test @based_on(gd, n = first(cols(tq) .* string.(cols(yq)))).n == ["av", "cy"]
    @test @based_on(gd, n = first(Symbol.(cols(yq), ^(:t)))).n == [:vt, :yt]
    @test @based_on(gd, n = first(Symbol.(cols(yq), ^(:body)))).n == [:vbody, :ybody]
    @test @based_on(gd, body = cols(iq)).body == df.i
    @test @based_on(gd, transform = cols(iq)).transform == df.i
    @test @based_on(gd, (n1 = [first(cols(iq))], n2 = [first(cols(yq))])).n1 == [1, 4]

    @test @based_on(gd, n = mean(cols(ir))).n == [2.0, 4.5]
    @test @based_on(gd, n = mean(cols(ir)) + mean(cols(gr))).n == [3.0, 6.5]
    @test @based_on(gd, n = first(cols(tr) .* string.(cols(yr)))).n == ["av", "cy"]
    @test @based_on(gd, n = first(Symbol.(cols(yr), ^(:t)))).n == [:vt, :yt]
    @test @based_on(gd, n = first(Symbol.(cols(yr), ^(:body)))).n == [:vbody, :ybody]
    @test @based_on(gd, body = cols(ir)).body == df.i
    @test @based_on(gd, transform = cols(ir)).transform == df.i
    @test @based_on(gd, (n1 = [first(cols(ir))], n2 = [first(cols(yr))])).n1 == [1, 4]
    @test @based_on(gd, n = mean(cols("i")) + 0 * first(cols(:g))).n == [2.0, 4.5]
    @test @based_on(gd, n = mean(cols(2)) + first(cols(1))).n == [3.0, 6.5]

    @test @based_on(gd, :i) == select(df, :g, :i)
    @test @based_on(gd, :i, :g) ≅ select(df, :g, :i)

    @test @based_on(gd, :i, n = 1).n == fill(1, nrow(df))

    @test @based_on(gd, cols("new_column") = 2).new_column == [2, 2]
    @test @based_on(gd, cols(n_str) = 2).new_column == [2, 2]
    @test @based_on(gd, cols(n_sym) = 2).new_column == [2, 2]
    @test @based_on(gd, cols(n_space) = 2)."new column" == [2, 2]
    @test @based_on(gd, cols("new" * "_" * "column") = 2)."new_column" == [2, 2]
end

@testset "where" begin
    df = DataFrame(A = [1, 2, 3, missing], B = [2, 1, 2, 1])

    x = [2, 1, 0, 0]

    @test @where(df, :A .> 1) == df[(df.A .> 1) .=== true,:]
    @test @where(df, :B .> 1) == df[df.B .> 1,:]
    @test @where(df, :A .> x) == df[(df.A .> x) .=== true,:]
    @test @where(df, :B .> x) ≅ df[df.B .> x,:]
    @test @where(df, :A .> :B, :B .> mean(:B)) == DataFrame(A = 3, B = 2)
    @test @where(df, :A .> 1, :B .> 1) == df[map(&, df.A .> 1, df.B .> 1),:]
    @test @where(df, :A .> 1, :A .< 4, :B .> 1) == df[map(&, df.A .> 1, df.A .< 4, df.B .> 1),:]

    @test @where(df, :A .> 1).A isa Vector{Union{Missing, Int}}

    @test @where(df, cols(:A) .> 1) == df[(df.A .> 1) .=== true,:]
    @test @where(df, cols(:B) .> 1) == df[df.B .> 1,:]
    @test @where(df, cols(:A) .> x) == df[(df.A .> x) .=== true,:]
    @test @where(df, cols(:B) .> x) ≅ df[df.B .> x,:]
    @test @where(df, cols(:A) .> :B, cols(:B) .> mean(:B)) == DataFrame(A = 3, B = 2)
    @test @where(df, cols(:A) .> 1, :B .> 1) == df[map(&, df.A .> 1, df.B .> 1),:]
    @test @where(df, cols(:A) .> 1, :A .< 4, :B .> 1) == df[map(&, df.A .> 1, df.A .< 4, df.B .> 1),:]

    @test @where(df, :A .> 1, :A .<= 2) == DataFrame(A = 2, B = 1)

    subdf = @view df[df.B .== 2, :]

    @test @where(subdf, :A .== 3) == DataFrame(A = 3, B = 2)
end

@testset "where with :block" begin
    df = DataFrame(A = [1, 2, 3, missing], B = [2, 1, 2, 1])

    d = @where df begin
        :A .> 1
        :B .> 1
    end
    @test d ≅ @where(df, :A .> 1, :B .> 1)

    d = @where df begin
        cols(:A) .> 1
        :B .> 1
    end
    @test d ≅ @where(df, :A .> 1, :B .> 1)

    d = @where df begin
        :A .> 1
        cols(:B) .> 1
    end
    @test d ≅ @where(df, :A .> 1, :B .> 1)

    d = @where df begin
        begin
            :A .> 1
        end
        :B .> 1
    end
    @test d ≅ @where(df, :A .> 1, :B .> 1)

    d = @where df begin
        :A .> 1
        @. :B > 1
    end
    @test d ≅ @where(df, :A .> 1, :B .> 1)
end

@testset "@where with a grouped data frame" begin
    df = DataFrame(
        g = [1, 1, 1, 2, 2],
        i = 1:5,
        t = ["a", "b", "c", "c", "e"],
        y = [:v, :w, :x, :y, :z],
        c = [:g, :quote, :body, :transform, missing]
    )

    gd = groupby(df, :g)

    @test @where(gd, :i .== first(:i)) ≅ df[[1, 4], :]
    @test @where(gd, cols(:i) .> mean(cols(:i)), :t .== "c") ≅ df[[3], :]
    @test @where(gd, :c .== :g) ≅ df[[], :]
end

@testset "Unquoted symbols on LHS" begin
    df = DataFrame(
        g = [1, 1, 1, 2, 2],
        i = 1:5,
        t = ["a", "b", "c", "c", "e"],
        y = [:v, :w, :x, :y, :z],
        c = [:g, :quote, :body, :transform, missing]
    )

    gd = groupby(df, :g)

    newdf = @transform df :n = :i

    @test (@transform df n = :i) ≅ newdf
    @test (@transform(df, n = identity(:i))) ≅ newdf
    @test (@transform df @byrow n = :i) ≅ newdf
    d = @transform df begin
        n = identity(:i)
    end
    @test d ≅ newdf

    d = @eachrow df begin
        @newcol n::Vector{Int}
        :n = :i
    end
    @test d ≅ newdf

    newdf = @select df :n = :i

    @test (@select df n = :i) ≅ newdf
    @test (@select(df, n = identity(:i))) ≅ newdf
    d = @select df begin
        n = identity(:i)
    end
    @test (@select df @byrow n = :i) ≅ newdf
    @test d ≅ newdf

    newdf = @combine gd :n = first(:i)
    @test (@combine gd n = first(:i)) ≅ newdf
    @test (@combine(gd, n = first(:i))) ≅ newdf
end

end # module