text:
include("Draw.jl")

using Gtk
using Printf

win = GtkWindow("NetworkVis")
g = GtkGrid()
netLabel = GtkLabel("Network")
netEntry = GtkEntry()
set_gtk_property!(netEntry, :text, "Karate")
n0Label = GtkLabel("n0")
n0Entry = GtkEntry()
set_gtk_property!(n0Entry, :text, "20")
m0Label = GtkLabel("m0")
m0Entry = GtkEntry()
set_gtk_property!(m0Entry, :text, "20")
selectCb = GtkComboBoxText()
push!(selectCb, "Node")
push!(selectCb, "Node && Edge")
set_gtk_property!(selectCb, :active, 1)
addCb = GtkComboBoxText()
push!(addCb, "KeepOne")
push!(addCb, "KeepAll")
set_gtk_property!(addCb, :active, 0)

retLabel = GtkLabel("*****")
retLabel2 = GtkLabel("*****")
retLabel3 = GtkLabel("*****")

drawButton = GtkButton("Draw")
g[1, 1] = netLabel
g[2, 1] = netEntry
g[1, 2] = n0Label
g[2, 2] = n0Entry
g[1, 3] = m0Label
g[2, 3] = m0Entry
g[1, 4] = selectCb
g[2, 4] = addCb
g[1:2, 5] = drawButton
g[1:2, 6] = retLabel
g[1:2, 7] = retLabel2
g[1:2, 8] = retLabel3

set_gtk_property!(g, :column_homogeneous, true)
set_gtk_property!(g, :column_spacing, 15)
set_gtk_property!(g, :row_spacing, 15)
set_gtk_property!(g, :margin_left, 15)
set_gtk_property!(g, :margin_right, 15)
set_gtk_property!(g, :margin_top, 15)
set_gtk_property!(g, :margin_bottom, 15)
push!(win, g)
showall(win)

signal_connect(drawButton, "clicked") do widget
	s1 = get_gtk_property(netEntry, :text, String)
	s2 = get_gtk_property(n0Entry, :text, String)
	s3 = get_gtk_property(m0Entry, :text, String)
	s4 = Gtk.bytestring( GAccessor.active_text(selectCb) )
	s5 = Gtk.bytestring( GAccessor.active_text(addCb) )
	cntstr = "Network = " * s1 * ", n0 = " * s2 * ", m0 = " * s3
	cntstr2 = "Compress Mode : " * s4 * ", " * s5
	GAccessor.text(retLabel, cntstr)
	GAccessor.text(retLabel2, cntstr2)
	GAccessor.text(retLabel3, "Running ... ...")
	ags1 = s1
	ags2 = s2 * "," * s3 * "," * ((s4 == "Node") ? "n," : "ne,") * s5
	T = time()
	DrawNetwork(ags1, ags2)
	T = time() - T
	GAccessor.text(retLabel3, "Running Time : " * @sprintf("%.2f s", T))
	run(Cmd(["epstopdf", "../pictures/"*ags1*".eps"]))
	run(Cmd(["open", "../pictures/"*ags1*".pdf"]))

	#win2 = GtkWindow("Final Drawing")
	#bx = GtkBox(:v)
	#ii = GtkImage("picture/" * s1 * ".eps")
	#push!(bx, ii)
	#push!(win2, bx)
	#showall(win2)
	#signal_connect(win2, :destroy) do widget
	#    Gtk.gtk_quit()
	#end
end

signal_connect(win, :destroy) do widget
    Gtk.gtk_quit()
	exit()
end

Gtk.gtk_main()


text:
# some idea to reduce allocation - Not ok yet
_string_size(x, f, threads, ::Type{T}) where T <: InMemoryDatasets.FLOATS = Base.Ryu.neededdigits(T)

_ndigits(x) = ndigits(x)
_ndigits(::Missing) = 0
function _string_size(x, f, threads, ::Type{T}) where T <: InMemoryDatasets.INTEGERS
    if threads
        InMemoryDatasets.hp_maximum(_ndigits∘f, x) + 1
    else
        InMemoryDatasets.stat_maximum(_ndigits∘f, x) + 1
    end
end
_string_size(x, f, threads, ::Type{T}) where T <: Bool = 1
_string_size(x, f, threads, ::Type{T}) where T <: Characters{M, UInt8} where M= M

_STRING_L(x) = length(string(x))
_STRING_L(::Missing) = 0
function _string_size(x, f, threads, ::Type{T}) where T <: Any
    if threads
        InMemoryDatasets.hp_maximum(_STRING_L∘f, x)
    else
        InMemoryDatasets.stat_maximum(_STRING_L∘f, x)
    end
end

function _find_max_string_length(ds, delim, quotechar, mapformats, threads)
    ncols = InMemoryDatasets.ncol(ds)
    ff = Function[]
    if mapformats
        for j in 1:ncols
            push!(ff, InMemoryDatasets.getformat(ds, j))
        end
    else
        ff = repeat([identity], ncols)
    end
    n, p = size(ds)
    s = 0
    cnt_str = 0
    for j in 1:ncols
        T = Core.Compiler.return_type(ff[j], (eltype(InMemoryDatasets._columns(ds)[j]), ))
        s += _string_size(InMemoryDatasets._columns(ds)[j], ff[j], threads, nonmissingtype(T))
        if nonmissingtype(T) <: AbstractString
            cnt_str += 1
        end
    end
    s += ncols*length(delim) + 1
    if quotechar != nothing
        s += 2*cnt_str
    end
    s + 1
end

function WRITE(f, buff, cur_pos, lbuff, lastvalid = length(cur_pos))
    offset = 1
    jump = size(buff, 1)
    for i in 1:lastvalid
        copyto!(lbuff, offset, buff, (i-1)*jump+1, cur_pos[i]-1)
        offset += cur_pos[i]-1
    end
    write(f, view(lbuff, 1:offset-1))
end

function WRITE_CHUNK(buff, cur_pos, lbuff, f, ds, n, ff, delim, quotechar, threads)
    rchunk = length(cur_pos)
    chunk = div(n, rchunk)
    for j in 1:chunk
        fill!(cur_pos, 1)
        InMemoryDatasets.row_join!(buff, cur_pos, view(ds, (j-1)*rchunk+1:j*rchunk, :), ff, :, delim = delim, quotechar = quotechar, threads = threads)
        WRITE(f, buff, cur_pos, lbuff)
    end
    fill!(cur_pos, 1)
    InMemoryDatasets.row_join!(buff, cur_pos, view(ds, chunk*rchunk+1:n, :), ff, :, delim = delim, quotechar = quotechar, threads = threads)
    WRITE(f, buff, cur_pos, lbuff, length(chunk*rchunk+1:n))
end

# basic function for writing csv files
function filewriter(path::AbstractString, ds::AbstractDataset; delim = ',', quotechar = nothing, mapformats = false, append = false, header = true, lsize = :auto, buffsize = 2^24, threads::Bool = true)
    ncols = InMemoryDatasets.ncol(ds)
    ff = Function[]
    if mapformats
        for j in 1:ncols
            push!(ff, InMemoryDatasets.getformat(ds, j))
        end
    else
        ff = repeat([identity], ncols)
    end
    n, p = size(ds)
    if lsize == :auto
        lsize = _find_max_string_length(ds, UInt8.(delim), quotechar, mapformats, threads)
    else
        lsize = lsize
    end
    f = open(path, write = true, append = append)
    try
        if header
            allnames = names(ds)
            for j in 1:ncols
                if quotechar !== nothing
                    write(f, quotechar)
                end
                write(f, allnames[j])
                if quotechar !== nothing
                    write(f, quotechar)
                end
                if j == ncols
                    write(f, '\n')
                else
                    write(f, delim)
                end
            end
        end
        nrow_buff = div(buffsize, lsize)
        nrow_buff == 0 && throw(ArgumentError("very wide data set! you need to manually adjust `buffsize` (and/or `lsize`)"))
        cs = min(nrow_buff, n)
        buff = Matrix{UInt8}(undef, lsize, cs)
        cur_pos = Vector{Int}(undef, cs)
        lbuff = Vector{UInt8}(undef, lsize*cs)
        nrow_buff, sizeof(buff), sizeof(cur_pos), sizeof(lbuff)
        WRITE_CHUNK(buff, cur_pos, lbuff, f, ds, n, ff, delim, quotechar, threads)
    catch e
        close(f)
        rethrow(e)
    end
    close(f)
end

ext: jl


text:
let m = test_page_model()
    load_parameters(m)
end


text:
export ft_getqueuestatus

function ft_getqueuestatus(ft_handle::Culong)
  amountinrxqueue = Ref{Cuint}()
  ft_status = ccall((:FT_GetQueueStatus, d2xx),
                     Cuint,
                     (Culong, Ref{Cuint}),
                     ft_handle, amountinrxqueue)
  checkstatus(ft_status)
  return convert(UInt32, amountinrxqueue[])
end


text:
"""
An [`AbstractConstraintSet`](@ref) that stores the constraint values as well as Lagrange
multiplier and penalty terms for each constraint.

The cost associated with constraint terms in the augmented Lagrangian can be evaluated for

	cost!(J::Vector, ::ALConstraintSet)

which adds the cost at each time step to the vector `J` of length `N`.

The cost expansion for these terms is evaluated along the trajectory `Z` using

	cost_expansion!(E::Objective, conSet::ALConstraintSet, Z)

which also adds the expansion terms to the terms in `E`.

The penalty and multiplier terms can be updated using

	penalty_update!(::ALConstraintSet)
	dual_update!(::ALConstraintSet)

The current set of active constraint (with tolerance `tol`) can be re-calculated using

	update_active_set!(::ALConstraintSet, ::Val{tol})

The maximum penalty can be queried using `max_penalty(::ALConstraintSet)`, and the
penalties and/or multipliers can be reset using

	reset!(::ALConstraintSet)
	reset_penalties!(::ALConstraintSet)
	reset_duals!(::ALConstraintSet)

# Constructor
	ALConstraintSet(::ConstraintList, ::AbstractModel)
	ALConstraintSet(::Problem)
"""
struct ALConstraintSet{T} <: AbstractConstraintSet
    convals::Vector{ConVal}
    errvals::Vector{ConVal}
    λ::Vector{<:Vector}
    μ::Vector{<:Vector}
    active::Vector{<:Vector}
    c_max::Vector{T}
    μ_max::Vector{T}
    μ_maxes::Vector{Vector{T}}
	params::Vector{ConstraintParams{T}}
	p::Vector{Int}
end

function ALConstraintSet(cons::ConstraintList, model::AbstractModel)
    n,m = cons.n, cons.m
    n̄ = RobotDynamics.state_diff_size(model)
    ncon = length(cons)
    useG = model isa LieGroupModel
    errvals = map(1:ncon) do i
        C,c = gen_convals(n̄, m, cons[i], cons.inds[i])
        ConVal(n̄, m, cons[i], cons.inds[i], C, c, useG)
    end
    convals = map(errvals) do errval
        ConVal(n, m, errval)
    end
	errvals = convert(Vector{ConVal}, errvals)
	convals = convert(Vector{ConVal}, convals)
    λ = map(1:ncon) do i
        p = length(cons[i])
        [@SVector zeros(p) for i in cons.inds[i]]
    end
    μ = map(1:ncon) do i
        p = length(cons[i])
        [@SVector ones(p) for i in cons.inds[i]]
    end
    a = map(1:ncon) do i
        p = length(cons[i])
        [@SVector ones(Bool,p) for i in cons.inds[i]]
    end
    c_max = zeros(ncon)
    μ_max = zeros(ncon)
    μ_maxes = [zeros(length(ind)) for ind in cons.inds]
	params = [ConstraintParams() for con in cons.constraints]
    ALConstraintSet(convals, errvals, λ, μ, a, c_max, μ_max, μ_maxes, params, copy(cons.p))
end

@inline ALConstraintSet(prob::Problem) = ALConstraintSet(prob.constraints, prob.model)

# Iteration
Base.iterate(conSet::AbstractConstraintSet) =
	isempty(get_convals(conSet)) ? nothing : (get_convals(conSet)[1].con,1)
Base.iterate(conSet::AbstractConstraintSet, state::Int) =
	state >= length(conSet) ? nothing : (get_convals(conSet)[state+1].con, state+1)
@inline Base.length(conSet) = length(get_convals(conSet))
Base.IteratorSize(::AbstractConstraintSet) = Base.HasLength()
Base.IteratorEltype(::AbstractConstraintSet) = Base.HasEltype()
Base.eltype(::AbstractConstraintSet) = AbstractConstraint

"""
	link_constraints!(set1, set2)

Link any common constraints between `set1` and `set2` by setting elements in `set1` to point
to elements in `set2`
"""
function link_constraints!(set1::ALConstraintSet, set2::ALConstraintSet)
	# Find common constraints
	links = Tuple{Int,Int}[]
	for (i,con1) in enumerate(set1)
		for (j,con2) in enumerate(set2)
			if con1 === con2
				push!(links, (i,j))
			end
		end
	end

	# Link values
	for (i,j) in links
		set1.convals[i] = set2.convals[j]
		set1.errvals[i] = set2.errvals[j]
		set1.active[i] = set2.active[j]
		set1.λ[i] = set2.λ[j]
		set1.μ[i] = set2.μ[j]
	end
	return links
end

@inline get_convals(conSet::ALConstraintSet) = conSet.convals
@inline get_errvals(conSet::ALConstraintSet) = conSet.errvals

# Augmented Lagrangian Updates
function dual_update!(conSet::ALConstraintSet)
    for i in eachindex(conSet.λ)
        dual_update!(conSet.convals[i], conSet.λ[i], conSet.μ[i], conSet.params[i])
    end
end

function dual_update!(conval::ConVal, λ::Vector{<:SVector}, μ::Vector{<:SVector}, params::ConstraintParams)
    c = conval.vals
	λ_max = params.λ_max
	λ_min = sense(conval.con) == Equality() ? -λ_max : zero(λ_max)
	for i in eachindex(conval.inds)
		λ[i] = clamp.(λ[i] + μ[i] .* c[i], λ_min, λ_max)
	end
end

function penalty_update!(conSet::ALConstraintSet)
	for i in eachindex(conSet.μ)
		penalty_update!(conSet.μ[i], conSet.params[i])
	end
end

function penalty_update!(μ::Vector{<:SVector}, params::ConstraintParams)
	ϕ = params.ϕ
	μ_max = params.μ_max
	for i in eachindex(μ)
		μ[i] = clamp.(ϕ * μ[i], 0.0, μ_max)
	end
end

# Active Set
function update_active_set!(conSet::ALConstraintSet, val::Val{tol}=Val(0.0)) where tol
	for i in eachindex(conSet.active)
		update_active_set!(conSet.active[i], conSet.λ[i], conSet.convals[i], val)
	end
end

function update_active_set!(a::Vector{<:StaticVector}, λ::Vector{<:StaticVector},
		conval::ConVal, ::Val{tol}) where tol
	if sense(conval.con) == Inequality()
		for i in eachindex(a)
			a[i] = @. (conval.vals[i] >= -tol) | (λ[i] > zero(tol))
		end
	end
end

# Cost
function cost!(J::Vector{<:Real}, conSet::ALConstraintSet)
	for i in eachindex(conSet.convals)
		cost!(J, conSet.convals[i], conSet.λ[i], conSet.μ[i], conSet.active[i])
	end
end

function cost!(J::Vector{<:Real}, conval::ConVal, λ::Vector{<:StaticVector},
		μ::Vector{<:StaticVector}, a::Vector{<:StaticVector})
	for (i,k) in enumerate(conval.inds)
		c = SVector(conval.vals[i])
		Iμ = Diagonal(SVector(μ[i] .* a[i]))
		J[k] += λ[i]'c .+ 0.5*c'Iμ*c
	end
end

function cost_expansion!(E::Objective, conSet::ALConstraintSet, Z::AbstractTrajectory,
		init::Bool=false, rezero::Bool=false)
	for i in eachindex(conSet.errvals)
		cost_expansion!(E, conSet.convals[i], conSet.λ[i], conSet.μ[i], conSet.active[i])
	end
end

@generated function cost_expansion!(E::QuadraticObjective{n,m}, conval::ConVal{C}, λ, μ, a) where {n,m,C}
	if C <: StateConstraint
		expansion = quote
			cx = ∇c
			E[k].Q .+= cx'Iμ*cx
			E[k].q .+= cx'g
		end
	elseif C <: ControlConstraint
		expansion = quote
			cu = ∇c
			E[k].R .+= cu'Iμ*cu
			E[k].r .+= cu'g
		end
	elseif C<: StageConstraint
		ix = SVector{n}(1:n)
		iu = SVector{m}(n .+ (1:m))
		expansion = quote
			cx = ∇c[:,$ix]
			cu = ∇c[:,$iu]
			E[k].Q .+= cx'Iμ*cx
			E[k].q .+= cx'g
			E[k].H .+= cu'Iμ*cx
			E[k].R .+= cu'Iμ*cu
			E[k].r .+= cu'g
		end
	else
		throw(ArgumentError("cost expansion not supported for CoupledConstraints"))
	end
	quote
		for (i,k) in enumerate(conval.inds)
			∇c = SMatrix(conval.jac[i])
			c = conval.vals[i]
			Iμ = Diagonal(a[i] .* μ[i])
			g = Iμ*c .+ λ[i]

			$expansion
		end
	end
end

"""
	max_penalty(conSet::ALConstraintSet)

Calculate the maximum constrained penalty across all constraints.
"""
function max_penalty(conSet::ALConstraintSet)
	max_penalty!(conSet)
	maximum(conSet.μ_max)
end

function max_penalty!(conSet::ALConstraintSet{T}) where T
    conSet.c_max .*= 0
    for i in eachindex(conSet.μ)
        maxes = conSet.μ_maxes[i]::Vector{T}
        max_penalty!(maxes, conSet.μ[i])
        conSet.μ_max[i] = maximum(maxes)
    end
end

function max_penalty!(μ_max::Vector{<:Real}, μ::Vector{<:StaticVector})
    for i in eachindex(μ)
        μ_max[i] = maximum(μ[i])
    end
    return nothing
end

# Reset
function reset!(conSet::ALConstraintSet)
    reset_duals!(conSet)
    reset_penalties!(conSet)
end

function reset_duals!(conSet::ALConstraintSet)
	function _reset!(V::Vector{<:SVector})
	    for i in eachindex(V)
	        V[i] = zero(V[i])
	    end
	end
    for i in eachindex(conSet.λ)
        _reset!(conSet.λ[i])
    end
end

function reset_penalties!(conSet::ALConstraintSet)
	function _reset!(V::Vector{<:SVector}, params::ConstraintParams)
	    for i in eachindex(V)
	        V[i] = zero(V[i]) .+ params.μ0
	    end
	end
    for i in eachindex(conSet.μ)
        # reset!(conSet.μ[i], conSet.params[i].μ0)
		# μ0 = conSet.params[i].μ0
        _reset!(conSet.μ[i], conSet.params[i])
    end
end


text:
# Copyright (c) 2021, Rolfe Power

using Test
using Pat: DimensionSet, mass, velocity, acceleration, area, volume, force, density

@testset "Basic Construction" begin
    ds = DimensionSet(3.0, 4.0, 5.0)
    @test mass(ds) == 3.0
    @test length(ds) == 4.0
    @test time(ds) == 5.0
end

@testset "Default Construction" begin
    ds = DimensionSet()
    @test mass(ds) == 1
    @test length(ds) == 1
    @test time(ds) == 1
end

@testset "Single Value Construction" begin
    k = rand(Float64) + 1.0
    ds = DimensionSet(k)
    @test mass(ds) == k
    @test length(ds) == k
    @test time(ds) == k
    @test_throws DomainError DimensionSet(0)
    @test_throws DomainError DimensionSet(-1.0)
end

@testset "Keyword Construction" begin
    ds = DimensionSet(mass=3.0, length=4.0, time=5.0)
    @test ds == DimensionSet(3, 4, 5)
    @test mass(ds) == 3.0
    @test length(ds) == 4.0
    @test time(ds) == 5.0
    @test_throws DomainError DimensionSet(mass=-1, length=1, time=1)
    @test_throws DomainError DimensionSet(mass=1, length=-1, time=1)
    @test_throws DomainError DimensionSet(mass=1, length=1, time=-1)
end

@testset "Derived Quantities" begin
    m = 3.0
    l = 4.0
    t = 5.0
    v = 0.8
    a = 0.16
    ar = 16.0
    vol = 64.0
    f = 0.48
    d = 3//64

    ds = DimensionSet(m, l, t)
    @test velocity(ds) == v
    @test acceleration(ds) == a
    @test area(ds) == ar
    @test volume(ds) == vol
    @test force(ds) == f
    @test density(ds) == d
end


text:
module SPHShockTube1D

using Plots

include("kernels.jl")
include("output.jl")
include("initialconditions.jl")
include("solver.jl")
include("simulationstep.jl")

(x, ρ, u, v, p) = runsimulation()

gr()
plot(x, ρ)

directfind(x)

end # module


text:
__precompile__()

module MMTF
    include("api.jl")
end


text:
# # Hypercube Examples (Bravais Lattice)

# ## Preamble
using LatticeTools
using Plots

mkpath("example_hypercube")

function draw_hypercube(hypercube::Hypercube, coordinates::AbstractMatrix{<:Integer})
    xlim = (minimum(coordinates[1,:]) - 3.5, maximum(coordinates[1,:]) + 3.5)
    ylim = (minimum(coordinates[2,:]) - 3.5, maximum(coordinates[2,:]) + 3.5)
    boundary = let
        r0 = [0,0]
        r1 = hypercube.shape_matrix[:,1]
        r2 = hypercube.shape_matrix[:,2]
        hcat(r0, r1, r1 .+ r2, r2, r0)
    end
    fig = plot(boundary[1,:], boundary[2,:], label="", size=(400, 400))
    for Ri in Iterators.product(-1:1, -1:1)
        alpha = (Ri == (0,0)) ? 1.0 : 0.1
        Rr = hypercube.shape_matrix * [Ri...]
        scatter!(coordinates[1,:] .+ Rr[1], coordinates[2,:] .+ Rr[2], aspect_ratio=1, markersize=12, xlim=xlim, ylim=ylim, markeralpha=alpha, label="")
        annotation = []
        for i in 1:size(coordinates, 2)
            x = coordinates[1,i] + Rr[1]
            y = coordinates[2,i] + Rr[2]
            if xlim[1] < x < xlim[2] && ylim[1] < y < ylim[2]
                push!(annotation, (x, y, text("$i", 8, :black, :center)))
            end
        end
        if !isempty(annotation)
            annotation = [annotation...]
            annotate!(annotation)
        end
    end
    fig
end

# ## (4,-4) x (4,4)
size_matrix = [ 4 4; -4 4]
hypercube = Hypercube(size_matrix)
generator_translations = find_generators(hypercube)
coordinates = generate_coordinates(hypercube, generator_translations)
coordmat = hcat(coordinates...)
println("All elements")
for (i, c) in enumerate(coordinates)
    println("$i : $c")
end
println("Generator translations")
for (it, t) in enumerate(eachcol(generator_translations))
    println("t($it) = $t")
end
draw_hypercube(hypercube, coordmat)
savefig("example_hypercube/bravais_(4,-4)x(4,4).svg")

# ![](example_hypercube//bravais_(4,-4)x(4,4).svg)

# ## (2,-2) x (2,4)
size_matrix = [ 2 2; -2 4]
hypercube = Hypercube(size_matrix)
generator_translations = find_generators(hypercube)
coordinates = generate_coordinates(hypercube, generator_translations)
coordmat = hcat(coordinates...)
draw_hypercube(hypercube, coordmat)
println("All elements")
for (i, c) in enumerate(coordinates)
    println("$i : $c")
end
println("Generator translations")
for (it, t) in enumerate(eachcol(generator_translations))
    println("t($it) = $t")
end
draw_hypercube(hypercube, coordmat)
savefig("example_hypercube/bravais_(2,-2)x(2,4).svg")

# ![](example_hypercube//bravais_(2,-2)x(2,4).svg)


text:
function factorial(n)
	fact = 1
	for i in 1:n
		fact *= i
	end
	return fact
end

println(@time factorial(49))


text:
module SSLTestPlots
using SimpleSDMLayers
using Test
using Plots
using StatsPlots

temperature, precipitation = SimpleSDMPredictor(WorldClim, BioClim, [1,12])

ispath("gallery") || mkpath("gallery")

chelsa1 = SimpleSDMPredictor(CHELSA, BioClim, 1; left=-11.0, right=31.1, bottom=29.0, top=71.1)
n_chelsa1 = zeros(Float32, size(chelsa1));
for (i,e) in enumerate(chelsa1.grid)
  n_chelsa1[i] = isnothing(e) ? NaN : Float32(e)
end
chelsa1 = SimpleSDMPredictor(n_chelsa1, chelsa1)
plot(chelsa1, c=:heat, title="Temperature from CHELSA", frame=:box,
    xlabel = "Longitude",
    ylabel= "Latitude")
savefig(joinpath("gallery", "range-comparison-chelsa.png"))

wc1 = SimpleSDMPredictor(WorldClim, BioClim, 1; left=-11.0, right=31.1, bottom=29.0, top=71.1)
plot(wc1, c=:heat, title="Temperature from worldclim @ 10", frame=:box,
    xlabel = "Longitude",
    ylabel= "Latitude")
savefig(joinpath("gallery", "range-comparison-worldclim-10.png"))

wc1 = SimpleSDMPredictor(WorldClim, BioClim, 1; resolution=5.0, left=-11.0, right=31.1, bottom=29.0, top=71.1)
plot(wc1, c=:heat, title="Temperature from worldclim @ 5", frame=:box,
    xlabel = "Longitude",
    ylabel= "Latitude")
savefig(joinpath("gallery", "range-comparison-worldclim-5.png"))

lc1 = SimpleSDMPredictor(EarthEnv, LandCover, 1; left=-11.0, right=31.1, bottom=29.0, top=71.1)
n_lc1 = zeros(Float32, size(lc1));
for (i,e) in enumerate(lc1.grid)
  n_lc1[i] = isnothing(e) ? NaN : Float32(e)
end
lc1 = SimpleSDMPredictor(n_lc1, lc1)
plot(lc1, c=:heat, title="Landcover class 1", frame=:box,
    xlabel = "Longitude",
    ylabel= "Latitude")
savefig(joinpath("gallery", "range-comparison-landcover.png"))

plot(temperature, c=:magma, title="Temperature", frame=:box,
    xlabel = "Longitude",
    ylabel= "Latitude")
savefig(joinpath("gallery", "heatmap.png"))

contour(temperature, c=:viridis, title="Temperature", frame=:box,
    xlabel = "Longitude",
    ylabel= "Latitude")
savefig(joinpath("gallery", "contour.png"))

contour(temperature, c=:cividis, title="Temperature", frame=:box,
    fill=true, lw=0.0,
    xlabel = "Longitude",
    ylabel= "Latitude")
savefig(joinpath("gallery", "filled_contour.png"))

cmap = coarsen(temperature, minimum, (10,10))
heatmap(cmap, c=:RdYlBu, title="Temperature", frame=:box)
xaxis!("Longitude")
yaxis!("Latitude")
savefig(joinpath("gallery", "heatmap_scaledown.png"))

histogram(precipitation, leg=false)
xaxis!("Precipitation")
savefig(joinpath("gallery", "histogram.png"))

density(precipitation, leg=false)
xaxis!("Precipitation")
savefig(joinpath("gallery", "density.png"))

plot(temperature, precipitation, leg=false, c=:grey, msc=:grey, alpha=0.5)
xaxis!("Temperature")
yaxis!("Precipitation")
savefig(joinpath("gallery", "scatter.png"))

histogram2d(temperature, precipitation, leg=false)
xaxis!("Temperature")
yaxis!("Precipitation")
savefig(joinpath("gallery", "scatter-2d.png"))

a = rand(Bool, 100, 100)
a = convert(Matrix{Union{Bool,Nothing}}, a)
a[rand(eachindex(a), 100)] .= nothing
S = SimpleSDMResponse(a)

plot(convert(Float64, S))
savefig(joinpath("gallery", "booltype.png"))

end


text:
module SampleMultiplePackage2

using Test

test() = @test true

end  # module SampleMultiplePackage2


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

JLLWrappers.@generate_main_file_header("Bison")
JLLWrappers.@generate_main_file("Bison", UUID("0f48145f-aea8-549d-8864-7f251ac1e6d0"))
end  # module Bison_jll


text:
q = normalize(@SVector rand(4))
q0 = normalize(@SVector rand(4))
dq(q) = quat_diff(q,q0)
@test ForwardDiff.jacobian(dq,q) ≈ quat_diff_jacobian(q0)

quad = Dynamics.Quadrotor()
x0 = Problems.quadrotor_static.x0
xf = Problems.quadrotor_static.xf
state_diff(quad, xf, x0)
@test let quad=quad, xf=xf, x0=x0
    allocs = (@allocated state_diff(quad, xf, x0))
    allocs += (@allocated state_diff_jacobian(quad, x0))
end == 0
state_diff_jacobian(quad, x0)
@btime state_diff($quad, $xf, $x0)
@btime state_diff_jacobian($quad, $x0)
sd(x) = let model=quad, x0=x0
    state_diff(model, x, x0)
end
state_diff(quad, xf, x0) == sd(xf)
ForwardDiff.jacobian(sd, xf) ≈ state_diff_jacobian(quad, x0)


text:
"""
    Ridge(alpha = 0.1)
Ridge Regression. `alpha` is the value multiplied by regularization term.

# Example
```jldoctest regression
julia> model = Ridge()
Ridge(Float64[], 0.1)

julia> fit!(model, x, t)
3-element Vector{Float64}:
 -0.5635468573581848
  2.1185952951687614
 40.334109796666425

julia> model(x)
20-element Vector{Float64}:
 175.12510514593038
 170.28763505842625
 149.54478779081344
 159.7466476176333
 165.4525001910219
 129.6935485937018
 164.79709438985097
 161.3621431448216
 170.17418141858434
 176.95192713546982
 174.8078461898064
 168.76930346791391
 171.09202561187362
 170.58861763111338
 155.04089855305028
 168.05151465675456
 149.76311329450505
 169.5183634524783
 141.7695072903308
 163.94744858842117
```
"""
mutable struct Ridge
    w::Array
    α::Float64
    Ridge(alpha = 0.1) = new(Array{Float64}(undef, 0), alpha)
end

function fit!(model::Ridge, x, t)
    check_size(x, t)
    x = expand(x)
    n = size(x, 1)
    _I = Matrix{Float64}(I, n, n)
    model.w = inv(x * x' .+ model.α * _I) * x * t
end

(model::Ridge)(x) = expand(x)' * model.w


text:
# Data to be added to specific nws only
function add_singular_data!(target::AbstractDict, source::AbstractDict, lookup::AbstractDict, y::Int)
    first_hour_nws = string.(_FP.nw_ids(target, hour=1, year=y))
    last_hour_nws  = string.(_FP.nw_ids(target, hour=_FP.dim_length(target, :hour), year=y))
    for comp in source["scenarioDataInputFile"]["storage"]
        index = lookup["storage"][comp["id"]]
        for s in 1:_FP.dim_length(target, :scenario)
            target["nw"][first_hour_nws[s]]["storage"]["$index"]["energy"] = comp["initEnergy"][s][y]
            target["nw"][last_hour_nws[s]]["storage"]["$index"]["energy"] = comp["finalEnergy"][s][y]
        end
    end
    if haskey(source, "candidatesInputFile")
        for cand in source["candidatesInputFile"]["storage"]
            comp = cand["storageData"]
            index = lookup["cand_storage"][comp["id"]]
            for s in 1:_FP.dim_length(target, :scenario)
                target["nw"][first_hour_nws[s]]["ne_storage"]["$index"]["energy"] = comp["initEnergy"][s][y]
                target["nw"][last_hour_nws[s]]["ne_storage"]["$index"]["energy"] = comp["finalEnergy"][s][y]
            end
        end
    end
end


text:
using Test, SummationByPartsOperators
using LinearAlgebra

function accuracy_test!(res, ufunc, dufunc, D, direction)
    u = compute_coefficients(ufunc, D)
    du = compute_coefficients(dufunc, D)
    mul!(res, D, u, direction)
    maximum(abs, du-res) < 5*length(res)*eps(eltype(res))
end

# Accuracy Tests
for T in (Float32, Float64)
    xmin = -one(T)
    xmax = one(T)
    ymin = -one(T)
    ymax = one(T)

    for N in 2 .^ (3:6)
        D = fourier_derivative_operator(xmin, xmax, N, ymin, ymax, N)
        println(devnull, D)
        @test SummationByPartsOperators.derivative_order(D) == 1
        @test issymmetric(D) == false
        u = compute_coefficients(zero ∘ eltype, D)
        res = similar(u)
        for k in 0:(N÷2)-1
            ufunc = x->sinpi(k*x[1])
            dufunc = x->eltype(x)(k*π)*cospi(k*x[1])
            @test accuracy_test!(res, ufunc, dufunc, D, Val(:x))
            xplot, duplot = evaluate_coefficients(res, D)
            @test maximum(abs, duplot - dufunc.(xplot)) < 5N*eps(T)
            @test abs(integrate(u, D)) < N*eps(T)

            ufunc = x->cospi(k*x[1])
            dufunc = x->-eltype(x)(k*π)*sinpi(k*x[1])
            @test accuracy_test!(res, ufunc, dufunc, D, Val(:x))
            xplot, duplot = evaluate_coefficients(res, D)
            @test maximum(abs, duplot - dufunc.(xplot)) < 5N*eps(T)
            @test abs(integrate(u, D)) < N*eps(T)

            ufunc = x->sinpi(k*x[2])
            dufunc = x->eltype(x)(k*π)*cospi(k*x[2])
            @test accuracy_test!(res, ufunc, dufunc, D, Val(:y))
            xplot, duplot = evaluate_coefficients(res, D)
            @test maximum(abs, duplot - dufunc.(xplot)) < 5N*eps(T)
            @test abs(integrate(u, D)) < N*eps(T)

            ufunc = x->cospi(k*x[2])
            dufunc = x->-eltype(x)(k*π)*sinpi(k*x[2])
            @test accuracy_test!(res, ufunc, dufunc, D, Val(:y))
            xplot, duplot = evaluate_coefficients(res, D)
            @test maximum(abs, duplot - dufunc.(xplot)) < 5N*eps(T)
            @test abs(integrate(u, D)) < N*eps(T)
        end
    end
end


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

# Instant arithmetic
(+)(x::Instant) = x
(-){T<:Instant}(x::T,y::T) = x.periods - y.periods

# TimeType arithmetic
(+)(x::TimeType) = x
(-){T<:TimeType}(x::T,y::T) = x.instant - y.instant

# TimeType-Year arithmetic
function (+)(dt::DateTime,y::Year)
    oy,m,d = yearmonthday(dt); ny = oy+value(y); ld = daysinmonth(ny,m)
    return DateTime(ny,m,d <= ld ? d : ld,hour(dt),minute(dt),second(dt),millisecond(dt))
end
function (+)(dt::Date,y::Year)
    oy,m,d = yearmonthday(dt); ny = oy+value(y); ld = daysinmonth(ny,m)
    return Date(ny,m,d <= ld ? d : ld)
end
function (-)(dt::DateTime,y::Year)
    oy,m,d = yearmonthday(dt); ny = oy-value(y); ld = daysinmonth(ny,m)
    return DateTime(ny,m,d <= ld ? d : ld,hour(dt),minute(dt),second(dt),millisecond(dt))
end
function (-)(dt::Date,y::Year)
    oy,m,d = yearmonthday(dt); ny = oy-value(y); ld = daysinmonth(ny,m)
    return Date(ny,m,d <= ld ? d : ld)
end

# TimeType-Month arithmetic
# monthwrap adds two months with wraparound behavior (i.e. 12 + 1 == 1)
monthwrap(m1,m2) = (v = mod1(m1+m2,12); return v < 0 ? 12 + v : v)
# yearwrap takes a starting year/month and a month to add and returns
# the resulting year with wraparound behavior (i.e. 2000-12 + 1 == 2001)
yearwrap(y,m1,m2) = y + fld(m1 + m2 - 1,12)

function (+)(dt::DateTime,z::Month)
    y,m,d = yearmonthday(dt)
    ny = yearwrap(y,m,value(z))
    mm = monthwrap(m,value(z)); ld = daysinmonth(ny,mm)
    return DateTime(ny,mm,d <= ld ? d : ld,hour(dt),minute(dt),second(dt),millisecond(dt))
end
function (+)(dt::Date,z::Month)
    y,m,d = yearmonthday(dt)
    ny = yearwrap(y,m,value(z))
    mm = monthwrap(m,value(z)); ld = daysinmonth(ny,mm)
    return Date(ny,mm,d <= ld ? d : ld)
end
function (-)(dt::DateTime,z::Month)
    y,m,d = yearmonthday(dt)
    ny = yearwrap(y,m,-value(z))
    mm = monthwrap(m,-value(z)); ld = daysinmonth(ny,mm)
    return DateTime(ny,mm,d <= ld ? d : ld,hour(dt),minute(dt),second(dt),millisecond(dt))
end
function (-)(dt::Date,z::Month)
    y,m,d = yearmonthday(dt)
    ny = yearwrap(y,m,-value(z))
    mm = monthwrap(m,-value(z)); ld = daysinmonth(ny,mm)
    return Date(ny,mm,d <= ld ? d : ld)
end
(+)(x::Date,y::Week) = return Date(UTD(value(x) + 7*value(y)))
(-)(x::Date,y::Week) = return Date(UTD(value(x) - 7*value(y)))
(+)(x::Date,y::Day)  = return Date(UTD(value(x) + value(y)))
(-)(x::Date,y::Day)  = return Date(UTD(value(x) - value(y)))
(+)(x::DateTime,y::Period)   = return DateTime(UTM(value(x)+toms(y)))
(-)(x::DateTime,y::Period)   = return DateTime(UTM(value(x)-toms(y)))
(+)(y::Period,x::TimeType) = x + y
(-)(y::Period,x::TimeType) = x - y

for op in (:.+, :.-)
    op_ = Symbol(string(op)[2:end])
    @eval begin
        # GeneralPeriod, AbstractArray{TimeType}
        ($op){T<:TimeType}(x::AbstractArray{T}, y::GeneralPeriod) =
            reshape(T[($op_)(i,y) for i in x], size(x))
        ($op){T<:TimeType}(y::GeneralPeriod, x::AbstractArray{T}) = ($op)(x,y)
        ($op_){T<:TimeType}(x::AbstractArray{T}, y::GeneralPeriod) = ($op)(x,y)
        ($op_){T<:TimeType}(y::GeneralPeriod, x::AbstractArray{T}) = ($op)(x,y)

        # TimeType, StridedArray{GeneralPeriod}
        ($op){T<:TimeType,P<:GeneralPeriod}(x::StridedArray{P}, y::T) =
            reshape(T[($op_)(i,y) for i in x], size(x))
        ($op){P<:GeneralPeriod}(y::TimeType, x::StridedArray{P}) = ($op)(x,y)
        ($op_){T<:TimeType,P<:GeneralPeriod}(x::StridedArray{P}, y::T) = ($op)(x,y)
        ($op_){P<:GeneralPeriod}(y::TimeType, x::StridedArray{P}) = ($op)(x,y)
    end
end

# TimeType, AbstractArray{TimeType}
(.-){T<:TimeType}(x::AbstractArray{T}, y::T) = reshape(Period[i - y for i in x], size(x))
(.-){T<:TimeType}(y::T, x::AbstractArray{T}) = -(x .- y)
(-){T<:TimeType}(x::AbstractArray{T}, y::T) = x .- y
(-){T<:TimeType}(y::T, x::AbstractArray{T}) = -(x .- y)

# AbstractArray{TimeType}, AbstractArray{TimeType}
(-){T<:TimeType}(x::OrdinalRange{T}, y::OrdinalRange{T}) = collect(x) - collect(y)
(-){T<:TimeType}(x::Range{T}, y::Range{T}) = collect(x) - collect(y)

max_stars_repo_name: habemus-papadum/julia

max_issues_repo_name: habemus-papadum/julia

max_forks_repo_name: habemus-papadum/julia


text:
# Automatically generated using Clang.jl

const DAQmx_Val_WaitInfinitely = -1.0

@cenum RealTime::Int32 begin
    ConvLateErrorsToWarnings = 8942
    NumOfWarmupIters = 8941
    ReportMissedSamp = 8985
    WaitForNextSampClkWaitMode = 8943
    WriteRecoveryMode = 8986
end

@cenum DOChannel::Int32 begin
    DataXferMech = 8806
    DataXferReqCond = 8807
    GenerateOn = 10601
    InvertLines = 4403
    LineStatesDoneState = 10600
    LineStatesPausedState = 10599
    LineStatesStartState = 10610
    LogicFamily = 10606
    MemMapEnable = 10603
    NumLines = 8569
    OutputDriveType = 4407
    OvercurrentAutoReenable = 10886
    OvercurrentLimit = 10885
    OvercurrentReenablePeriod = 10887
    Tristate = 6387
    UsbXferReqCount = 12291
    UsbXferReqSize = 10897
    UseOnlyOnBrdMem = 8805
end

@cenum Read::Int32 begin
    AccessoryInsertionOrRemovalDetected = 12144
    AutoStart = 6182
    AvailSampPerChan = 4643
    ChangeDetectHasOverflowed = 8596
    ChannelsToRead = 6179
    CommonModeRangeErrorChans = 10905
    CommonModeRangeErrorChansExist = 10904
    CurrReadPos = 4641
    DevsWithInsertedOrRemovedAccessories = 12145
    DigitalLinesBytesPerChan = 8572
    ExcitFaultChans = 12425
    ExcitFaultChansExist = 12424
    NumChans = 8571
    Offset = 6411
    OpenChans = 12545
    OpenChansDetails = 12546
    OpenChansExist = 12544
    OpenCurrentLoopChans = 10762
    OpenCurrentLoopChansExist = 10761
    OpenThrmcplChans = 10903
    OpenThrmcplChansExist = 10902
    OverWrite = 4625
    OvercurrentChans = 10727
    OvercurrentChansExist = 10726
    OverloadedChans = 8565
    OverloadedChansExist = 8564
    OvertemperatureChans = 12418
    OvertemperatureChansExist = 12417
    PLLUnlockedChans = 12569
    PLLUnlockedChansExist = 12568
    RawDataWidth = 8570
    ReadAllAvailSamp = 4629
    RelativeTo = 6410
    SleepTime = 8880
    SyncUnlockedChans = 12606
    SyncUnlockedChansExist = 12605
    TotalSampPerChanAcquired = 6442
    WaitMode = 8754
end

@cenum Buffer::Int32 begin
    InputBufSize = 6252
    InputOnbrdBufSize = 8970
    OutputBufSize = 6253
    OutputOnbrdBufSize = 8971
end

@cenum COChannel::Int32 begin
    AutoIncrCnt = 661
    ConstrainedGenMode = 10738
    Count = 659
    CtrTimebaseActiveEdge = 833
    CtrTimebaseMasterTimebaseDiv = 6339
    CtrTimebaseRate = 6338
    CtrTimebaseSrc = 825
    CtrTimebaseDigFltrEnable = 8822
    CtrTimebaseDigFltrMinPulseWidth = 8823
    CtrTimebaseDigFltrTimebaseRate = 8825
    CtrTimebaseDigFltrTimebaseSrc = 8824
    CtrTimebaseDigSyncEnable = 8826
    DataXferMech = 11980
    DataXferReqCond = 11981
    EnableInitialDelayOnRetrigger = 11977
    MemMapEnable = 11987
    OutputState = 660
    OutputType = 6325
    Prescaler = 8813
    PulseDone = 6414
    PulseDutyCyc = 4470
    PulseFreq = 4472
    PulseFreqInitialDelay = 665
    PulseFreqUnits = 6357
    PulseHighTicks = 4457
    PulseHighTime = 6330
    PulseIdleState = 4464
    PulseLowTicks = 4465
    PulseLowTime = 6331
    PulseTerm = 6369
    PulseTicksInitialDelay = 664
    PulseTimeInitialDelay = 6332
    PulseTimeUnits = 6358
    RdyForNewVal = 8959
    UsbXferReqCount = 12293
    UsbXferReqSize = 10899
    UseOnlyOnBrdMem = 11979
end

@cenum DIChannel::Int32 begin
    AcquireOn = 10598
    DataXferMech = 8803
    DataXferReqCond = 8804
    DigFltrEnable = 8662
    DigFltrEnableBusMode = 12030
    DigFltrMinPulseWidth = 8663
    DigFltrTimebaseRate = 11989
    DigFltrTimebaseSrc = 11988
    DigSyncEnable = 11990
    InvertLines = 1939
    LogicFamily = 10605
    MemMapEnable = 10602
    NumLines = 8568
    Tristate = 6288
    UsbXferReqCount = 12290
    UsbXferReqSize = 10896
end

@cenum ExportedSignal::Int32 begin
    _10MHzRefClkOutputTerm = 8814
    _20MHzTimebaseOutputTerm = 5719
    AIConvClkOutputTerm = 5767
    AIConvClkPulsePolarity = 5768
    AIHoldCmpltEventOutputTerm = 6381
    AIHoldCmpltEventPulsePolarity = 6382
    AdvCmpltEventDelay = 5975
    AdvCmpltEventOutputTerm = 5713
    AdvCmpltEventPulsePolarity = 5714
    AdvCmpltEventPulseWidth = 5716
    AdvTrigOutputTerm = 5701
    AdvTrigPulsePolarity = 5702
    AdvTrigPulseWidth = 5704
    AdvTrigPulseWidthUnits = 5703
    ChangeDetectEventOutputTerm = 8599
    ChangeDetectEventPulsePolarity = 8963
    CtrOutEventOutputBehavior = 5967
    CtrOutEventOutputTerm = 5911
    CtrOutEventPulsePolarity = 5912
    CtrOutEventToggleIdleState = 6250
    DataActiveEventLvlActiveLvl = 5684
    DataActiveEventOutputTerm = 5683
    DividedSampClkTimebaseOutputTerm = 8609
    HshkEventDelay = 8892
    HshkEventInterlockedAssertOnStart = 8894
    HshkEventInterlockedAssertedLvl = 8893
    HshkEventInterlockedDeassertDelay = 8895
    HshkEventOutputBehavior = 8891
    HshkEventOutputTerm = 8890
    HshkEventPulsePolarity = 8896
    HshkEventPulseWidth = 8897
    PauseTrigLvlActiveLvl = 5654
    PauseTrigOutputTerm = 5653
    RdyForStartEventLvlActiveLvl = 5969
    RdyForStartEventOutputTerm = 5641
    RdyForXferEventDeassertCond = 10595
    RdyForXferEventDeassertCondCustomThreshold = 10596
    RdyForXferEventLvlActiveLvl = 8886
    RdyForXferEventOutputTerm = 8885
    RefTrigOutputTerm = 1424
    RefTrigPulsePolarity = 1425
    SampClkTimebaseOutputTerm = 6393
    SampClkDelayOffset = 8644
    SampClkOutputBehavior = 6251
    SampClkOutputTerm = 5731
    SampClkPulsePolarity = 5732
    StartTrigOutputTerm = 1412
    StartTrigPulsePolarity = 1413
    SyncPulseEventOutputTerm = 8764
    WatchdogExpiredEventOutputTerm = 8618
end

@cenum Device::Int32 begin
    AIBridgeRngs = 12240
    AIChargeRngs = 12561
    AICouplings = 10644
    AICurrentIntExcitDiscreteVals = 10699
    AICurrentRngs = 10641
    AIDigFltrLowpassCutoffFreqDiscreteVals = 12488
    AIDigFltrLowpassCutoffFreqRangeVals = 12489
    AIFreqRngs = 10642
    AIGains = 10643
    AILowpassCutoffFreqDiscreteVals = 10645
    AILowpassCutoffFreqRangeVals = 10703
    AIMaxMultiChanRate = 10637
    AIMaxSingleChanRate = 10636
    AIMinRate = 10638
    AINumSampTimingEngines = 12643
    AINumSyncPulseSrcs = 12644
    AIPhysicalChans = 8990
    AIResistanceRngs = 10773
    AISampModes = 12252
    AISimultaneousSamplingSupported = 10639
    AISupportedMeasTypes = 12242
    AITrigUsage = 10630
    AIVoltageIntExcitDiscreteVals = 10697
    AIVoltageIntExcitRangeVals = 10698
    AIVoltageRngs = 10640
    AOCurrentRngs = 10652
    AOGains = 10653
    AOMaxRate = 10647
    AOMinRate = 10648
    AONumSampTimingEngines = 12645
    AONumSyncPulseSrcs = 12646
    AOPhysicalChans = 8991
    AOSampClkSupported = 10646
    AOSampModes = 12253
    AOSupportedOutputTypes = 12243
    AOTrigUsage = 10631
    AOVoltageRngs = 10651
    AccessoryProductNums = 12142
    AccessoryProductTypes = 12141
    AccessorySerialNums = 12143
    AnlgTrigSupported = 10628
    BusType = 8998
    CIMaxSize = 10655
    CIMaxTimebase = 10656
    CIPhysicalChans = 8996
    CISampClkSupported = 10654
    CISampModes = 12254
    CISupportedMeasTypes = 12244
    CITrigUsage = 10634
    COMaxSize = 10657
    COMaxTimebase = 10658
    COPhysicalChans = 8997
    COSampClkSupported = 12123
    COSampModes = 12255
    COSupportedOutputTypes = 12245
    COTrigUsage = 10635
    ChassisModuleDevNames = 10678
    CompactDAQChassisDevName = 10679
    CompactDAQSlotNum = 10680
    CompactRIOChassisDevName = 12641
    CompactRIOSlotNum = 12642
    DILines = 8992
    DIMaxRate = 10649
    DINumSampTimingEngines = 12647
    DIPorts = 8993
    DITrigUsage = 10632
    DOLines = 8994
    DOMaxRate = 10650
    DONumSampTimingEngines = 12648
    DOPorts = 8995
    DOTrigUsage = 10633
    DigTrigSupported = 10629
    IsSimulated = 8906
    NumDMAChans = 9020
    NumTimeTrigs = 12609
    NumTimestampEngines = 12610
    PCIBusNum = 8999
    PCIDevNum = 9000
    PXIChassisNum = 9001
    PXISlotNum = 9002
    ProductCategory = 10665
    ProductNum = 8989
    ProductType = 1585
    SerialNum = 1586
    TCPIPEthernetIP = 10892
    TCPIPHostname = 10891
    TCPIPWirelessIP = 10893
    TEDSHWTEDSSupported = 12246
    Terminals = 10816
    TimeTrigSupported = 12319
end

@cenum CIChannel::Int32 begin
    AngEncoderInitialAngle = 2177
    AngEncoderPulsesPerRev = 2165
    AngEncoderUnits = 6310
    Count = 328
    CountEdgesActiveEdge = 1687
    CountEdgesCountDirDigFltrEnable = 8689
    CountEdgesCountDirDigFltrMinPulseWidth = 8690
    CountEdgesCountDirDigFltrTimebaseRate = 8692
    CountEdgesCountDirDigFltrTimebaseSrc = 8691
    CountEdgesCountDirDigSyncEnable = 8693
    CountEdgesCountDirLogicLvlBehavior = 12446
    CountEdgesCountDirTermCfg = 12445
    CountEdgesCountResetActiveEdge = 12210
    CountEdgesCountResetDigFltrEnable = 12211
    CountEdgesCountResetDigFltrMinPulseWidth = 12212
    CountEdgesCountResetDigFltrTimebaseRate = 12214
    CountEdgesCountResetDigFltrTimebaseSrc = 12213
    CountEdgesCountResetDigSyncEnable = 12215
    CountEdgesCountResetEnable = 12207
    CountEdgesCountResetLogicLvlBehavior = 12448
    CountEdgesCountResetResetCount = 12208
    CountEdgesCountResetTerm = 12209
    CountEdgesCountResetTermCfg = 12447
    CountEdgesDigFltrEnable = 8694
    CountEdgesDigFltrMinPulseWidth = 8695
    CountEdgesDigFltrTimebaseRate = 8697
    CountEdgesDigFltrTimebaseSrc = 8696
    CountEdgesDigSyncEnable = 8698
    CountEdgesDir = 1686
    CountEdgesDirTerm = 8673
    CountEdgesGateWhen = 12533
    CountEdgesGateDigFltrEnable = 12529
    CountEdgesGateDigFltrMinPulseWidth = 12530
    CountEdgesGateDigFltrTimebaseRate = 12532
    CountEdgesGateDigFltrTimebaseSrc = 12531
    CountEdgesGateEnable = 12525
    CountEdgesGateLogicLvlBehavior = 12528
    CountEdgesGateTerm = 12526
    CountEdgesGateTermCfg = 12527
    CountEdgesInitialCnt = 1688
    CountEdgesLogicLvlBehavior = 12444
    CountEdgesTerm = 6343
    CountEdgesTermCfg = 12443
    CtrTimebaseActiveEdge = 322
    CtrTimebaseMasterTimebaseDiv = 6323
    CtrTimebaseRate = 6322
    CtrTimebaseSrc = 323
    CtrTimebaseDigFltrEnable = 8817
    CtrTimebaseDigFltrMinPulseWidth = 8818
    CtrTimebaseDigFltrTimebaseRate = 8820
    CtrTimebaseDigFltrTimebaseSrc = 8819
    CtrTimebaseDigSyncEnable = 8821
    CustomScaleName = 6302
    DataXferMech = 512
    DataXferReqCond = 12027
    DupCountPrevent = 8620
    DutyCycleDigFltrEnable = 12430
    DutyCycleDigFltrMinPulseWidth = 12431
    DutyCycleDigFltrTimebaseRate = 12433
    DutyCycleDigFltrTimebaseSrc = 12432
    DutyCycleLogicLvlBehavior = 12450
    DutyCycleStartingEdge = 12434
    DutyCycleTerm = 12429
    DutyCycleTermCfg = 12449
    EncoderAInputLogicLvlBehavior = 12452
    EncoderAInputTerm = 8605
    EncoderAInputTermCfg = 12451
    EncoderAInputDigFltrEnable = 8699
    EncoderAInputDigFltrMinPulseWidth = 8700
    EncoderAInputDigFltrTimebaseRate = 8702
    EncoderAInputDigFltrTimebaseSrc = 8701
    EncoderAInputDigSyncEnable = 8703
    EncoderBInputLogicLvlBehavior = 12454
    EncoderBInputTerm = 8606
    EncoderBInputTermCfg = 12453
    EncoderBInputDigFltrEnable = 8704
    EncoderBInputDigFltrMinPulseWidth = 8705
    EncoderBInputDigFltrTimebaseRate = 8707
    EncoderBInputDigFltrTimebaseSrc = 8706
    EncoderBInputDigSyncEnable = 8708
    EncoderDecodingType = 8678
    EncoderZIndexEnable = 2192
    EncoderZIndexPhase = 2185
    EncoderZIndexVal = 2184
    EncoderZInputLogicLvlBehavior = 12456
    EncoderZInputTerm = 8607
    EncoderZInputTermCfg = 12455
    EncoderZInputDigFltrEnable = 8709
    EncoderZInputDigFltrMinPulseWidth = 8710
    EncoderZInputDigFltrTimebaseRate = 8712
    EncoderZInputDigFltrTimebaseSrc = 8711
    EncoderZInputDigSyncEnable = 8713
    FreqDigFltrEnable = 8679
    FreqDigFltrMinPulseWidth = 8680
    FreqDigFltrTimebaseRate = 8682
    FreqDigFltrTimebaseSrc = 8681
    FreqDigSyncEnable = 8683
    FreqDiv = 327
    FreqEnableAveraging = 11984
    FreqLogicLvlBehavior = 12440
    FreqMeasMeth = 324
    FreqMeasTime = 325
    FreqStartingEdge = 1945
    FreqTerm = 6306
    FreqTermCfg = 12439
    FreqUnits = 6305
    GPSSyncMethod = 4242
    GPSSyncSrc = 4243
    LinEncoderDistPerPulse = 2321
    LinEncoderInitialPos = 2325
    LinEncoderUnits = 6313
    Max = 6300
    MaxMeasPeriod = 12437
    MeasType = 6304
    MemMapEnable = 11986
    Min = 6301
    NumPossiblyInvalidSamps = 6460
    OutputState = 329
    PeriodDigFltrEnable = 8684
    PeriodDigFltrMinPulseWidth = 8685
    PeriodDigFltrTimebaseRate = 8687
    PeriodDigFltrTimebaseSrc = 8686
    PeriodDigSyncEnable = 8688
    PeriodDiv = 6446
    PeriodEnableAveraging = 11985
    PeriodLogicLvlBehavior = 12442
    PeriodMeasMeth = 6444
    PeriodMeasTime = 6445
    PeriodStartingEdge = 2130
    PeriodTerm = 6308
    PeriodTermCfg = 12441
    PeriodUnits = 6307
    Prescaler = 8761
    PulseWidthDigFltrEnable = 8714
    PulseWidthDigFltrMinPulseWidth = 8715
    PulseWidthDigFltrTimebaseRate = 8717
    PulseWidthDigFltrTimebaseSrc = 8716
    PulseWidthDigSyncEnable = 8718
    PulseWidthLogicLvlBehavior = 12458
    PulseWidthStartingEdge = 2085
    PulseWidthTerm = 6314
    PulseWidthTermCfg = 12457
    PulseWidthUnits = 2083
    PulseFreqDigFltrEnable = 12038
    PulseFreqDigFltrMinPulseWidth = 12039
    PulseFreqDigFltrTimebaseRate = 12041
    PulseFreqDigFltrTimebaseSrc = 12040
    PulseFreqDigSyncEnable = 12042
    PulseFreqLogicLvlBehavior = 12466
    PulseFreqStartEdge = 12037
    PulseFreqTerm = 12036
    PulseFreqTermCfg = 12465
    PulseFreqUnits = 12043
    PulseTicksDigFltrEnable = 12054
    PulseTicksDigFltrMinPulseWidth = 12055
    PulseTicksDigFltrTimebaseRate = 12057
    PulseTicksDigFltrTimebaseSrc = 12056
    PulseTicksDigSyncEnable = 12058
    PulseTicksLogicLvlBehavior = 12470
    PulseTicksStartEdge = 12053
    PulseTicksTerm = 12052
    PulseTicksTermCfg = 12469
    PulseTimeDigFltrEnable = 12046
    PulseTimeDigFltrMinPulseWidth = 12047
    PulseTimeDigFltrTimebaseRate = 12049
    PulseTimeDigFltrTimebaseSrc = 12048
    PulseTimeDigSyncEnable = 12050
    PulseTimeLogicLvlBehavior = 12468
    PulseTimeStartEdge = 12045
    PulseTimeTerm = 12044
    PulseTimeTermCfg = 12467
    PulseTimeUnits = 12051
    SampClkOverrunBehavior = 12435
    SampClkOverrunSentinelVal = 12436
    SemiPeriodDigFltrEnable = 8729
    SemiPeriodDigFltrMinPulseWidth = 8730
    SemiPeriodDigFltrTimebaseRate = 8732
    SemiPeriodDigFltrTimebaseSrc = 8731
    SemiPeriodDigSyncEnable = 8733
    SemiPeriodLogicLvlBehavior = 12464
    SemiPeriodStartingEdge = 8958
    SemiPeriodTerm = 6320
    SemiPeriodTermCfg = 12463
    SemiPeriodUnits = 6319
    TCReached = 336
    ThreshVoltage = 12471
    TimestampInitialSeconds = 8884
    TimestampUnits = 8883
    TwoEdgeSepFirstEdge = 2099
    TwoEdgeSepFirstLogicLvlBehavior = 12460
    TwoEdgeSepFirstTerm = 6317
    TwoEdgeSepFirstTermCfg = 12459
    TwoEdgeSepFirstDigFltrEnable = 8719
    TwoEdgeSepFirstDigFltrMinPulseWidth = 8720
    TwoEdgeSepFirstDigFltrTimebaseRate = 8722
    TwoEdgeSepFirstDigFltrTimebaseSrc = 8721
    TwoEdgeSepFirstDigSyncEnable = 8723
    TwoEdgeSepSecondEdge = 2100
    TwoEdgeSepSecondLogicLvlBehavior = 12462
    TwoEdgeSepSecondTerm = 6318
    TwoEdgeSepSecondTermCfg = 12461
    TwoEdgeSepSecondDigFltrEnable = 8724
    TwoEdgeSepSecondDigFltrMinPulseWidth = 8725
    TwoEdgeSepSecondDigFltrTimebaseRate = 8727
    TwoEdgeSepSecondDigFltrTimebaseSrc = 8726
    TwoEdgeSepSecondDigSyncEnable = 8728
    TwoEdgeSepUnits = 6316
    UsbXferReqCount = 12292
    UsbXferReqSize = 10898
    VelocityAngEncoderPulsesPerRev = 12505
    VelocityAngEncoderUnits = 12504
    VelocityDiv = 12524
    VelocityEncoderAInputDigFltrEnable = 12512
    VelocityEncoderAInputDigFltrMinPulseWidth = 12513
    VelocityEncoderAInputDigFltrTimebaseRate = 12515
    VelocityEncoderAInputDigFltrTimebaseSrc = 12514
    VelocityEncoderAInputLogicLvlBehavior = 12511
    VelocityEncoderAInputTerm = 12509
    VelocityEncoderAInputTermCfg = 12510
    VelocityEncoderBInputDigFltrEnable = 12519
    VelocityEncoderBInputDigFltrMinPulseWidth = 12520
    VelocityEncoderBInputDigFltrTimebaseRate = 12522
    VelocityEncoderBInputDigFltrTimebaseSrc = 12521
    VelocityEncoderBInputLogicLvlBehavior = 12518
    VelocityEncoderBInputTerm = 12516
    VelocityEncoderBInputTermCfg = 12517
    VelocityEncoderDecodingType = 12508
    VelocityLinEncoderDistPerPulse = 12507
    VelocityLinEncoderUnits = 12506
    VelocityMeasTime = 12523
end

@cenum PersistedChannel::Int32 begin
    AllowInteractiveDeletion = 8914
    AllowInteractiveEditing = 8913
    Author = 8912
end

@cenum Task::Int32 begin
    Channels = 4723
    Complete = 4724
    Devices = 8974
    Name = 4726
    NumChans = 8577
    NumDevices = 10682
end

@cenum AOChannel::Int32 begin
    CurrentUnits = 4361
    CustomScaleName = 4488
    DACOffsetExtSrc = 8788
    DACOffsetSrc = 8787
    DACOffsetVal = 8789
    DACRefAllowConnToGnd = 6192
    DACRefConnToGnd = 304
    DACRefExtSrc = 8786
    DACRefSrc = 306
    DACRefVal = 6194
    DACRngHigh = 6190
    DACRngLow = 6189
    DataXferMech = 308
    DataXferReqCond = 6204
    DevScalingCoeff = 6449
    EnhancedImageRejectionEnable = 8769
    FilterDelay = 12405
    FilterDelayAdjustment = 12402
    FilterDelayUnits = 12406
    FuncGenAmplitude = 10778
    FuncGenFMDeviation = 10787
    FuncGenFreq = 10777
    FuncGenModulationType = 10786
    FuncGenOffset = 10779
    FuncGenSquareDutyCycle = 10780
    FuncGenType = 10776
    Gain = 280
    IdleOutputBehavior = 8768
    LoadImpedance = 289
    Max = 4486
    MemMapEnable = 6287
    Min = 4487
    OutputImpedance = 5264
    OutputType = 4360
    PowerAmpChannelEnable = 12386
    PowerAmpGain = 12389
    PowerAmpOffset = 12390
    PowerAmpOvercurrent = 12388
    PowerAmpScalingCoeff = 12387
    ReglitchEnable = 307
    Resolution = 6188
    ResolutionUnits = 6187
    TermCfg = 6286
    UsbXferReqCount = 12289
    UsbXferReqSize = 10895
    UseOnlyOnBrdMem = 6202
    VoltageCurrentLimit = 10781
    VoltageUnits = 4484
end

@cenum PersistedScale::Int32 begin
    AllowInteractiveDeletion = 8918
    AllowInteractiveEditing = 8917
    Author = 8916
end

@cenum PhysicalChannel::Int32 begin
    AIInputSrcs = 12248
    AIPowerControlEnable = 12653
    AIPowerControlType = 12654
    AIPowerControlVoltage = 12652
    AISensorPowerOpenChan = 12668
    AISensorPowerOvercurrent = 12669
    AISensorPowerTypes = 12665
    AISensorPowerVoltageRangeVals = 12666
    AISupportedMeasTypes = 12247
    AITermCfgs = 9026
    AOManualControlAmplitude = 10783
    AOManualControlEnable = 10782
    AOManualControlFreq = 10784
    AOManualControlShortDetected = 11971
    AOSupportedOutputTypes = 12249
    AOSupportedPowerUpOutputTypes = 12366
    AOTermCfgs = 10659
    CISupportedMeasTypes = 12250
    COSupportedOutputTypes = 12251
    DIChangeDetectSupported = 10662
    DIPortWidth = 10660
    DISampClkSupported = 10661
    DISampModes = 12256
    DOPortWidth = 10663
    DOSampClkSupported = 10664
    DOSampModes = 12257
    TEDSBitStream = 8671
    TEDSMfgID = 8666
    TEDSModelNum = 8667
    TEDSSerialNum = 8668
    TEDSTemplateIDs = 8847
    TEDSVersionLetter = 8670
    TEDSVersionNum = 8669
end

@cenum AIChannel::Int32 begin
    ACExcitFreq = 257
    ACExcitSyncEnable = 258
    ACExcitWireMode = 6349
    ADCCustomTimingMode = 12139
    ADCTimingMode = 10745
    Accel4WireDCVoltageSensitivity = 12565
    Accel4WireDCVoltageSensitivityUnits = 12566
    AccelChargeSensitivity = 12563
    AccelChargeSensitivityUnits = 12564
    AccelSensitivity = 1682
    AccelSensitivityUnits = 8604
    AccelUnits = 1651
    AcceldBRef = 10674
    Atten = 6145
    AutoZeroMode = 5984
    AveragingWinSize = 12270
    BridgeBalanceCoarsePot = 6129
    BridgeBalanceFinePot = 6388
    BridgeCfg = 135
    BridgeElectricalUnits = 12167
    BridgeInitialRatio = 12166
    BridgeInitialVoltage = 6125
    BridgeNomResistance = 6124
    BridgePhysicalUnits = 12168
    BridgePolyForwardCoeff = 12176
    BridgePolyReverseCoeff = 12177
    BridgeScaleType = 12169
    BridgeShuntCalEnable = 148
    BridgeShuntCalGainAdjust = 6463
    BridgeShuntCalSelect = 8661
    BridgeShuntCalShuntCalAActualResistance = 12153
    BridgeShuntCalShuntCalAResistance = 12152
    BridgeShuntCalShuntCalASrc = 12490
    BridgeShuntCalShuntCalBActualResistance = 12155
    BridgeShuntCalShuntCalBResistance = 12154
    BridgeTableElectricalVals = 12174
    BridgeTablePhysicalVals = 12175
    BridgeTwoPointLinFirstElectricalVal = 12170
    BridgeTwoPointLinFirstPhysicalVal = 12171
    BridgeTwoPointLinSecondElectricalVal = 12172
    BridgeTwoPointLinSecondPhysicalVal = 12173
    BridgeUnits = 12178
    ChanCalApplyCalIfExp = 8857
    ChanCalDesc = 8868
    ChanCalEnableCal = 8856
    ChanCalHasValidCalInfo = 8855
    ChanCalOperatorName = 8867
    ChanCalPolyForwardCoeff = 8863
    ChanCalPolyReverseCoeff = 8864
    ChanCalScaleType = 8860
    ChanCalTablePreScaledVals = 8861
    ChanCalTableScaledVals = 8862
    ChanCalVerifAcqVals = 8866
    ChanCalVerifRefVals = 8865
    ChargeUnits = 12562
    ChopEnable = 12611
    Coupling = 100
    CurrentShuntLoc = 6130
    CurrentShuntResistance = 6131
    CurrentACRMSUnits = 6115
    CurrentUnits = 1793
    CustomScaleName = 6112
    DCOffset = 10889
    DataXferCustomThreshold = 8972
    DataXferMaxRate = 12567
    DataXferMech = 6177
    DataXferReqCond = 6283
    DevScalingCoeff = 6448
    DigFltrBandpassCenterFreq = 12483
    DigFltrBandpassWidth = 12484
    DigFltrCoeff = 12487
    DigFltrEnable = 12477
    DigFltrHighpassCutoffFreq = 12482
    DigFltrLowpassCutoffFreq = 12481
    DigFltrNotchCenterFreq = 12485
    DigFltrNotchWidth = 12486
    DigFltrOrder = 12480
    DigFltrResponse = 12479
    DigFltrType = 12478
    DigFltrTypes = 12551
    DitherEnable = 104
    EddyCurrentProxProbeSensitivity = 10942
    EddyCurrentProxProbeSensitivityUnits = 10943
    EddyCurrentProxProbeUnits = 10944
    EnhancedAliasRejectionEnable = 8852
    ExcitActualVal = 6275
    ExcitDCorAC = 6139
    ExcitIdleOutputBehavior = 12472
    ExcitSense = 12541
    ExcitSrc = 6132
    ExcitUseForScaling = 6140
    ExcitUseMultiplexed = 8576
    ExcitVal = 6133
    ExcitVoltageOrCurrent = 6134
    FilterDelay = 12269
    FilterDelayAdjustment = 12404
    FilterDelayUnits = 12401
    FilterEnable = 12659
    FilterFreq = 12660
    FilterOrder = 12662
    FilterResponse = 12661
    ForceReadFromChan = 6392
    ForceIEPESensorSensitivity = 12161
    ForceIEPESensorSensitivityUnits = 12162
    ForceUnits = 12149
    FreqHyst = 2068
    FreqThreshVoltage = 2069
    FreqUnits = 2054
    Gain = 6168
    Impedance = 98
    InputSrc = 8600
    IsTEDS = 10627
    LVDTSensitivity = 2361
    LVDTSensitivityUnits = 8602
    LVDTUnits = 2320
    LeadWireResistance = 6126
    LossyLSBRemovalCompressedSampSize = 8921
    LowpassCutoffFreq = 6147
    LowpassEnable = 6146
    LowpassSwitchCapClkSrc = 6276
    LowpassSwitchCapExtClkDiv = 6278
    LowpassSwitchCapExtClkFreq = 6277
    LowpassSwitchCapOutClkDiv = 6279
    Max = 6109
    MeasType = 1685
    MemMapEnable = 6284
    MicrophoneSensitivity = 5430
    Min = 6110
    OpenChanDetectEnable = 12543
    OpenThrmcplDetectEnable = 12146
    PressureUnits = 12150
    ProbeAtten = 10888
    RTDA = 4112
    RTDB = 4113
    RTDC = 4115
    RTDR0 = 4144
    RTDType = 4146
    RVDTSensitivity = 2307
    RVDTSensitivityUnits = 8603
    RVDTUnits = 2167
    RawDataCompressionType = 8920
    RawSampJustification = 80
    RawSampSize = 8922
    RemoveFilterDelay = 12221
    ResistanceCfg = 6273
    ResistanceUnits = 2389
    Resolution = 5989
    ResolutionUnits = 5988
    RngHigh = 6165
    RngLow = 6166
    RosetteStrainGageOrientation = 12284
    RosetteStrainGageRosetteMeasType = 12285
    RosetteStrainGageRosetteType = 12286
    RosetteStrainGageStrainChans = 12283
    SampAndHoldEnable = 6170
    SensorPowerCfg = 12650
    SensorPowerType = 12651
    SensorPowerVoltage = 12649
    SoundPressureMaxSoundPressureLvl = 8762
    SoundPressureUnits = 5416
    SoundPressuredBRef = 10673
    StrainGageCfg = 2434
    StrainGageForceReadFromChan = 12282
    StrainGageGageFactor = 2452
    StrainGagePoissonRatio = 2456
    StrainUnits = 2433
    TEDSUnits = 8672
    TempUnits = 4147
    TermCfg = 4247
    ThrmcplCJCChan = 4148
    ThrmcplCJCSrc = 4149
    ThrmcplCJCVal = 4150
    ThrmcplLeadOffsetVoltage = 12216
    ThrmcplScaleType = 10704
    ThrmcplType = 4176
    ThrmstrA = 6345
    ThrmstrB = 6347
    ThrmstrC = 6346
    ThrmstrR1 = 4193
    TorqueUnits = 12151
    UsbXferReqCount = 12288
    UsbXferReqSize = 10894
    VelocityIEPESensorSensitivity = 12278
    VelocityIEPESensorSensitivityUnits = 12279
    VelocityIEPESensordBRef = 12277
    VelocityUnits = 12276
    VoltageACRMSUnits = 6114
    VoltageUnits = 4244
    VoltagedBRef = 10672
end

@cenum PersistedTask::Int32 begin
    AllowInteractiveDeletion = 8910
    AllowInteractiveEditing = 8909
    Author = 8908
end

@cenum Scale::Int32 begin
    Descr = 4646
    LinSlope = 4647
    LinYIntercept = 4648
    MapPreScaledMax = 4657
    MapPreScaledMin = 4658
    MapScaledMax = 4649
    MapScaledMin = 4656
    PolyForwardCoeff = 4660
    PolyReverseCoeff = 4661
    PreScaledUnits = 6391
    ScaledUnits = 6427
    TablePreScaledVals = 4663
    TableScaledVals = 4662
    Type = 6441
end

@cenum Write::Int32 begin
    AccessoryInsertionOrRemovalDetected = 12371
    CurrWritePos = 5208
    DevsWithInsertedOrRemovedAccessories = 12372
    DigitalLinesBytesPerChan = 8575
    ExternalOvervoltageChans = 12476
    ExternalOvervoltageChansExist = 12475
    NumChans = 8574
    Offset = 6413
    OpenCurrentLoopChans = 10731
    OpenCurrentLoopChansExist = 10730
    OvercurrentChans = 10729
    OvercurrentChansExist = 10728
    OverloadedChans = 12421
    OverloadedChansExist = 12420
    OvertemperatureChans = 12419
    OvertemperatureChansExist = 10884
    PowerSupplyFaultChans = 10733
    PowerSupplyFaultChansExist = 10732
    RawDataWidth = 8573
    RegenMode = 5203
    RelativeTo = 6412
    SleepTime = 8882
    SpaceAvail = 5216
    SyncUnlockedChans = 12608
    SyncUnlockedChansExist = 12607
    TotalSampPerChanGenerated = 6443
    WaitMode = 8881
end

@cenum DAQmxAttribute::Int32 begin
    AIConv_ActiveEdge = 6227
    AIConv_DigFltr_Enable = 11996
    AIConv_DigFltr_MinPulseWidth = 11997
    AIConv_DigFltr_TimebaseRate = 11999
    AIConv_DigFltr_TimebaseSrc = 11998
    AIConv_DigSync_Enable = 12000
    AIConv_MaxRate = 8905
    AIConv_Rate = 6216
    AIConv_Src = 5378
    AIConv_TimebaseDiv = 4917
    AIConv_Timebase_Src = 4921
    AdvTrig_Type = 4965
    AnlgEdge_RefTrig_Coupling = 8757
    AnlgEdge_RefTrig_DigFltr_Enable = 12006
    AnlgEdge_RefTrig_DigFltr_MinPulseWidth = 12007
    AnlgEdge_RefTrig_DigFltr_TimebaseRate = 12009
    AnlgEdge_RefTrig_DigFltr_TimebaseSrc = 12008
    AnlgEdge_RefTrig_DigSync_Enable = 12010
    AnlgEdge_RefTrig_Hyst = 5153
    AnlgEdge_RefTrig_Lvl = 5154
    AnlgEdge_RefTrig_Slope = 5155
    AnlgEdge_RefTrig_Src = 5156
    AnlgEdge_StartTrig_Coupling = 8755
    AnlgEdge_StartTrig_DigFltr_Enable = 12001
    AnlgEdge_StartTrig_DigFltr_MinPulseWidth = 12002
    AnlgEdge_StartTrig_DigFltr_TimebaseRate = 12004
    AnlgEdge_StartTrig_DigFltr_TimebaseSrc = 12003
    AnlgEdge_StartTrig_DigSync_Enable = 12005
    AnlgEdge_StartTrig_Hyst = 5013
    AnlgEdge_StartTrig_Lvl = 5014
    AnlgEdge_StartTrig_Slope = 5015
    AnlgEdge_StartTrig_Src = 5016
    AnlgLvl_PauseTrig_Coupling = 8758
    AnlgLvl_PauseTrig_DigFltr_Enable = 12016
    AnlgLvl_PauseTrig_DigFltr_MinPulseWidth = 12017
    AnlgLvl_PauseTrig_DigFltr_TimebaseRate = 12019
    AnlgLvl_PauseTrig_DigFltr_TimebaseSrc = 12018
    AnlgLvl_PauseTrig_DigSync_Enable = 12020
    AnlgLvl_PauseTrig_Hyst = 4968
    AnlgLvl_PauseTrig_Lvl = 4969
    AnlgLvl_PauseTrig_Src = 4976
    AnlgLvl_PauseTrig_When = 4977
    AnlgMultiEdge_RefTrig_Couplings = 12586
    AnlgMultiEdge_RefTrig_Hysts = 12585
    AnlgMultiEdge_RefTrig_Lvls = 12584
    AnlgMultiEdge_RefTrig_Slopes = 12583
    AnlgMultiEdge_RefTrig_Srcs = 12582
    AnlgMultiEdge_StartTrig_Couplings = 12581
    AnlgMultiEdge_StartTrig_Hysts = 12580
    AnlgMultiEdge_StartTrig_Lvls = 12579
    AnlgMultiEdge_StartTrig_Slopes = 12578
    AnlgMultiEdge_StartTrig_Srcs = 12577
    AnlgWin_PauseTrig_Btm = 4981
    AnlgWin_PauseTrig_Coupling = 8759
    AnlgWin_PauseTrig_DigFltr_Enable = 12021
    AnlgWin_PauseTrig_DigFltr_MinPulseWidth = 12022
    AnlgWin_PauseTrig_DigFltr_TimebaseRate = 12024
    AnlgWin_PauseTrig_DigFltr_TimebaseSrc = 12023
    AnlgWin_PauseTrig_DigSync_Enable = 12025
    AnlgWin_PauseTrig_Src = 4979
    AnlgWin_PauseTrig_Top = 4982
    AnlgWin_PauseTrig_When = 4980
    AnlgWin_RefTrig_Btm = 5160
    AnlgWin_RefTrig_Coupling = 6231
    AnlgWin_RefTrig_DigFltr_Enable = 12011
    AnlgWin_RefTrig_DigFltr_MinPulseWidth = 12012
    AnlgWin_RefTrig_DigFltr_TimebaseRate = 12014
    AnlgWin_RefTrig_DigFltr_TimebaseSrc = 12013
    AnlgWin_RefTrig_DigSync_Enable = 12015
    AnlgWin_RefTrig_Src = 5158
    AnlgWin_RefTrig_Top = 5161
    AnlgWin_RefTrig_When = 5159
    AnlgWin_StartTrig_Btm = 5122
    AnlgWin_StartTrig_Coupling = 8756
    AnlgWin_StartTrig_DigFltr_Enable = 12031
    AnlgWin_StartTrig_DigFltr_MinPulseWidth = 12032
    AnlgWin_StartTrig_DigFltr_TimebaseRate = 12034
    AnlgWin_StartTrig_DigFltr_TimebaseSrc = 12033
    AnlgWin_StartTrig_DigSync_Enable = 12035
    AnlgWin_StartTrig_Src = 5120
    AnlgWin_StartTrig_Top = 5123
    AnlgWin_StartTrig_When = 5121
    ArmStartTrig_Timescale = 12594
    ArmStartTrig_TimestampEnable = 12595
    ArmStartTrig_TimestampTimescale = 12597
    ArmStartTrig_TimestampVal = 12596
    ArmStartTrig_TrigWhen = 12593
    ArmStartTrig_Type = 5140
    ArmStart_Term = 12159
    Cal_AccConnectionCount = 12267
    Cal_DevTemp = 8763
    Cal_RecommendedAccConnectionCountLimit = 12268
    Cal_UserDefinedInfo = 6241
    Cal_UserDefinedInfo_MaxSize = 6428
    Carrier_SerialNum = 10890
    ChanDescr = 6438
    ChanIsGlobal = 8964
    ChanType = 6271
    Chan_SyncUnlockBehavior = 12604
    ChangeDetect_DI_FallingEdgePhysicalChans = 8598
    ChangeDetect_DI_RisingEdgePhysicalChans = 8597
    ChangeDetect_DI_Tristate = 12026
    DelayFromSampClk_Delay = 4887
    DelayFromSampClk_DelayUnits = 4868
    DigEdge_AdvTrig_DigFltr_Enable = 8760
    DigEdge_AdvTrig_Edge = 4960
    DigEdge_AdvTrig_Src = 4962
    DigEdge_ArmStartTrig_DigFltr_Enable = 8749
    DigEdge_ArmStartTrig_DigFltr_MinPulseWidth = 8750
    DigEdge_ArmStartTrig_DigFltr_TimebaseRate = 8752
    DigEdge_ArmStartTrig_DigFltr_TimebaseSrc = 8751
    DigEdge_ArmStartTrig_DigSync_Enable = 8753
    DigEdge_ArmStartTrig_Edge = 5141
    DigEdge_ArmStartTrig_Src = 5143
    DigEdge_RefTrig_DigFltr_Enable = 11991
    DigEdge_RefTrig_DigFltr_MinPulseWidth = 11992
    DigEdge_RefTrig_DigFltr_TimebaseRate = 11994
    DigEdge_RefTrig_DigFltr_TimebaseSrc = 11993
    DigEdge_RefTrig_DigSync_Enable = 11995
    DigEdge_RefTrig_Edge = 5168
    DigEdge_RefTrig_Src = 5172
    DigEdge_StartTrig_DigFltr_Enable = 8739
    DigEdge_StartTrig_DigFltr_MinPulseWidth = 8740
    DigEdge_StartTrig_DigFltr_TimebaseRate = 8742
    DigEdge_StartTrig_DigFltr_TimebaseSrc = 8741
    DigEdge_StartTrig_DigSync_Enable = 8743
    DigEdge_StartTrig_Edge = 5124
    DigEdge_StartTrig_Src = 5127
    DigEdge_WatchdogExpirTrig_Edge = 8613
    DigEdge_WatchdogExpirTrig_Src = 8612
    DigLvl_PauseTrig_DigFltr_Enable = 8744
    DigLvl_PauseTrig_DigFltr_MinPulseWidth = 8745
    DigLvl_PauseTrig_DigFltr_TimebaseRate = 8747
    DigLvl_PauseTrig_DigFltr_TimebaseSrc = 8746
    DigLvl_PauseTrig_DigSync_Enable = 8748
    DigLvl_PauseTrig_Src = 4985
    DigLvl_PauseTrig_When = 4992
    DigPattern_PauseTrig_Pattern = 8584
    DigPattern_PauseTrig_Src = 8559
    DigPattern_PauseTrig_When = 8560
    DigPattern_RefTrig_Pattern = 8583
    DigPattern_RefTrig_Src = 5175
    DigPattern_RefTrig_When = 5176
    DigPattern_StartTrig_Pattern = 8582
    DigPattern_StartTrig_Src = 5136
    DigPattern_StartTrig_When = 5137
    ExtCal_LastTemp = 6247
    ExtCal_RecommendedInterval = 6248
    FieldDAQ_BankDevNames = 12664
    FieldDAQ_DevName = 12657
    FirstSampClk_Timescale = 12675
    FirstSampClk_When = 12674
    FirstSampTimestamp_Enable = 12601
    FirstSampTimestamp_Timescale = 12603
    FirstSampTimestamp_Val = 12602
    HshkTrig_Type = 8887
    Hshk_DelayAfterXfer = 8898
    Hshk_SampleInputDataWhen = 8900
    Hshk_StartCond = 8899
    Implicit_UnderflowBehavior = 12029
    Interlocked_HshkTrig_AssertedLvl = 8889
    Interlocked_HshkTrig_Src = 8888
    Logging_FilePath = 11972
    Logging_FilePreallocationSize = 12230
    Logging_FileWriteSize = 12227
    Logging_Mode = 11973
    Logging_Pause = 12259
    Logging_SampsPerFile = 12260
    Logging_TDMS_GroupName = 11974
    Logging_TDMS_Operation = 11975
    MasterTimebase_Rate = 5269
    MasterTimebase_Src = 4931
    OnDemand_SimultaneousAOEnable = 8608
    PauseTrig_Term = 12064
    PauseTrig_Type = 4966
    PhysicalChanName = 6389
    RefClk_Rate = 4885
    RefClk_Src = 4886
    RefTrig_AutoTrigEnable = 11969
    RefTrig_AutoTriggered = 11970
    RefTrig_Delay = 5251
    RefTrig_MaxNumTrigsToDetect = 12576
    RefTrig_PretrigSamples = 5189
    RefTrig_RetriggerWin = 12575
    RefTrig_Retriggerable = 12573
    RefTrig_Term = 12063
    RefTrig_TimestampEnable = 12590
    RefTrig_TimestampTimescale = 12592
    RefTrig_TimestampVal = 12591
    RefTrig_TrigWin = 12574
    RefTrig_Type = 5145
    SampClkTimebase_Term = 12060
    SampClk_ActiveEdge = 4865
    SampClk_DigFltr_Enable = 8734
    SampClk_DigFltr_MinPulseWidth = 8735
    SampClk_DigFltr_TimebaseRate = 8737
    SampClk_DigFltr_TimebaseSrc = 8736
    SampClk_DigSync_Enable = 8738
    SampClk_MaxRate = 8904
    SampClk_OverrunBehavior = 12028
    SampClk_Rate = 4932
    SampClk_Src = 6226
    SampClk_Term = 12059
    SampClk_TimebaseDiv = 6379
    SampClk_Timebase_ActiveEdge = 6380
    SampClk_Timebase_MasterTimebaseDiv = 4869
    SampClk_Timebase_Rate = 4867
    SampClk_Timebase_Src = 4872
    SampClk_UnderflowBehavior = 10593
    SampClk_WriteWfm_UseInitialWfmDT = 12540
    SampQuant_SampMode = 4864
    SampQuant_SampPerChan = 4880
    SampTimingEngine = 10790
    SampTimingType = 4935
    SelfCal_LastTemp = 6244
    SelfCal_Supported = 6240
    StartTrig_Delay = 6230
    StartTrig_DelayUnits = 6344
    StartTrig_MaxNumTrigsToDetect = 12572
    StartTrig_RetriggerWin = 12571
    StartTrig_Retriggerable = 6415
    StartTrig_Term = 12062
    StartTrig_Timescale = 12342
    StartTrig_TimestampEnable = 12618
    StartTrig_TimestampTimescale = 12589
    StartTrig_TimestampVal = 12619
    StartTrig_TrigWhen = 12365
    StartTrig_TrigWin = 12570
    StartTrig_Type = 5011
    SyncClk_Interval = 12158
    SyncPulse_MinDelayToStart = 8767
    SyncPulse_ResetDelay = 12157
    SyncPulse_ResetTime = 12156
    SyncPulse_Src = 8765
    SyncPulse_SyncTime = 8766
    SyncPulse_Term = 12165
    SyncPulse_Time_Timescale = 12600
    SyncPulse_Time_When = 12599
    SyncPulse_Type = 12598
    Sys_DevNames = 6459
    Sys_GlobalChans = 4709
    Sys_NIDAQMajorVersion = 4722
    Sys_NIDAQMinorVersion = 6435
    Sys_NIDAQUpdateVersion = 12066
    Sys_Scales = 4710
    Sys_Tasks = 4711
    Trigger_SyncType = 12160
    WatchdogExpirTrig_TrigOnNetworkConnLoss = 12381
    WatchdogExpirTrig_Type = 8611
    Watchdog_AO_ExpirState = 12383
    Watchdog_AO_OutputType = 12382
    Watchdog_CO_ExpirState = 12384
    Watchdog_DO_ExpirState = 8615
    Watchdog_HasExpired = 8616
    Watchdog_Timeout = 8617
end

@cenum DAQmxConstant::Int32 begin
    _100MHzTimebase = 15857
    _10MHzRefClock = 12536
    _20MHzTimebase = 12537
    _20MHzTimebaseClock = 12486
    _2Wire = 2
    _2point5V = 14620
    _3Wire = 3
    _3point3V = 14621
    _4Wire = 4
    _5V = 14619
    _5Wire = 5
    _6Wire = 6
    _80MHzTimebase = 14636
    _8MHzTimebase = 16023
    A = 12513
    AC = 10045
    AHighBHigh = 10040
    AHighBLow = 10041
    AI = 10100
    AIConvertClock = 12484
    AIHoldCmpltEvent = 12493
    ALowBHigh = 10042
    ALowBLow = 10043
    AM = 14756
    AO = 10102
    AOSeries = 14647
    AandB = 12515
    AboveLvl = 10093
    AccelUnit_g = 10186
    Acceleration_4WireDCVoltage = 16106
    Acceleration_Charge = 16104
    Accelerometer = 10356
    Acquired_Into_Buffer = 1
    Action_Cancel = 1
    Action_Commit = 0
    ActiveDrive = 12573
    ActiveHigh = 10095
    ActiveLow = 10096
    AdvCmpltEvent = 12492
    AdvanceTrigger = 12488
    AllowRegen = 10097
    Amps = 10342
    AnlgEdge = 10099
    AnlgLvl = 10101
    AnlgMultiEdge = 16108
    AnlgWin = 10103
    ArmStartTrigger = 14641
    Auto = 1
    Automatic = 16097
    B = 12514
    BSeriesDAQ = 14662
    B_Type_TC = 10047
    Bandpass = 16073
    Bar = 15880
    BelowLvl = 10107
    Bessel = 16153
    Best50HzRejection = 14713
    Best60HzRejection = 14714
    BipolarDC = 16147
    Bit_CouplingTypes_AC = 1
    Bit_CouplingTypes_DC = 2
    Bit_CouplingTypes_Ground = 4
    Bit_CouplingTypes_HFReject = 8
    Bit_CouplingTypes_LFReject = 16
    Bit_CouplingTypes_NoiseReject = 32
    Bit_TermCfg_Diff = 4
    Bit_TermCfg_NRSE = 2
    Bit_TermCfg_PseudoDIFF = 8
    Bit_TermCfg_RSE = 1
    Bit_TriggerUsageTypes_Advance = 1
    Bit_TriggerUsageTypes_ArmStart = 32
    Bit_TriggerUsageTypes_Handshake = 16
    Bit_TriggerUsageTypes_Pause = 2
    Bit_TriggerUsageTypes_Reference = 4
    Bit_TriggerUsageTypes_Start = 8
    Bits = 10109
    BreakBeforeMake = 10110
    Brickwall = 16155
    Bridge = 15908
    BuiltIn = 10200
    BurstHandshake = 12548
    Butterworth = 16076
    CI = 10131
    CO = 10132
    CSeriesModule = 14659
    CartesianShearStrainXY = 15976
    CartesianStrainX = 15974
    CartesianStrainY = 15975
    Cfg_Default = 1
    Chan = 10113
    ChanForAllLines = 1
    ChanPerLine = 0
    ChangeDetection = 12504
    ChangeDetectionEvent = 12511
    ChannelCurrent = 1
    ChannelHighImpedance = 2
    ChannelVoltage = 0
    Charge = 16105
    ClearExpiration = 1
    Closed = 10438
    Comb = 16152
    CompactDAQ = 14637
    CompactDAQChassis = 14658
    CompactRIO = 16143
    CompactRIOChassis = 16144
    ConstVal = 10116
    ConstantGroupDelay = 16075
    Cont = 10117
    ContSamps = 10123
    Coulombs = 16102
    CountDown = 10124
    CountEdges = 10125
    CountUp = 10128
    CounterOutputEvent = 12494
    Create = 15848
    CreateOrReplace = 15847
    CurrReadPos = 10425
    CurrWritePos = 10430
    Current = 10134
    CurrentRMS = 10351
    Custom = 10137
    DC = 10050
    DI = 10151
    DMA = 10054
    DO = 10153
    Default = 1
    DegC = 10143
    DegF = 10144
    DegR = 10145
    Degrees = 10146
    DegreesPerSecond = 16082
    DeltaRosette = 15969
    Diff = 10106
    DigEdge = 10150
    DigLvl = 10152
    DigPattern = 10398
    DigitalIO = 14648
    Disabled = 16146
    DoNotAllowRegen = 10158
    DoNotInvertPolarity = 0
    DoNotOverwriteUnreadSamps = 10159
    DoNotWrite = 12540
    DutyCycle = 16070
    DynAvg = 16065
    DynamicSignalAcquisition = 14649
    ESeriesDAQ = 14642
    E_Type_TC = 10055
    Elliptical = 16077
    Enabled = 16145
    EnteringWin = 10163
    EverySample = 10164
    ExtControlled = 10326
    External = 10167
    FM = 14757
    Falling = 10171
    FallingSlope = 10171
    FieldDAQ = 16151
    Finite = 10172
    FiniteSamps = 10178
    FirstPretrigSamp = 10427
    FirstSample = 10424
    FirstSampleTimestamp = 16130
    Fixed50PercentDutyCycle = 14711
    FixedHighFreq = 14709
    FixedLowFreq = 14710
    FootPounds = 15884
    Force_Bridge = 15899
    Force_IEPESensor = 15895
    Freq = 10179
    Freq_Voltage = 10181
    FromCustomScale = 10065
    FromTEDS = 12516
    FullBridge = 10182
    FullBridgeI = 10183
    FullBridgeII = 10184
    FullBridgeIII = 10185
    FuncGen = 14750
    GND = 10066
    GPS_Timestamp = 10362
    Ground = 2
    GroupByChannel = 0
    GroupByScanNumber = 1
    HWTimedSinglePoint = 12522
    HalfBridge = 10187
    HalfBridgeI = 10188
    HalfBridgeII = 10189
    HaltOutputAndError = 14615
    Handshake = 10389
    HandshakeTriggerAsserts = 12552
    HandshakeTriggerDeasserts = 12553
    HardwareDefined = 10191
    High = 10192
    HighFreq2Ctr = 10157
    HighImpedance = 12527
    HighResolution = 10195
    HighSpeed = 14712
    Highpass = 16072
    HostTime = 16126
    Hz = 10373
    IODeviceTime = 16127
    IRIGB = 10070
    IgnoreLostSyncLock = 16129
    IgnoreOverruns = 15863
    Immediate = 10198
    Implicit = 10451
    InchOunces = 15882
    InchPounds = 15883
    Inches = 10379
    InchesPerSecond = 15960
    InchesPerSecondSquared = 12471
    InsideWin = 10199
    Interlocked = 12549
    Internal = 10200
    Interrupts = 10204
    InvertPolarity = 1
    J_Type_TC = 10072
    K_Type_TC = 10073
    Kelvins = 10325
    KilogramForce = 15877
    LargeRng2Ctr = 10205
    LeavingWin = 10208
    LeftJustified = 10209
    Linear = 10447
    Load = 10440
    Local = 16095
    Log = 15844
    LogAndRead = 15842
    LogicLevelPullUp = 16064
    Loopback0 = 0
    Loopback180 = 1
    LosslessPacking = 12555
    LossyLSBRemoval = 12556
    Low = 10214
    LowFreq1Ctr = 10105
    Lowpass = 16071
    Lvl = 10210
    MSeriesDAQ = 14643
    MaintainExistingValue = 12528
    MapRanges = 10448
    Master = 15888
    MaxShearStrain = 15977
    MaxShearStrainAngle = 15978
    Meters = 10219
    MetersPerSecond = 15959
    MetersPerSecondSquared = 12470
    MilliVoltsPerInchPerSecond = 15964
    MillivoltsPerMillimeterPerSecond = 15963
    MostRecentSamp = 10428
    Multicycle = 14614
    NIELVIS = 14755
    NRSE = 10078
    N_Type_TC = 10077
    NetworkDAQ = 14829
    NewtonMeters = 15881
    Newtons = 15875
    NoAction = 10227
    NoBridge = 10228
    NoChange = 10160
    None = 10230
    Notch = 16074
    Off = 10231
    Ohms = 10384
    OnBrdMemEmpty = 10235
    OnBrdMemHalfFullOrLess = 10239
    OnBrdMemMoreThanHalfFull = 10237
    OnBrdMemNotEmpty = 10241
    OnBrdMemNotFull = 10242
    OnDemand = 10390
    Onboard = 16128
    OnbrdMemCustomThreshold = 12577
    OnbrdMemFull = 10236
    OnbrdMemMoreThanHalfFull = 10237
    Once = 10244
    Open = 10437
    OpenCollector = 12574
    OpenOrCreate = 15846
    OutsideWin = 10251
    OverwriteUnreadSamps = 10252
    PCCard = 12585
    PCI = 12582
    PCIe = 13612
    PPS = 10080
    PXI = 12583
    PXIe = 14706
    Pascals = 10081
    PathStatus_AlreadyExists = 10432
    PathStatus_Available = 10431
    PathStatus_ChannelInUse = 10434
    PathStatus_ChannelReservedForRouting = 10436
    PathStatus_SourceChannelConflict = 10435
    PathStatus_Unsupported = 10433
    PatternDoesNotMatch = 10253
    PatternMatches = 10254
    PauseUntilDataAvailable = 14616
    Period = 10256
    PicoCoulombs = 16103
    PicoCoulombsPerG = 16099
    PicoCoulombsPerInchesPerSecondSquared = 16101
    PicoCoulombsPerMetersPerSecondSquared = 16100
    PipelinedSampClk = 14668
    Poll = 12524
    Polynomial = 10449
    Position_AngEncoder = 10360
    Position_EddyCurrentProximityProbe = 14835
    Position_LVDT = 10352
    Position_LinEncoder = 10361
    Position_RVDT = 10353
    Pounds = 15876
    PoundsPerSquareInch = 15879
    Pressure_Bridge = 15902
    PrincipalStrain1 = 15971
    PrincipalStrain2 = 15972
    PrincipalStrainAngle = 15973
    ProgrammedIO = 10264
    PseudoDiff = 12529
    Pt3750 = 12481
    Pt3851 = 10071
    Pt3911 = 12482
    Pt3916 = 10069
    Pt3920 = 10053
    Pt3928 = 12483
    PullDown = 15951
    PullUp = 15950
    Pulse = 10265
    PulseFrequency = 15864
    PulseTicks = 15866
    PulseTime = 15865
    PulseWidth = 10359
    Pulse_Freq = 10119
    Pulse_Ticks = 10268
    Pulse_Time = 10269
    QuarterBridge = 10270
    QuarterBridgeI = 10271
    QuarterBridgeII = 10272
    R1 = 12465
    R2 = 12466
    R3 = 12467
    R4 = 14813
    RPM = 16080
    RSE = 10083
    R_Type_TC = 10082
    Radians = 10273
    RadiansPerSecond = 16081
    RectangularRosette = 15968
    RefTrig = 10426
    ReferenceTrigger = 12490
    Remote = 16096
    RepeatedData = 16062
    ReservedForRouting = 10441
    ResetTimer = 0
    Resistance = 10278
    RightJustified = 10279
    Rising = 10280
    RisingSlope = 10280
    Rosette_Strain_Gage = 15980
    SCC = 14707
    SCCConnectorBlock = 14704
    SCCModule = 14705
    SCExpress = 15886
    SCSeriesDAQ = 14645
    SCXI = 12584
    SCXI1124Range0to10V = 14631
    SCXI1124Range0to1V = 14629
    SCXI1124Range0to20mA = 14635
    SCXI1124Range0to5V = 14630
    SCXI1124RangeNeg10to10V = 14634
    SCXI1124RangeNeg1to1V = 14632
    SCXI1124RangeNeg5to5V = 14633
    SCXIModule = 14660
    SSeriesDAQ = 14644
    S_Type_TC = 10085
    SameAsMasterTimebase = 10282
    SameAsSampTimebase = 10284
    SampClk = 10388
    SampClkActiveEdge = 14617
    SampClkInactiveEdge = 14618
    SampClkPeriods = 10286
    SampleClkPeriods = 10286
    SampleClock = 12487
    SampleCompleteEvent = 12530
    Save_AllowInteractiveDeletion = 4
    Save_AllowInteractiveEditing = 2
    Save_Overwrite = 1
    Sawtooth = 14754
    Seconds = 10364
    SemiPeriod = 10289
    SentinelValue = 16063
    Sine = 14751
    SingleCycle = 14613
    Slave = 15889
    Sleep = 12547
    Software = 10292
    SoundPressure_Microphone = 10354
    Source = 10439
    Square = 14753
    StartTrigger = 12491
    StopTaskAndError = 15862
    Strain = 10299
    Strain_Gage = 10300
    SwitchBlock = 15870
    Switches = 14650
    SynchronousEventCallbacks = 1
    TCPIP = 14828
    TEDS_Sensor = 12531
    TIOSeries = 14661
    T_Type_TC = 10086
    Table = 10450
    Task_Abort = 6
    Task_Commit = 3
    Task_Reserve = 4
    Task_Start = 0
    Task_Stop = 1
    Task_Unreserve = 5
    Task_Verify = 2
    TeeRosette = 15970
    Temp_BuiltInSensor = 10311
    Temp_RTD = 10301
    Temp_TC = 10303
    Temp_Thrmstr = 10302
    Ticks = 10304
    Time = 15996
    Toggle = 10307
    Torque_Bridge = 15905
    Transferred_From_Buffer = 2
    Triangle = 14752
    Tristate = 10310
    TwoEdgeSep = 10267
    TwoPointLinear = 15898
    TwoPulseCounting = 10313
    USB = 12586
    USBDAQ = 14646
    USBbulk = 12590
    Unconstrained = 14708
    Unknown = 12588
    UserProvided = 10167
    Velocity_AngEncoder = 16078
    Velocity_IEPESensor = 15966
    Velocity_LinEncoder = 16079
    Voltage = 10322
    VoltageRMS = 10350
    Voltage_CustomWithExcitation = 10323
    Volts = 10348
    VoltsPerG = 12510
    VoltsPerMil = 14837
    VoltsPerMillimeter = 14839
    VoltsPerVolt = 15896
    WDTExpiredEvent = 12512
    WaitForHandshakeTriggerAssert = 12550
    WaitForHandshakeTriggerDeassert = 12551
    WaitForInterrupt = 12523
    WhenAcqComplete = 12546
    WriteToEEPROM = 12538
    WriteToPROM = 12539
    X1 = 10090
    X2 = 10091
    X4 = 10092
    XSeriesDAQ = 15858
    Yield = 12525
    ZeroVolts = 12526
    ZeroVoltsOrAmps = 12526
    g = 10186
    mVoltsPerG = 12509
    mVoltsPerMicron = 14840
    mVoltsPerMil = 14836
    mVoltsPerMillimeter = 14838
    mVoltsPerNewton = 15891
    mVoltsPerPound = 15892
    mVoltsPerVolt = 15897
    mVoltsPerVoltPerDegree = 12507
    mVoltsPerVoltPerMilliInch = 12505
    mVoltsPerVoltPerMillimeter = 12506
    mVoltsPerVoltPerRadian = 12508
end


text:
@testset "conxexhull" begin
    @testset "convexhull2" begin
        points = [27.0 68.0; 30.0 48.0; 43.0 67.0; 58.0 48.0; 58.0 27.0; 37.0 69.0; 38.0 46.0; 46.0 10.0; 61.0 33.0; 62.0 63.0; 63.0 69.0; 32.0 22.0; 45.0 35.0; 59.0 15.0; 5.0 6.0; 10.0 17.0; 21.0 10.0; 5.0 64.0; 30.0 15.0; 39.0 10.0; 32.0 39.0; 25.0 32.0; 25.0 55.0; 48.0 28.0; 56.0 37.0; 30.0 40.0; 37.0 52.0; 49.0 49.0; 52.0 64.0; 20.0 26.0; 40.0 30.0; 21.0 47.0; 17.0 63.0; 31.0 62.0; 52.0 33.0; 51.0 21.0; 42.0 41.0; 31.0 32.0; 5.0 25.0; 12.0 42.0; 36.0 16.0; 52.0 41.0; 27.0 23.0; 17.0 33.0; 13.0 13.0; 57.0 58.0; 62.0 42.0; 42.0 57.0; 16.0 57.0; 8.0 52.0; 7.0 38.0]
        hull = convexhull(points)
        @test size(hull,1) == 8
        @test hull == [[5.0, 6.0],[46.0,10.0],[59.0,15.0],[62.0,42.0],[63.0,69.0],[37.0,69.0],[27.0,68.0],[5.0,64.0]]
    end

    @testset "convexhull1" begin
        points = [GeometricStructures.Point2D{Float64}(27.0,68.0),
                    GeometricStructures.Point2D{Float64}(30.0,48.0),
                    GeometricStructures.Point2D{Float64}(43.0,67.0),
                    GeometricStructures.Point2D{Float64}(58.0,48.0),
                    GeometricStructures.Point2D{Float64}(58.0,27.0),
                    GeometricStructures.Point2D{Float64}(37.0,69.0),
                    GeometricStructures.Point2D{Float64}(38.0,46.0),
                    GeometricStructures.Point2D{Float64}(46.0,10.0),
                    GeometricStructures.Point2D{Float64}(61.0,33.0),
                    GeometricStructures.Point2D{Float64}(62.0,63.0),
                    GeometricStructures.Point2D{Float64}(63.0,69.0),
                    GeometricStructures.Point2D{Float64}(32.0,22.0),
                    GeometricStructures.Point2D{Float64}(45.0,35.0),
                    GeometricStructures.Point2D{Float64}(59.0,15.0),
                    GeometricStructures.Point2D{Float64}(5.0,6.0),
                    GeometricStructures.Point2D{Float64}(10.0,17.0),
                    GeometricStructures.Point2D{Float64}(21.0,10.0),
                    GeometricStructures.Point2D{Float64}(5.0,64.0),
                    GeometricStructures.Point2D{Float64}(30.0,15.0),
                    GeometricStructures.Point2D{Float64}(39.0,10.0),
                    GeometricStructures.Point2D{Float64}(32.0,39.0),
                    GeometricStructures.Point2D{Float64}(25.0,32.0),
                    GeometricStructures.Point2D{Float64}(25.0,55.0),
                    GeometricStructures.Point2D{Float64}(48.0,28.0),
                    GeometricStructures.Point2D{Float64}(56.0,37.0),
                    GeometricStructures.Point2D{Float64}(30.0,40.0),
                    GeometricStructures.Point2D{Float64}(37.0,52.0),
                    GeometricStructures.Point2D{Float64}(49.0,49.0),
                    GeometricStructures.Point2D{Float64}(52.0,64.0),
                    GeometricStructures.Point2D{Float64}(20.0,26.0),
                    GeometricStructures.Point2D{Float64}(40.0,30.0),
                    GeometricStructures.Point2D{Float64}(21.0,47.0),
                    GeometricStructures.Point2D{Float64}(17.0,63.0),
                    GeometricStructures.Point2D{Float64}(31.0,62.0),
                    GeometricStructures.Point2D{Float64}(52.0,33.0),
                    GeometricStructures.Point2D{Float64}(51.0,21.0),
                    GeometricStructures.Point2D{Float64}(42.0,41.0),
                    GeometricStructures.Point2D{Float64}(31.0,32.0),
                    GeometricStructures.Point2D{Float64}(5.0,25.0),
                    GeometricStructures.Point2D{Float64}(12.0,42.0),
                    GeometricStructures.Point2D{Float64}(36.0,16.0),
                    GeometricStructures.Point2D{Float64}(52.0,41.0),
                    GeometricStructures.Point2D{Float64}(27.0,23.0),
                    GeometricStructures.Point2D{Float64}(17.0,33.0),
                    GeometricStructures.Point2D{Float64}(13.0,13.0),
                    GeometricStructures.Point2D{Float64}(57.0,58.0),
                    GeometricStructures.Point2D{Float64}(62.0,42.0),
                    GeometricStructures.Point2D{Float64}(42.0,57.0),
                    GeometricStructures.Point2D{Float64}(16.0,57.0),
                    GeometricStructures.Point2D{Float64}(8.0,52.0),
                    GeometricStructures.Point2D{Float64}(7.0,38.0)]
        hull = convexhull(points)
        @test size(hull,1) == 8
        @test hull == [GeometricStructures.Point2D{Float64}(5.0,6.0),
                        GeometricStructures.Point2D{Float64}(46.0,10.0),
                        GeometricStructures.Point2D{Float64}(59.0,15.0),
                        GeometricStructures.Point2D{Float64}(62.0,42.0),
                        GeometricStructures.Point2D{Float64}(63.0,69.0),
                        GeometricStructures.Point2D{Float64}(37.0,69.0),
                        GeometricStructures.Point2D{Float64}(27.0,68.0),
                        GeometricStructures.Point2D{Float64}(5.0,64.0)]
    end

end

max_stars_repo_name: helgith/GeometricStructures

max_issues_repo_name: helgith/GeometricStructures

max_forks_repo_name: helgith/GeometricStructures


text:
using Pkg, Revise; Pkg.activate("bulma"; shared=true);
using Documenter
using Documenter.Utilities.JSDependencies: JSDependencies, RemoteLibrary

const jslibraries = [
    RemoteLibrary("jquery", "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"),
    RemoteLibrary("jqueryui", "https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.0/jquery-ui.min.js"),
    RemoteLibrary("headroom", "https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/headroom.min.js"),
    RemoteLibrary(
        "headroom-jquery",
        "https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/jQuery.headroom.min.js",
        deps = ["jquery", "headroom"],
    ),
    # FIXME: upgrade KaTeX to v0.11.0
    RemoteLibrary("katex", "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.2/katex.min.js"),
    RemoteLibrary(
        "katex-auto-render",
        "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.2/contrib/auto-render.min.js",
        deps = ["katex"],
    ),
    RemoteLibrary("highlight", "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.8/highlight.min.js"),
    RemoteLibrary(
        "highlight-julia",
        "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.8/languages/julia.min.js",
        deps = ["highlight"],
    ),
    RemoteLibrary(
        "highlight-julia-repl",
        "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.8/languages/julia-repl.min",
        deps = ["highlight"],
    ),
]

function loadsnippet(name)
    snippetfile = joinpath(Documenter.Writers.HTMLWriter.ASSETS, "js", "$(name).js")
    isfile(snippetfile) || error("No such file: $(snippetfile)")
    JSDependencies.parse_snippet(snippetfile)
end

r = let r = JSDependencies.RequireJS(libraries)
    push!(r, loadsnippet("headroom"))
    push!(r, loadsnippet("highlight"))
    push!(r, loadsnippet("katex"))
    push!(r, loadsnippet("settings"))
    push!(r, loadsnippet("sidebar"))
    push!(r, loadsnippet("themes"))
    push!(r, loadsnippet("versions"))
    return r
end

let
    JSDependencies.verify(r)
    println("="^80)
    JSDependencies.writejs(stdout, r)

    p = joinpath(dirname(pathof(Documenter)), "../docs/build/assets/documenter.js")
    JSDependencies.writejs(p, r)
end

# 'lunr': 'https://cdnjs.cloudflare.com/ajax/libs/lunr.js/2.3.5/lunr.min',
# 'lodash': 'https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.min'
push!(r, JSAPI.JSLibrary(
    "lunr",
    "https://cdnjs.cloudflare.com/ajax/libs/lunr.js/2.3.5/lunr.min.js",
    nothing, nothing
))

push!(r, JSAPI.JSLibrary(
    "lodash",
    "https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.min.js",
    nothing, nothing
))

push!(r, JSAPI.JSSnippet(["jquery"], ["\$"],
    JSAPI.js"""
    $(document).ready(function() {
        var version_selector = $("#version-selector");

        // add the current version to the selector based on siteinfo.js, but only if the selector is empty
        if (typeof DOCUMENTER_CURRENT_VERSION !== 'undefined' && $('#version-selector > option').length == 0) {
            var option = $("<option value='#' selected='selected'>" + DOCUMENTER_CURRENT_VERSION + "</option>");
            version_selector.append(option);
        }

        if (typeof DOC_VERSIONS !== 'undefined') {
            var existing_versions = $('#version-selector > option');
            var existing_versions_texts = existing_versions.map(function(i,x){return x.text});
            DOC_VERSIONS.forEach(function(each) {
                var version_url = documenterBaseURL + "/../" + each;
                var existing_id = $.inArray(each, existing_versions_texts);
                // if not already in the version selector, add it as a new option,
                // otherwise update the old option with the URL and enable it
                if (existing_id == -1) {
                    var option = $("<option value='" + version_url + "'>" + each + "</option>");
                    version_selector.append(option);
                } else {
                    var option = existing_versions[existing_id];
                    option.value = version_url;
                    option.disabled = false;
                }
            });
        }

        // only show the version selector if the selector has been populated
        if ($('#version-selector > option').length > 0) {
            version_selector.css("visibility", "visible");
        }

        // Scroll the navigation bar to the currently selected menu item
        $("nav.toc > ul").get(0).scrollTop = $(".current").get(0).offsetTop - $("nav.toc > ul").get(0).offsetTop;
    })
    """
))

function highlightjs(languages = String[])
    hljs_version = "9.15.5"
    libraries = [JSAPI.JSLibrary(
        "highlight",
        "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/$(hljs_version)/highlight.min.js",
        nothing, nothing
    )]
    prepend!(languages, ["julia", "julia-repl"])
    for language in languages
        push!(libraries, JSAPI.JSLibrary(
            "highlight-$(language)",
            "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/$(hljs_version)/languages/$(language).min.js",
            ["highlight"], nothing
        ))
    end
    snippet = JSAPI.JSSnippet(
        vcat(["jquery", "highlight"], ["highlight-$(language)" for language in languages]),
        ["\$", "hljs"],
        JSAPI.js"""
        $(document).ready(function() {
            hljs.initHighlighting();
        })
        """
    )
    (libraries, [snippet])
end

let (libs, snippets) = highlightjs(["yaml"])
    map(x -> push!(r, x), libs)
    map(x -> push!(r, x), snippets)
end

const MathJaxDefaultConfig = Dict(
    :tex2jax => Dict(
        "inlineMath" => [["\$","\$"], ["\\(","\\)"]],
        "processEscapes" => true
    ),
    :config => ["MMLorHTML.js"],
    :jax => [
        "input/TeX",
        "output/HTML-CSS",
        "output/NativeMML"
    ],
    :extensions => [
        "MathMenu.js",
        "MathZoom.js",
        "TeX/AMSmath.js",
        "TeX/AMSsymbols.js",
        "TeX/autobold.js",
        "TeX/autoload-all.js"
    ],
    :TeX => Dict(:equationNumbers => Dict(:autoNumber => "AMS"))
)

function mathjax(config::Dict = MathJaxDefaultConfig)
    config_json = JSON.json(config, 2) # FIXME: JS escapes
    js = """
    MathJax.Hub.Config($(config_json));
    """
    snippet = JSAPI.JSSnippet(["mathjax"], ["MathJax"], js)
    library = JSAPI.JSLibrary(
        "mathjax",
        "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS_HTML",
        nothing, "MathJax"
    )
    ([library], [snippet])
end
let (libs, snippets) = mathjax()
    map(x -> push!(r, x), libs)
    map(x -> push!(r, x), snippets)
end

push!(r, JSAPI.JSSnippet(["jquery", "headroom"], ["\$", "Headroom"],
    JSAPI.js"""
    $(document).ready(function() {
        var navtoc = $("nav.toc");
        $("nav.toc li.current a.toctext").click(function() {
            navtoc.toggleClass('show');
        });
        $("article > header div#topbar a.fa-bars").click(function(ev) {
            ev.preventDefault();
            navtoc.toggleClass('show');
            if (navtoc.hasClass('show')) {
                var title = $("article > header div#topbar span").text();
                $("nav.toc ul li a:contains('" + title + "')").focus();
            }
        });
        $("article#docs").bind('click', function(ev) {
            if ($(ev.target).is('div#topbar a.fa-bars')) {
                return;
            }
            if (navtoc.hasClass('show')) {
                navtoc.removeClass('show');
            }
        });
        if ($("article > header div#topbar").css('display') == 'block') {
            var headroom = new Headroom(document.querySelector("article > header div#topbar"), {"tolerance": {"up": 10, "down": 10}});
            headroom.init();
        }
    })
    """
))

let
    JSAPI.verify(r)
    println("="^80)
    JSAPI.writejs(stdout, r)
    JSAPI.writejs("docs/build/assets/documenter.js", r)
end

push!(r, JSAPI.JSSnippet(["jquery", "lunr", "lodash"], ["\$", "lunr"],
    String(read("search.js"))
))
JSAPI.writejs("docs/build/assets/documenter-search.js", r)

let b = IOBuffer()
    write(b, JSAPI.js"""
    // libraries: jquery, xyz
    // args: $
    /// libraries: j_query*
    $(document).ready(function() {
        hljs.initHighlighting();
    })
    """)
    seek(b, 0)
    read_js_snippet(b)
end

Base.:(==)(library::JSAPI.JSLibrary, s::AbstractString) = (library.name == s)
Base.:(==)(s::AbstractString, library::JSAPI.JSLibrary) = (library == s)

# macro jssnippet(name::Symbol)
#     name_str = String(name)
#     quote
#         $(esc(name)) = load_js_snippet($name_str)
#     end
# end
#
# @jssnippet headroom
# @jssnippet highlight
# @jssnippet katex
# @jssnippet settings
# @jssnippet sidebar
# @jssnippet themes
# @jssnippet versions


text:
@testset "restrict" begin
    @testset "interfaces" begin
        A = rand(N0f8, 4, 5, 3)

        Ar = @inferred restrict(A, 1)
        @test typeof(Ar) <: Array
        @test size(Ar) == (3, 5, 3)

        Ar = @inferred restrict(A, (1, ))
        @test typeof(Ar) <: Array
        @test size(Ar) == (3, 5, 3)

        Ar = @inferred restrict(A, (1, 2, 3))
        @test typeof(Ar) <: Array
        @test size(Ar) == (3, 3, 2)
        @test Ar == restrict(A)

        @test_throws MethodError restrict(A, 1, 2, 3)
    end

    @testset "numerical test" begin
        A = reshape([UInt16(i) for i = 1:60], 4, 5, 3)
        B = restrict(A, (1,2))
        Btarget = cat([0.96875   4.625   5.96875;
                       2.875    10.5    12.875;
                       1.90625   5.875   6.90625],
                      [8.46875  14.625  13.46875;
                       17.875    30.5    27.875;
                       9.40625  15.875  14.40625],
                      [15.96875  24.625  20.96875;
                       32.875    50.5    42.875;
                       16.90625  25.875  21.90625], dims=3)
        @test B ≈ Btarget

        Argb = reinterpretc(RGB, reinterpret(N0f16, permutedims(A, (3,1,2))))
        B = restrict(Argb)
        Bf = permutedims(reinterpretc(eltype(eltype(B)), B), (2,3,1))
        # isapprox no longer lies, so atol is now serious
        @test isapprox(Bf, Btarget/reinterpret(one(N0f16)), atol=1e-10)

        Argba = reinterpretc(RGBA{N0f16}, reinterpret(N0f16, A))
        B = restrict(Argba)
        @test isapprox(reinterpretc(eltype(eltype(B)), B), restrict(A, (2,3))/reinterpret(one(N0f16)), atol=1e-10)

        A = reshape(1:60, 5, 4, 3)
        B = restrict(A, (1,2,3))
        @test cat([2.6015625   8.71875   6.1171875;
                   4.09375    12.875     8.78125;
                   3.5390625  10.59375   7.0546875],
                  [10.1015625  23.71875  13.6171875;
                   14.09375    32.875    18.78125;
                   11.0390625  25.59375  14.5546875], dims=3) ≈ B
    end

    @testset "singleton dimension" begin
        # https://github.com/JuliaImages/ImageTransformations.jl/issues/47
        @test restrict([1]) == [1.0]
        @test restrict([0 1 0]) == [0.25 0.25]
        @test restrict([0, 1, 0], 5) == [0, 1, 0]
    end

    @testset "OffsetArray" begin
        A = rand(5, 4, 3)
        Ao = OffsetArray(A, (-2,1,0))

        for (dims, offsets) in [
                (1,      (-1, 1, 0)),
                (2,      (-2, 0, 0)),
                ((1, 2), (-1, 0, 0))
            ]
            Ar = @inferred restrict(Ao, dims)
            @test typeof(Ar) <: OffsetArray
            @test Ar.offsets == offsets
            @test parent(Ar) == restrict(A, dims)
        end
    end

    @testset "SubArray" begin
        x0 = [0, 0, 1, 1, 0, 0]
        xv = @view x0[1:2:6]
        x = x0[1:2:6]
        xr = restrict(xv)
        @test xr == restrict(x)
        @test xr isa Array

        x = view(x0, IdentityUnitRange(3:5))
        xr = restrict(x)
        @test xr == restrict(collect(x))
        @test xr isa Array
    end

    @testset "FixedPoint overflow" begin
        # issue https://github.com/JuliaImages/Images.jl/issues/395
        img1 = colorview(RGB, fill(0.9, 3, 5, 5))
        img2 = colorview(RGB, fill(N0f8(0.9), 3, 5, 5))
        @test isapprox(channelview(restrict(img1)), channelview(restrict(img2)), rtol=0.01)
    end

    @testset "Array of arrays" begin
        a = Vector{Int}[[3,3,3], [2,1,7],[-11,4,2]]
        @test restrict(a) == Vector{Float64}[[2,3.5/2,6.5/2], [-5,4.5/2,5.5/2]]
    end

    @testset "various colorant" begin
        # issue https://github.com/JuliaImages/Images.jl/issues/652
        img = testimage("cameraman")
        @test eltype(@inferred(restrict(img))) == Gray{Float32}
        img = testimage("mandrill")
        @test eltype(@inferred(restrict(img))) == RGB{Float32}
        @test eltype(@inferred(restrict(Lab.(img)))) == RGB{Float32}
        img = rand(RGBA{N0f8}, 11, 11)
        @test eltype(@inferred(restrict(img))) == RGBA{Float32}
        @test eltype(@inferred(restrict(LabA.(img)))) == ARGB{Float32}

        ori = repeat(distinguishable_colors(10), inner=(1, 10))
        for T in (
            RGB, BGR, RGBX, XRGB,
            ARGB, RGBA,
            RGB24, ARGB32,
        )
            img = T.(ori)
            out = @inferred restrict(img)
            if T == RGB24
                @test eltype(out) == RGB{Float32}
            elseif T == ARGB32
                @test eltype(out) == ARGB{Float32}
            else
                @test eltype(out) <: T
            end
            ref = restrict(ori)
            @test ref ≈ RGB.(out)
        end
        for T in (Gray, AGray, GrayA, Gray24)
            img = T.(ori)
            out = @inferred restrict(img)
            if T == Gray24
                @test eltype(out) == Gray{Float32}
            else
                @test eltype(out) <: T
            end
            ref = restrict(Gray.(ori))
            @test ref ≈ Gray.(out)
        end
    end
end


text:
# ---
# title: 405. Convert a Number to Hexadecimal
# id: problem405
# author: Tian Jun
# date: 2020-10-31
# difficulty: Easy
# categories: Bit Manipulation
# link: <https://leetcode.com/problems/convert-a-number-to-hexadecimal/description/>
# hidden: true
# ---
#
# Given an integer, write an algorithm to convert it to hexadecimal. For
# negative integer, [two’s
# complement](https://en.wikipedia.org/wiki/Two%27s_complement) method is used.
#
# **Note:**
#
#   1. All letters in hexadecimal (`a-f`) must be in lowercase.
#   2. The hexadecimal string must not contain extra leading `0`s. If the number is zero, it is represented by a single zero character `'0'`; otherwise, the first character in the hexadecimal string will not be the zero character.
#   3. The given number is guaranteed to fit within the range of a 32-bit signed integer.
#   4. You **must not use _any_ method provided by the library** which converts/formats the number to hex directly.
#
# **Example 1:**
#
#
#
#     Input:
#     26
#
#     Output:
#     "1a"
#
#
# **Example 2:**
#
#
#
#     Input:
#     -1
#
#     Output:
#     "ffffffff"
#
#
#
## @lc code=start
using LeetCode

## add your code here:
## @lc code=end