text:
function twodStokes(N=25)
#  Solves Stokes equation in 2D with Dirichlet boundary conditions
#     - ∇⋅(∇z+∇z') + ∇p = f,  Ω = (0,1)×(0,1),  homogeneous Dirichlet b.c.
#---------------------------------------------------------------------------78--

#  include("../src/twodMesh.jl")
#  include("../src/twodQuadratureRule.jl")
#  include("../src/twodShape.jl")
#  include("../src/twodBilinear.jl")
#  include("../src/twodLinForm.jl")
#  include("../src/twodMassMatrix.jl")
#  include("../src/TriMesh_PromoteL2Q.jl")

#  @everywhere include("twodShape.jl")
#  @everywhere include("twodBilinear.jl")
#  @everywhere include("twodLinForm.jl")

  #  Define problem parameters
#  @everywhere μ = 0.001
#  @everywhere ϵ = 0.0
  μ = 0.01
  ϵ = 0      # 1e-5/μ    # when the PDE solution is not in the FEM subspace

  xMin = -1.0
  xMax =  1.0
  yMin = -1.0
  yMax =  1.0

  rule = 7   # points in quadrature formula

  #  Specify manufactured solutions for code verification
  #-----------------------------------------------------------------------------
  function uExact(x)
    return -x[2]*(1-x[2]^2)
  end

  function vExact(x)
    return  x[1]*(1-x[1]^2)
  end

  function pExact(x)
    return x[1]+x[2]
  end

#  @everywhere function fx(x::Array{Float64,2})
  function fx(x::Array{Float64,2})
    return 1.0-6.0*μ*x[1,2]
  end
#  @everywhere function fy(x::Array{Float64,2})
  function fy(x::Array{Float64,2})
    return 1.0+6.0*μ*x[1,1]
  end

  #  Create mesh then set equation numbers
  #-----------------------------------------------------------------------------
  nNodesX = N
  nNodesY = N
  x,eConn,iB = twodMesh( xMin,xMax, yMin,yMax, "quadratic", nNodesX,nNodesY )
  nNodes = size(x,1)
  nElements = size(eConn,1)

  #  Set the index into equation numbers
  #-----------------------------------------------------------------------------
  ideU = zeros(Int64,nNodes,2)

  # easily streamlined... since boundaries are handled later
  global nUnk = 0
  for i=1:nNodes
    global nUnk = nUnk+1
    ideU[i,1] = nUnk

    global nUnk = nUnk+1
    ideU[i,2] = nUnk
  end

  ideP = zeros(Int64,nNodes)
  for n_el=1:nElements
    vertex = eConn[n_el,1:3]
    if ( ideP[vertex[1]]==0 )
      global nUnk = nUnk + 1
      ideP[vertex[1]] = nUnk
    end

    if ( ideP[vertex[2]]==0 )
      global nUnk = nUnk + 1
      ideP[vertex[2]] = nUnk
    end

    if ( ideP[vertex[3]]==0 )
      global nUnk = nUnk + 1
      ideP[vertex[3]] = nUnk
    end
  end
  nP = nUnk - 2*nNodes

  #  Integrate system matrices, element-by-element
  #-----------------------------------------------------------------------------
  r,s,w = twodQuadratureRule(rule)
  μ_g   = μ*ones(rule)
  ϵ_g   = ϵ*ones(rule)
  one   = ones(rule)

  nElDOF   = size(eConn,2)
  nElDOF2  = nElDOF*nElDOF
  nEntries = nElements*(2*nElDOF+3)*(2*nElDOF+3)
#  II  = SharedArray{Int64}(nEntries)
#  JJ  = SharedArray{Int64}(nEntries)
#  AA  = SharedArray{Float64}(nEntries)
#  b   = SharedArray{Float64}(2*nNodes)
  II  = Array{Int64,1}(undef, nEntries)
  JJ  = Array{Int64,1}(undef, nEntries)
  AA  = Array{Float64,1}(undef, nEntries)
  b   = zeros(Float64,nUnk,1)

#  @sync @distributed for k=1:nElements
  for k=1:nElements
#    xg  = zeros(Float64,rule,2)
#    wg  = zeros(Float64,rule)
#    phi = zeros(Float64,rule,nElDOF)
#    p_x = zeros(Float64,rule,nElDOF)
#    p_y = zeros(Float64,rule,nElDOF)

    nLocal = eConn[k,:][:]
    xLocal = x[nLocal,:]

    xg,wg,phi,phi_x,phi_y = twodShape( xLocal, r, s, w )
    xg,wg,psi,psi_x,psi_y = twodShape( xLocal[1:3,:], r, s, w )

    # evaluate forcing function at quadrature points
    fx_g = fx(xg)
    fy_g = fy(xg)

    A11Loc =-twodBilinear( 2*μ_g, phi_x, phi_x, wg) -
             twodBilinear(   μ_g, phi_y, phi_y, wg)
    A12Loc =-twodBilinear(   μ_g, phi_x, phi_y, wg)
    A21Loc =-twodBilinear(   μ_g, phi_y, phi_x, wg)
    A22Loc =-twodBilinear(   μ_g, phi_x, phi_x, wg) -
             twodBilinear( 2*μ_g, phi_y, phi_y, wg)
    B1Loc  = twodBilinear(   one, phi_x, psi  , wg)
    B2Loc  = twodBilinear(   one, phi_y, psi  , wg)
    MLoc   =-twodBilinear(   ϵ_g, psi  , psi  , wg)
    F1Loc  = twodLinForm(   fx_g, phi  ,        wg)
    F2Loc  = twodLinForm(   fy_g, phi  ,        wg)

    index = (k-1)*(2*nElDOF+3)^2   # compute base index (since k could be in any order)
    lDOF = ideU[nLocal,1][:]
    # u-momentum equations
    for nt = 1:nElDOF
      nTest = ideU[nLocal[nt],1]
      for nu = 1:nElDOF
        nUnkU = ideU[nLocal[nu],1]
        nUnkV = ideU[nLocal[nu],2]

        index = index + 1
        II[index] = nTest
        JJ[index] = nUnkU
        AA[index] = A11Loc[nt,nu]

        index = index + 1
        II[index] = nTest
        JJ[index] = nUnkV
        AA[index] = A12Loc[nt,nu]
      end
      for np = 1:3  # special to this linear element
        nUnkP = ideP[nLocal[np]]

        index = index + 1
        II[index] = nTest
        JJ[index] = nUnkP
        AA[index] = B1Loc[np,nt]
      end

      b[nTest] = b[nTest] + F1Loc[nt]
    end

    # v-momentum equations
    for nt = 1:nElDOF
      nTest = ideU[nLocal[nt],2]
      for nu = 1:nElDOF
        nUnkU = ideU[nLocal[nu],1]
        nUnkV = ideU[nLocal[nu],2]

        index = index + 1
        II[index] = nTest
        JJ[index] = nUnkU
        AA[index] = A21Loc[nt,nu]

        index = index + 1
        II[index] = nTest
        JJ[index] = nUnkV
        AA[index] = A22Loc[nt,nu]
      end
      for np = 1:3  # special to this linear element
        nUnkP = ideP[nLocal[np]]

        index = index + 1
        II[index] = nTest
        JJ[index] = nUnkP
        AA[index] = B2Loc[np,nt]
      end

      b[nTest] = b[nTest] + F2Loc[nt]
    end

    # continuity equations
    for nt = 1:3
      nTest = ideP[nLocal[nt]]
      for nu = 1:nElDOF
        nUnkU = ideU[nLocal[nu],1]
        nUnkV = ideU[nLocal[nu],2]

        index = index + 1
        II[index] = nTest
        JJ[index] = nUnkU
        AA[index] = B1Loc[nt,nu]

        index = index + 1
        II[index] = nTest
        JJ[index] = nUnkV
        AA[index] = B2Loc[nt,nu]
      end
      for np = 1:3  # special to this linear element
        nUnkP = ideP[nLocal[np]]

        index = index + 1
        II[index] = nTest
        JJ[index] = nUnkP
        AA[index] = MLoc[nt,np]
      end

    end
  end

  A = sparse(II,JJ,AA)

  #  Solve and apply the boundary conditions
  #-----------------------------------------------------------------------------
  nDirichlet = size(iB,1)

  sort!(iB)
  knownIndexU = [2*iB-ones(Int64,nDirichlet,1)]
  knownIndexV = [2*iB]

  dirichletU = zeros(Float64,nDirichlet,1)
  dirichletV = zeros(Float64,nDirichlet,1)
  for i = 1:length(iB)
    dirichletU[i] = uExact(x[iB[i],:])
    dirichletV[i] = vExact(x[iB[i],:])
  end

  interiorNodes = 1:nNodes
  interiorNodes = setdiff(interiorNodes,iB)
#  sort!(interiorNodes)

  nUnknowns = 2*length(interiorNodes) + nP
  unknownIndex = Array{Int64,1}(undef,nUnknowns)
  uIndex = Array{Int64,1}(undef,2*length(interiorNodes))
  vIndex = Array{Int64,1}(undef,2*length(interiorNodes))
  uInverseIndex = Array{Int64,1}(undef,nNodes)
  vInverseIndex = Array{Int64,1}(undef,nNodes)

  global nUnknownCounter = 0
  for i ∈ interiorNodes
    global nUnknownCounter = nUnknownCounter+1
    unknownIndex[nUnknownCounter] = 2*i-1
    uIndex[nUnknownCounter] = i
    uInverseIndex[i]=nUnknownCounter

    global nUnknownCounter = nUnknownCounter+1
    unknownIndex[nUnknownCounter] = 2*i
    vIndex[nUnknownCounter] = i
    vInverseIndex[i]=nUnknownCounter
  end

  getP = zeros(Int64,3*nNodes,1)
  for nNode=1:nNodes
    if ideP[nNode]>0
      global nUnknownCounter = nUnknownCounter + 1
      unknownIndex[nUnknownCounter] = ideP[nNode]
      getP[ideP[nNode]] = nUnknownCounter
    end
  end

  rhs = -b[unknownIndex]-A[unknownIndex,knownIndexU[][:]]*dirichletU-A[unknownIndex,knownIndexV[][:]]*dirichletV

  uvp = A[unknownIndex,unknownIndex]\rhs

  velocity = zeros(Float64,nNodes,2)

  global nUnknownCounter = 0
  for i=interiorNodes
    global nUnknownCounter = nUnknownCounter+1
    velocity[i,1] = uvp[nUnknownCounter]

    global nUnknownCounter = nUnknownCounter + 1
    velocity[i,2] = uvp[nUnknownCounter]
  end

  for i=1:nDirichlet
    velocity[iB[i],1] = dirichletU[i]
    velocity[iB[i],2] = dirichletV[i]
  end

  pressure = zeros(Float64,nNodes,1)

  vv = eConn[:,1:3]
  vvv = vv[:]
  vertices = unique(sort(vvv))
  for i ∈ vertices
    pressure[i] = uvp[getP[ideP[i]]]
  end
  pressure = TriMesh_PromoteL2Q(pressure,eConn)

#  return x,eConn,velocity,pressure

  #  Compute the exact solution for the unit test
  velocityExact = zeros(Float64,nNodes,2)
  for n=1:nNodes
    velocityExact[n,1] = uExact(x[n,:])
    velocityExact[n,2] = vExact(x[n,:])
  end

  pressureExact = zeros(Float64,nNodes,1)
  for n=1:nNodes
    pressureExact[n] = pExact(x[n,:])
  end

  # Compute the norm of the approximation error for the unit test
  M = twodMassMatrix(x,eConn)
  vDiff = velocity-velocityExact
  C     = pressureExact[1]-pressure[1]
  pDiff = pressure-pressureExact.+C
  return sqrt(dot(vDiff[:,1],M,vDiff[:,1])) +
         sqrt(dot(vDiff[:,2],M,vDiff[:,2])) +
         sqrt(dot(pDiff,M,pDiff))
end


text:
################################################################################
# # DESCRIPTION
#     Wrapper for Python Paraview functions.
# # AUTHORSHIP
#   * Author    : Eduardo J Alvarez
#   * Email     : Edo.AlvarezR@gmail.com
#   * Created   : Nov 2017
#   * License   : MIT License
################################################################################

# Wrap VTKtools_paraview.py
@pyimport imp
(file, filename, data) = imp.find_module("VTKtools_paraview", [module_path])
parapy = imp.load_module("VTKtools_paraview", file, filename, data)

ext: jl


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

using Test

# Tests for @__LINE__ inside and outside of macros
@test (@__LINE__) == 6

macro macro_caller_lineno()
    @test 9 == (@__LINE__) != __source__.line > 12
    return __source__.line
end

@test @macro_caller_lineno() == (@__LINE__) > 12

# @__LINE__ in a macro expands to the location of the macrocall in the source
# while __source__.line is the location of the macro caller
macro nested_LINE_expansion()
    return quote
        return (@emit_LINE, $(__source__.line))
    end
end
macro nested_LINE_expansion2()
    return :((@emit_LINE, $(__source__.line)))
end
macro emit_LINE()
    return quote
        (@__LINE__, $(__source__.line))
    end
end
@test (@emit_LINE) == ((@__LINE__) - 3, @__LINE__)
@test @nested_LINE_expansion() == ((@__LINE__() - 4, @__LINE__() - 12), @__LINE__())
@test @nested_LINE_expansion2() == ((@__LINE__() - 5, @__LINE__() - 9), @__LINE__())

loaded_files = String[]
push!(Base.include_callbacks, (mod::Module, fn::String) -> push!(loaded_files, fn))
include("test_sourcepath.jl")
@test length(loaded_files) == 1 && endswith(loaded_files[1], "test_sourcepath.jl")
pop!(Base.include_callbacks)
thefname = "the fname!//\\&\1*"
include_string_test_func = include_string(@__MODULE__, "include_string_test() = @__FILE__", thefname)
@test include_string_test_func() == thefname
@test include_string(@__MODULE__, "Base.source_path()", thefname) == Base.source_path()
@test basename(@__FILE__) == "loading.jl"
@test isabspath(@__FILE__)

@test isdir(@__DIR__)
@test @__DIR__() == dirname(@__FILE__)
let exename = `$(Base.julia_cmd()) --compiled-modules=yes --startup-file=no`,
    wd = sprint(show, abspath(pwd(), "")),
    s_dir = sprint(show, joinpath(realpath(tempdir()), ""))
    @test wd != s_dir
    @test readchomp(`$exename -E "@__DIR__" -i`) == wd
    @test readchomp(`$exename -E "cd(()->eval(:(@__DIR__)), $s_dir)" -i`) == s_dir
    @test readchomp(`$exename -E "@__DIR__"`) == wd # non-interactive
end

# Issue #5789 and PR #13542:
mktempdir() do dir
    cd(dir) do
        let true_filename = "cAsEtEsT.jl", lowered_filename="casetest.jl"
            touch(true_filename)
            @test Base.isfile_casesensitive(true_filename)
            @test !Base.isfile_casesensitive(lowered_filename)

            # check that case-sensitivity only applies to basename of a path:
            if isfile(lowered_filename) # case-insensitive filesystem
                mkdir("cAsEtEsT")
                touch(joinpath("cAsEtEsT", true_filename))
                @test Base.isfile_casesensitive(joinpath("casetest", true_filename))
                @test !Base.isfile_casesensitive(joinpath("casetest", lowered_filename))
            end
        end

        # Test Unicode normalization; pertinent for OS X
        let nfc_name = "\U00F4.jl"
            touch(nfc_name)
            @test Base.isfile_casesensitive(nfc_name)
        end
    end
end

import Base: SHA1, PkgId, load_path, identify_package, locate_package, version_slug
import UUIDs: UUID, uuid4, uuid_version
import Random: shuffle, randstring
using Test

saved_load_path = copy(LOAD_PATH)
saved_depot_path = copy(DEPOT_PATH)
push!(empty!(LOAD_PATH), "project")
push!(empty!(DEPOT_PATH), "depot")

@test load_path() == [abspath("project","Project.toml")]

@testset "project & manifest identify_package & locate_package" begin
    local path
    for (names, uuid, path) in [
        ("Foo",     "767738be-2f1f-45a9-b806-0234f3164144", "project/deps/Foo1/src/Foo.jl"       ),
        ("Bar.Foo", "6f418443-bd2e-4783-b551-cdbac608adf2", "project/deps/Foo2.jl/src/Foo.jl"    ),
        ("Bar",     "2a550a13-6bab-4a91-a4ee-dff34d6b99d0", "project/deps/Bar/src/Bar.jl"        ),
        ("Foo.Baz", "6801f525-dc68-44e8-a4e8-cabd286279e7", "depot/packages/9HkB/TCSb/src/Baz.jl"),
        ("Foo.Qux", "b5ec9b9c-e354-47fd-b367-a348bdc8f909", "project/deps/Qux.jl"                ),
    ]
        n = map(String, split(names, '.'))
        pkg = identify_package(n...)
        @test pkg == PkgId(UUID(uuid), n[end])
        @test joinpath(@__DIR__, normpath(path)) == locate_package(pkg)
    end
    @test identify_package("Baz") == nothing
    @test identify_package("Qux") == nothing
    @testset "equivalent package names" begin
        local classes = [
            ["Foo"],
            ["Bar", "Foo.Bar"],
            ["Foo.Baz", "Bar.Baz", "Foo.Bar.Baz"],
            ["Bar.Foo", "Foo.Bar.Foo", "Foo.Baz.Foo", "Bar.Baz.Foo"],
            ["Foo.Qux", "Foo.Baz.Qux", "Bar.Baz.Qux", "Foo.Bar.Foo.Qux",
             "Bar.Foo.Qux", "Foo.Baz.Foo.Qux", "Bar.Baz.Foo.Qux", "Foo.Bar.Baz.Foo.Qux"],
            ["Baz", "Qux", "Bar.Qux", "Bar.Baz.Bar", "Bar.Foo.Bar", "Bar.Foo.Baz",
             "Bar.Foo.Qux.Foo", "Bar.Foo.Qux.Bar", "Bar.Foo.Qux.Baz"],
        ]
        for i = 1:length(classes)
            A = classes[i]
            for x in A
                X = identify_package(map(String, split(x, '.'))...)
                for y in A
                    Y = identify_package(map(String, split(y, '.'))...)
                    @test X == Y
                end
                for j = i+1:length(classes)
                    B = classes[j]
                    for z in B
                        Z = identify_package(map(String, split(z, '.'))...)
                        @test X != Z
                    end
                end
            end
        end
    end
end

@testset "project & manifest import" begin
    @test !@isdefined Foo
    @test !@isdefined Bar
    import Foo
    @test @isdefined Foo
    @test !@isdefined Bar
    import Bar
    @test @isdefined Foo
    @test @isdefined Bar

    @testset "module graph structure" begin
        local classes = Dict(
            "Foo1" => [Foo],
            "Bar"  => [Bar, Foo.Bar],
            "Baz"  => [Foo.Baz, Bar.Baz, Foo.Bar.Baz],
            "Foo2" => [Bar.Foo, Foo.Bar.Foo, Foo.Baz.Foo, Bar.Baz.Foo],
            "Qux"  => [Foo.Qux, Foo.Baz.Qux, Bar.Baz.Qux, Foo.Bar.Foo.Qux,
                       Bar.Foo.Qux, Foo.Baz.Foo.Qux, Bar.Baz.Foo.Qux,
                       Foo.Bar.Baz.Foo.Qux],
        )
        for (i, (this, mods)) in enumerate(classes)
            for x in mods
                @test x.this == this
                for y in mods
                    @test x === y
                end
                for (j, (that, mods′)) in enumerate(classes)
                    i == j && continue
                    for z in mods′
                        @test x !== z
                    end
                end
            end
        end
    end
    @test Foo.which == "path"
end

function gen_entry_point(entry::String, pkg::PkgId)
    mkpath(dirname(entry))
    open(entry, "w") do io
        print(io, """
        __precompile__(true)
        module $(pkg.name)
        uuid = $(pkg.uuid === nothing ? "nothing" : "Base.UUID(\"$(pkg.uuid)\")")
        name = "$(pkg.name)"
        end
        """)
    end
end

function gen_project_file(project_file::String, pkg::PkgId, deps::Pair{String,UUID}...)
    mkpath(dirname(project_file))
    open(project_file, "w") do io
        println(io, "name = $(repr(pkg.name))")
        pkg.uuid !== nothing && println(io, "uuid = $(repr(string(pkg.uuid)))")
        println(io, "\n[deps]")
        for (name, uuid) in deps
            println(io, "$name = ", repr(string(uuid)))
        end
    end
end

function gen_implicit(dir::String, pkg::PkgId, proj::Bool, deps::Pair{String,UUID}...)
    entry_point = joinpath(dir, pkg.name, "src", "$(pkg.name).jl")
    gen_entry_point(entry_point, pkg)
    proj && gen_project_file(joinpath(dir, pkg.name, "Project.toml"), pkg, deps...)
    return entry_point
end

function gen_depot_ver(depot::String, pkg::PkgId, deps::Pair{String,UUID}...)
    pkg.uuid === nothing && return nothing, nothing
    tree = SHA1(rand(UInt8, 20)) # fake tree hash
    dir = joinpath(depot, "packages", version_slug(pkg.uuid, tree))
    entry = joinpath(dir, "src", "$(pkg.name).jl")
    gen_entry_point(entry, pkg)
    gen_project_file(joinpath(dir, "Project.toml"), pkg, deps...)
    return tree, entry
end

let n = 0
    global function gen_explicit(dir::String, pkg::PkgId=PkgId("Env$(n += 1)"))
        gen_project_file(joinpath(dir, "Project.toml"), pkg)
        close(open(joinpath(dir, "Manifest.toml"), "w"))
    end
end

function gen_manifest(dir::String, name::String, uuid::UUID, tree::SHA1,
    deps::Pair{String,UUID}...; toplevel::Bool = true)
    toplevel && open(joinpath(dir, "Project.toml"), "a") do io
        println(io, "$name = \"$uuid\"")
    end
    open(joinpath(dir, "Manifest.toml"), "a") do io
        println(io, "[[$name]]")
        println(io, "uuid = \"$uuid\"")
        println(io, "git-tree-sha1 = \"$(bytes2hex(tree.bytes))\"")
        if !isempty(deps)
            println(io, "    [$name.deps]")
            for (n, u) in deps
                println(io, "    $n = \"$u\"")
            end
        end
        println(io)
    end
end

false && let name = "Flarp"
uuidA = UUID("b2cb3794-8625-4058-bcde-7eeb13ac1c8b")
uuidB = UUID("1513c021-3639-4616-a37b-ee45c9d2f773")
uuids = [nothing, uuidA, uuidB]

ft(::UUID)    =  true:true
ft(::Nothing) = false:true

@testset "direct dependency loading: implict + implicit" begin
    for uuid1 in uuids, proj1 in ft(uuid1),
        uuid2 in uuids, proj2 in ft(uuid2)
        pkg1 = uuid1 === nothing ? PkgId(name) : PkgId(uuid1, name)
        pkg2 = uuid2 === nothing ? PkgId(name) : PkgId(uuid2, name)
        empty!(LOAD_PATH)
        mktempdir() do dir1
            push!(LOAD_PATH, dir1)
            path1 = gen_implicit(dir1, pkg1, proj1)
            @test identify_package(name) == pkg1
            @test locate_package(pkg1) == path1
            path = uuid1 == coalesce(uuid2, uuid1) ? path1 : nothing
            @test locate_package(pkg2) == path
            mktempdir() do dir2
                push!(LOAD_PATH, dir2)
                path2 = gen_implicit(dir2, pkg2, proj2)
                @test identify_package(name) == pkg1
                @test locate_package(pkg1) == path1
                path = uuid1 == coalesce(uuid2, uuid1) ? path1 : path2
                @test locate_package(pkg2) == path
            end
        end
    end
end

@testset "direct dependency loading: explicit + explicit" begin
    mktempdir() do depot
        push!(empty!(DEPOT_PATH), depot)
        pkgs  = [PkgId(uuid, name) for uuid in uuids]
        pairs = [gen_depot_ver(depot, pkg) for pkg in pkgs, _ in 1:2]
        trees = first.(pairs)
        paths = last.(pairs)
        for i = 1:length(uuids), k = 1:2,
            j = 1:length(uuids), l = 1:2
            uuids[i] !== nothing && uuids[j] !== nothing || continue
            empty!(LOAD_PATH)
            mktempdir() do dir1
                push!(LOAD_PATH, dir1)
                gen_explicit(dir1)
                gen_manifest(dir1, name, uuids[i], trees[i,k])
                @test identify_package(name) == pkgs[i]
                @test locate_package(pkgs[i]) == paths[i,k]
                path = uuids[i] == uuids[j] ? paths[i,k] : nothing
                @test locate_package(pkgs[j]) == path
                mktempdir() do dir2
                    push!(LOAD_PATH, dir2)
                    gen_explicit(dir2)
                    gen_manifest(dir2, name, uuids[j], trees[j,l])
                    @test identify_package(name) == pkgs[i]
                    @test locate_package(pkgs[i]) == paths[i,k]
                    path = uuids[i] == uuids[j] ? paths[i,k] : paths[j,l]
                    @test locate_package(pkgs[j]) == path
                end
            end
        end
    end
end

@testset "direct dependency loading: explicit + implicit" begin
    mktempdir() do depot
        push!(empty!(DEPOT_PATH), depot)
        pkgs  = [PkgId(uuid, name) for uuid in uuids]
        pairs = [gen_depot_ver(depot, pkg) for pkg in pkgs, _ in 1:2]
        trees = first.(pairs)
        paths = last.(pairs)
        for i = 1:length(uuids), k = 1:2,
            j = 1:length(uuids), l = 1:2, proj in ft(uuids[j])
            uuids[i] !== nothing || continue
            empty!(LOAD_PATH)
            mktempdir() do dir1
                push!(LOAD_PATH, dir1)
                gen_explicit(dir1)
                gen_manifest(dir1, name, uuids[i], trees[i,k])
                @test identify_package(name) == pkgs[i]
                @test locate_package(pkgs[i]) == paths[i,k]
                path = uuids[i] == coalesce(uuids[j], uuids[i]) ? paths[i,k] : nothing
                @test locate_package(pkgs[j]) == path
                mktempdir() do dir2
                    push!(LOAD_PATH, dir2)
                    path2 = gen_implicit(dir2, pkgs[j], proj)
                    @test identify_package(name) == pkgs[i]
                    @test locate_package(pkgs[i]) == paths[i,k]
                    path = uuids[i] == coalesce(uuids[j], uuids[i]) ? paths[i,k] : path2
                    @test locate_package(pkgs[j]) == path
                end
            end
        end
    end
end

uuidT = UUID("a54bd003-d8dc-4161-b186-d5516cd448e9")

@testset "indirect dependency loading: explicit + explicit" begin
    mktempdir() do depot
        push!(empty!(DEPOT_PATH), depot)
        # generate top-level package
        top = PkgId(uuidT, "TopLevel")
        top_tree, _ = gen_depot_ver(depot, top)
        # generate dependency packages
        pkgs  = [PkgId(uuid, name) for uuid in uuids]
        pairs = [gen_depot_ver(depot, pkg) for pkg in pkgs, _ in 1:2]
        trees = first.(pairs)
        paths = last.(pairs)
        for i = 1:length(uuids), k = 1:2, s = false:true,
            j = 1:length(uuids), l = 1:2, t = false:true
            uuids[i] !== nothing && uuids[j] !== nothing || continue
            empty!(LOAD_PATH)
            mktempdir() do dir1
                push!(LOAD_PATH, dir1)
                gen_explicit(dir1)
                gen_manifest(dir1, name, uuids[i], trees[i,k], toplevel=false)
                s && gen_manifest(dir1, top.name, top.uuid, top_tree, name => uuids[i])
                @test identify_package(top, name) == (s ? pkgs[i] : nothing)
                @test locate_package(pkgs[i]) == paths[i,k]
                path = uuids[i] == uuids[j] ? paths[i,k] : nothing
                @test locate_package(pkgs[j]) == path
                mktempdir() do dir2
                    push!(LOAD_PATH, dir2)
                    gen_explicit(dir2)
                    t && gen_manifest(dir1, top.name, top.uuid, top_tree, name => uuids[j])
                    gen_manifest(dir2, name, uuids[j], trees[j,l], toplevel=false)
                    pkg = (s ? pkgs[i] : t ? pkgs[j] : nothing)
                    @test identify_package(top, name) == pkg
                    @test locate_package(pkgs[i]) == paths[i,k]
                    path = uuids[i] == uuids[j] ? paths[i,k] : paths[j,l]
                    @test locate_package(pkgs[j]) == path
                end
            end
        end
    end
end
end # let

## systematic generation of test environments ##

const M = 3 # number of node names
const N = 12 # different UUIDs per name
const NODES = 1:M*N
const NAMES = map(string, ('A':'Z')[1:M])
const UUIDS = [uuid4() for i = 1:M, j = 1:N]
const KIND = [(i + j) % 3 for i = 1:M, j = 1:N]
const KIND0 = filter(i -> KIND[i] == 0, NODES)
const KIND2 = filter(i -> KIND[i] == 2, NODES)

# kind 0: no project file
# kind 1: project file without name or uuid
# kind 2: project file with name and uuid

# explicit env: root can be anything, everything else kind 2
# implicit env: nodes can be anything, names must be unique

# allowed dependencies between kinds (explicit and implicit):
allowed(i::Int, j::Int) = KIND[i] ≤ KIND[j] && !(KIND[i] == KIND[j] == 1)

# node names/labels
L(i::Int) = NAMES[mod1(i, M)]

# first generate random dependency graphs

const graphs = Any[]

while length(graphs) < 100
    if (flat = rand(Bool))
        root = rand(KIND0)
        pool = root ∪ filter(i -> L(i) ≠ L(root), NODES)
        size = rand(1:N)
    else
        root = rand(NODES)
        pool = filter(i -> i ≠ root, KIND2)
        size = rand(1:length(NODES)÷2)
    end
    graph = Dict(root => Int[])
    KIND[root] ≠ 0 && push!(graph[root], root)
    for _ = 1:size
        i = rand(keys(graph))
        J = filter(pool) do j
            allowed(i, j) && all(L(j) ≠ L(k) for k in graph[i])
        end
        isempty(J) && continue
        j = rand(J)
        push!(graph[i], j)
        if j ∉ keys(graph)
            graph[j] = [j]
            flat && filter!(k -> L(k) ≠ L(j), pool)
            isempty(pool) && break
        end
    end
    roots = flat ? reduce(∪, values(graph)) : graph[root]
    for i in keys(graph)
        KIND[i] == 0 && delete!(graph, i)
    end
    t = (flat, root,
        Dict(L(i) => i for i in roots),
        Dict(i => Dict(L(j) => j for j in deps) for (i, deps) in graph))
    t in graphs || push!(graphs, t)
end

# materialize dependency graphs as explicit environments

const envs = Dict{String,eltype(graphs)}()

for (flat, root, roots, graph) in graphs
    if flat
        all(KIND[i] == 2 for i in values(roots)) || continue
        all(KIND[i] == 2 for i in keys(graph)) || continue
    end
    dir = mktempdir()
    envs[dir] = (flat, root, roots, graph)

    # generate project file
    open(joinpath(dir, "Project.toml"), "w") do io
        name, uuid, kind = L(root), UUIDS[root], KIND[root]
        kind != 0 && println(io, "name = ", repr(name))
        kind == 2 && println(io, "uuid = ", repr(string(uuid)))
        println(io, "[deps]")
        for (n, i) in roots
            i == root && continue
            @assert KIND[i] == 2
            println(io, "$n = ", repr(string(UUIDS[i])))
        end
    end

    # count manifest entries
    counts = Dict(name => 0 for name in NAMES)
    for (i, _) in graph
        i == root && continue
        @assert KIND[i] == 2
        counts[L(i)] += 1
    end

    # generate manifest file
    open(joinpath(dir, "Manifest.toml"), "w") do io
        for (i, deps) in graph
            i == root && continue
            name, uuid = L(i), UUIDS[i]
            println(io, "[[$name]]")
            println(io, "uuid = ", repr(string(uuid)))
            deps = delete!(copy(deps), name)
            isempty(deps) && continue
            if all(counts[n] == 1 for n in keys(deps))
                println(io, "deps = ", repr(keys(deps)))
            else
                println(io, "  [$name.deps]")
                for (n, j) in deps
                    @assert KIND[j] == 2
                    println(io, "  $n = ", repr(string(UUIDS[j])))
                end
            end
        end
    end
end

# materialize dependency graphs as implicit environments (if possible)

for (flat, root, roots, graph) in graphs
    flat || continue
    dir = mktempdir()
    envs[dir] = (flat, root, roots, graph)

    for (name, i) in roots
        uuid, kind = UUIDS[i], KIND[i]
        # generate package entry point
        entry = joinpath(dir, name, "src", "$name.jl")
        mkpath(dirname(entry))
        open(entry, "w") do io
            print(io, """
            module $name
            name = $(repr(name))
            uuid = $(repr(string(uuid)))
            end
            """)
        end
        kind == 0 && continue
        deps = delete!(copy(graph[i]), name)
        # generate project file
        open(joinpath(dir, name, "Project.toml"), "w") do io
            kind != 0 && println(io, "name = ", repr(name))
            kind == 2 && println(io, "uuid = ", repr(string(uuid)))
            isempty(deps) || println(io, "[deps]")
            for (n, j) in deps
                @assert KIND[j] == 2
                println(io, "  $n = ", repr(string(UUIDS[j])))
            end
        end
    end
end

## use generated environments to test package loading ##

function pkg_id(id::Int)
    PkgId(KIND[id] == 2 ? UUIDS[id] : nothing, L(id))
end
function pkg_id(ids::Dict{String,Int}, name::String)
    haskey(ids, name) ? pkg_id(ids[name]) : nothing
end

function ≊(a::PkgId, b::PkgId)
    a.name == b.name || return false
    a.uuid == b.uuid && return true
    a.uuid == nothing && uuid_version(b.uuid) == 5 ||
    b.uuid == nothing && uuid_version(a.uuid) == 5
end
≊(a::Union{Nothing,PkgId}, b::Union{Nothing,PkgId}) = a == b

function add_id!(ids::Vector{Pair{Int,PkgId}},
    nodes::Dict{String,Int}, name::String, id::PkgId)
    node = nodes[name]
    any(node == i for (i, _) in ids) && return ids
    push!(ids, node => id)
end
function add_id!(ids::Vector{Pair{Int,PkgId}},
    nodes::Dict{String,Int}, name::String, ::Nothing)
    return ids # no op
end

function test_identify(roots::Dict{String,Int}, graph::Dict{Int,Dict{String,Int}})
    ids = Pair{Int,PkgId}[]
    # check & add named roots
    for name in NAMES
        id = identify_package(name)
        @test id ≊ pkg_id(roots, name)
        add_id!(ids, roots, name, id)
    end
    # add nodes reachable by uuid
    for (node, deps) in graph
        KIND[node] == 2 || continue
        add_id!(ids, deps, L(node), pkg_id(node))
    end
    # check all nodes reachable via `where`
    let i = 0
        while (i += 1) ≤ length(ids)
            node, where = ids[i]
            deps = get(graph, node, roots)
            for name in NAMES
                id = identify_package(where, name)
                @test id ≊ pkg_id(deps, name)
                add_id!(ids, deps, name, id)
            end
        end
    end
    # check all other package ids return nothing
    let ids = Dict(ids)
        for node in NODES
            node in keys(ids) && continue
            where = pkg_id(node)
            where.uuid == nothing && continue
            for name in NAMES
                id = where.name == name ? where : nothing
                @test identify_package(where, name) == id
            end
        end
    end
end

empty!(DEPOT_PATH)

@testset "identify_package with one env in load path" begin
    for (env, (_, _, roots, graph)) in envs
        push!(empty!(LOAD_PATH), env)
        test_identify(roots, graph)
    end
end

@testset "identify_package with two envs in load path" begin
    for x = false:true,
        (env1, (_, _, roots1, graph1)) in (x ? envs : rand(envs, 10)),
        (env2, (_, _, roots2, graph2)) in (x ? rand(envs, 10) : envs)
        push!(empty!(LOAD_PATH), env1, env2)
        roots = merge(roots2, roots1)
        graph = merge(graph2, graph1)
        test_identify(roots, graph)
    end
end

@testset "identify_package with three envs in load path" begin
    for (env1, (_, _, roots1, graph1)) in rand(envs, 10),
        (env2, (_, _, roots2, graph2)) in rand(envs, 10),
        (env3, (_, _, roots3, graph3)) in rand(envs, 10)
        push!(empty!(LOAD_PATH), env1, env2, env3)
        roots = merge(roots3, roots2, roots1)
        graph = merge(graph3, graph2, graph1)
        test_identify(roots, graph)
    end
end

## cleanup after tests ##

for env in keys(envs)
    rm(env, force=true, recursive=true)
end

append!(empty!(DEPOT_PATH), saved_depot_path)
append!(empty!(LOAD_PATH), saved_load_path)

max_stars_repo_name: BenChung/Julia-BTI

max_issues_repo_name: BenChung/Julia-BTI

max_forks_repo_name: BenChung/Julia-BTI


text:
using ConeProgramDiff
using Test
using LinearAlgebra, SparseArrays                       #stdlib
using JuMP, MathOptInterface, MathOptSetDistances       #Opt utils
using IterativeSolvers, Roots                           #Eq solvers
using SCS, ECOS, Hypatia                                #Opt solvers
using Random

const MOI = MathOptInterface
const MOSD = MathOptSetDistances

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

@testset "Projections" begin
    include("projections.jl")
end

@testset "D_Projections" begin
    include("d_projections.jl")
end

@testset "Solve and diff" begin
    include("solve_and_diff.jl")
end


text:
"""
    SolverOptions{T}

    Options and tolerances of primal-dual interior point solver.

    rtol: tolerance on residual violations (equality constraints); defaults to 1e-6
    btol: tolerance on bilinear violations (complementarity constraints); defaults to 1e-3
    ls_scale: line search scaling factor (α_new ← ls_scale * α_current); defaults to 0.5
    max_iter: maximum number of Newton iterations; defaults to 50
    max_ls: maximum number of line search steps; defaults to 10
    undercut: complementarity slackness target; solver will aim at reaching complementarity violation = btol / undercut; defaults to Inf
    no_progress_max: number of Newton's iterations without progress trigerring the rescaling of the target complementarity violation; defaults to 3
    no_progress_undercut: undercut scaling factor (target_new ← target_current / no_progress_undercut); defaults to 10
    verbose: flag for printing the status of the solver during the solve; defaults to false
"""
@with_kw mutable struct SolverOptions{T}
    rtol::T=1.0e-6
    btol::T=1.0e-3
    ls_scale::T=0.5
    max_iter::Int=50
    max_ls=10
    undercut::T=Inf
    no_progress_max::Int=3
    no_progress_undercut::T=10.0
    verbose::Bool=false
end


text:
#==============================================================================#
# MQ.jl
#
# This file is generated from:
# https://github.com/aws/aws-sdk-js/blob/master/apis/mq-2017-11-27.normal.json
#==============================================================================#

__precompile__()

module MQ

using AWSCore

"""
    using AWSSDK.MQ.create_broker
    create_broker([::AWSConfig], arguments::Dict)
    create_broker([::AWSConfig]; <keyword arguments>)

    using AWSCore.Services.mq
    mq([::AWSConfig], "POST", "/v1/brokers", arguments::Dict)
    mq([::AWSConfig], "POST", "/v1/brokers", <keyword arguments>)

# CreateBroker Operation

Creates a broker. Note: This API is asynchronous.

# Arguments

## `autoMinorVersionUpgrade = ::Bool`
Required. Enables automatic upgrades to new minor versions for brokers, as Apache releases the versions. The automatic upgrades occur during the maintenance window of the broker or after a manual broker reboot.

## `brokerName = ::String`
Required. The name of the broker. This value must be unique in your AWS account, 1-50 characters long, must contain only letters, numbers, dashes, and underscores, and must not contain whitespaces, brackets, wildcard characters, or special characters.

## `configuration = [ ... ]`
A list of information about the configuration.
```
 configuration = [
        "id" =>  ::String,
        "revision" =>  ::Int
    ]
```

## `creatorRequestId = ::String`
The unique ID that the requester receives for the created broker. Amazon MQ passes your ID with the API action. Note: We recommend using a Universally Unique Identifier (UUID) for the creatorRequestId. You may omit the creatorRequestId if your application doesn't require idempotency.

## `deploymentMode = "SINGLE_INSTANCE" or "ACTIVE_STANDBY_MULTI_AZ"`
Required. The deployment mode of the broker.

## `engineType = "ACTIVEMQ"`
Required. The type of broker engine. Note: Currently, Amazon MQ supports only ACTIVEMQ.

## `engineVersion = ::String`
Required. The version of the broker engine. Note: Currently, Amazon MQ supports only 5.15.0.

## `hostInstanceType = ::String`
Required. The broker's instance type.

## `logs = [ ... ]`
Enables Amazon CloudWatch logging for brokers.
```
 logs = [
        "audit" =>  ::Bool,
        "general" =>  ::Bool
    ]
```

## `maintenanceWindowStartTime = [ ... ]`
The parameters that determine the WeeklyStartTime.
```
 maintenanceWindowStartTime = [
        "dayOfWeek" =>  "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY" or "SUNDAY",
        "timeOfDay" =>  ::String,
        "timeZone" =>  ::String
    ]
```

## `publiclyAccessible = ::Bool`
Required. Enables connections from applications outside of the VPC that hosts the broker's subnets.

## `securityGroups = [::String, ...]`
The list of rules (1 minimum, 125 maximum) that authorize connections to brokers.

## `subnetIds = [::String, ...]`
The list of groups (2 maximum) that define which subnets and IP ranges the broker can use from different Availability Zones. A SINGLE_INSTANCE deployment requires one subnet (for example, the default subnet). An ACTIVE_STANDBY_MULTI_AZ deployment requires two subnets.

## `users = [[ ... ], ...]`
Required. The list of ActiveMQ users (persons or applications) who can access queues and topics. This value can contain only alphanumeric characters, dashes, periods, underscores, and tildes (- . _ ~). This value must be 2-100 characters long.
```
 users = [[
        "consoleAccess" =>  ::Bool,
        "groups" =>  [::String, ...],
        "password" =>  ::String,
        "username" =>  ::String
    ], ...]
```

# Returns

`CreateBrokerResponse`

# Exceptions

`BadRequestException`, `UnauthorizedException`, `InternalServerErrorException`, `ConflictException` or `ForbiddenException`.

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/mq-2017-11-27/CreateBroker)
"""
@inline create_broker(aws::AWSConfig=default_aws_config(); args...) = create_broker(aws, args)

@inline create_broker(aws::AWSConfig, args) = AWSCore.Services.mq(aws, "POST", "/v1/brokers", args)

@inline create_broker(args) = create_broker(default_aws_config(), args)

"""
    using AWSSDK.MQ.create_configuration
    create_configuration([::AWSConfig], arguments::Dict)
    create_configuration([::AWSConfig]; <keyword arguments>)

    using AWSCore.Services.mq
    mq([::AWSConfig], "POST", "/v1/configurations", arguments::Dict)
    mq([::AWSConfig], "POST", "/v1/configurations", <keyword arguments>)

# CreateConfiguration Operation

Creates a new configuration for the specified configuration name. Amazon MQ uses the default configuration (the engine type and version).

# Arguments

## `engineType = "ACTIVEMQ"`
Required. The type of broker engine. Note: Currently, Amazon MQ supports only ACTIVEMQ.

## `engineVersion = ::String`
Required. The version of the broker engine. Note: Currently, Amazon MQ supports only 5.15.0.

## `name = ::String`
Required. The name of the configuration. This value can contain only alphanumeric characters, dashes, periods, underscores, and tildes (- . _ ~). This value must be 1-150 characters long.

# Returns

`CreateConfigurationResponse`

# Exceptions

`BadRequestException`, `InternalServerErrorException`, `ConflictException` or `ForbiddenException`.

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/mq-2017-11-27/CreateConfiguration)
"""
@inline create_configuration(aws::AWSConfig=default_aws_config(); args...) = create_configuration(aws, args)

@inline create_configuration(aws::AWSConfig, args) = AWSCore.Services.mq(aws, "POST", "/v1/configurations", args)

@inline create_configuration(args) = create_configuration(default_aws_config(), args)

"""
    using AWSSDK.MQ.create_user
    create_user([::AWSConfig], arguments::Dict)
    create_user([::AWSConfig]; broker-id=, username=, <keyword arguments>)

    using AWSCore.Services.mq
    mq([::AWSConfig], "POST", "/v1/brokers/{broker-id}/users/{username}", arguments::Dict)
    mq([::AWSConfig], "POST", "/v1/brokers/{broker-id}/users/{username}", broker-id=, username=, <keyword arguments>)

# CreateUser Operation

Creates an ActiveMQ user.

# Arguments

## `broker-id = ::String` -- *Required*
The unique ID that Amazon MQ generates for the broker.

## `consoleAccess = ::Bool`
Enables access to the the ActiveMQ Web Console for the ActiveMQ user.

## `groups = [::String, ...]`
The list of groups (20 maximum) to which the ActiveMQ user belongs. This value can contain only alphanumeric characters, dashes, periods, underscores, and tildes (- . _ ~). This value must be 2-100 characters long.

## `password = ::String`
Required. The password of the user. This value must be at least 12 characters long, must contain at least 4 unique characters, and must not contain commas.

## `username = ::String` -- *Required*
The username of the ActiveMQ user. This value can contain only alphanumeric characters, dashes, periods, underscores, and tildes (- . _ ~). This value must be 2-100 characters long.

# Returns

`CreateUserResponse`

# Exceptions

`NotFoundException`, `BadRequestException`, `InternalServerErrorException`, `ConflictException` or `ForbiddenException`.

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/mq-2017-11-27/CreateUser)
"""
@inline create_user(aws::AWSConfig=default_aws_config(); args...) = create_user(aws, args)

@inline create_user(aws::AWSConfig, args) = AWSCore.Services.mq(aws, "POST", "/v1/brokers/{broker-id}/users/{username}", args)

@inline create_user(args) = create_user(default_aws_config(), args)

"""
    using AWSSDK.MQ.delete_broker
    delete_broker([::AWSConfig], arguments::Dict)
    delete_broker([::AWSConfig]; broker-id=)

    using AWSCore.Services.mq
    mq([::AWSConfig], "DELETE", "/v1/brokers/{broker-id}", arguments::Dict)
    mq([::AWSConfig], "DELETE", "/v1/brokers/{broker-id}", broker-id=)

# DeleteBroker Operation

Deletes a broker. Note: This API is asynchronous.

# Arguments

## `broker-id = ::String` -- *Required*
The name of the broker. This value must be unique in your AWS account, 1-50 characters long, must contain only letters, numbers, dashes, and underscores, and must not contain whitespaces, brackets, wildcard characters, or special characters.

# Returns

`DeleteBrokerResponse`

# Exceptions

`NotFoundException`, `BadRequestException`, `InternalServerErrorException` or `ForbiddenException`.

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/mq-2017-11-27/DeleteBroker)
"""
@inline delete_broker(aws::AWSConfig=default_aws_config(); args...) = delete_broker(aws, args)

@inline delete_broker(aws::AWSConfig, args) = AWSCore.Services.mq(aws, "DELETE", "/v1/brokers/{broker-id}", args)

@inline delete_broker(args) = delete_broker(default_aws_config(), args)

"""
    using AWSSDK.MQ.delete_user
    delete_user([::AWSConfig], arguments::Dict)
    delete_user([::AWSConfig]; broker-id=, username=)

    using AWSCore.Services.mq
    mq([::AWSConfig], "DELETE", "/v1/brokers/{broker-id}/users/{username}", arguments::Dict)
    mq([::AWSConfig], "DELETE", "/v1/brokers/{broker-id}/users/{username}", broker-id=, username=)

# DeleteUser Operation

Deletes an ActiveMQ user.

# Arguments

## `broker-id = ::String` -- *Required*
The unique ID that Amazon MQ generates for the broker.

## `username = ::String` -- *Required*
The username of the ActiveMQ user. This value can contain only alphanumeric characters, dashes, periods, underscores, and tildes (- . _ ~). This value must be 2-100 characters long.

# Returns

`DeleteUserResponse`

# Exceptions

`NotFoundException`, `BadRequestException`, `InternalServerErrorException` or `ForbiddenException`.

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/mq-2017-11-27/DeleteUser)
"""
@inline delete_user(aws::AWSConfig=default_aws_config(); args...) = delete_user(aws, args)

@inline delete_user(aws::AWSConfig, args) = AWSCore.Services.mq(aws, "DELETE", "/v1/brokers/{broker-id}/users/{username}", args)

@inline delete_user(args) = delete_user(default_aws_config(), args)

"""
    using AWSSDK.MQ.describe_broker
    describe_broker([::AWSConfig], arguments::Dict)
    describe_broker([::AWSConfig]; broker-id=)

    using AWSCore.Services.mq
    mq([::AWSConfig], "GET", "/v1/brokers/{broker-id}", arguments::Dict)
    mq([::AWSConfig], "GET", "/v1/brokers/{broker-id}", broker-id=)

# DescribeBroker Operation

Returns information about the specified broker.

# Arguments

## `broker-id = ::String` -- *Required*
The name of the broker. This value must be unique in your AWS account, 1-50 characters long, must contain only letters, numbers, dashes, and underscores, and must not contain whitespaces, brackets, wildcard characters, or special characters.

# Returns

`DescribeBrokerResponse`

# Exceptions

`NotFoundException`, `BadRequestException`, `InternalServerErrorException` or `ForbiddenException`.

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/mq-2017-11-27/DescribeBroker)
"""
@inline describe_broker(aws::AWSConfig=default_aws_config(); args...) = describe_broker(aws, args)

@inline describe_broker(aws::AWSConfig, args) = AWSCore.Services.mq(aws, "GET", "/v1/brokers/{broker-id}", args)

@inline describe_broker(args) = describe_broker(default_aws_config(), args)

"""
    using AWSSDK.MQ.describe_configuration
    describe_configuration([::AWSConfig], arguments::Dict)
    describe_configuration([::AWSConfig]; configuration-id=)

    using AWSCore.Services.mq
    mq([::AWSConfig], "GET", "/v1/configurations/{configuration-id}", arguments::Dict)
    mq([::AWSConfig], "GET", "/v1/configurations/{configuration-id}", configuration-id=)

# DescribeConfiguration Operation

Returns information about the specified configuration.

# Arguments

## `configuration-id = ::String` -- *Required*
The unique ID that Amazon MQ generates for the configuration.

# Returns

`DescribeConfigurationResponse`

# Exceptions

`NotFoundException`, `BadRequestException`, `InternalServerErrorException` or `ForbiddenException`.

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/mq-2017-11-27/DescribeConfiguration)
"""
@inline describe_configuration(aws::AWSConfig=default_aws_config(); args...) = describe_configuration(aws, args)

@inline describe_configuration(aws::AWSConfig, args) = AWSCore.Services.mq(aws, "GET", "/v1/configurations/{configuration-id}", args)

@inline describe_configuration(args) = describe_configuration(default_aws_config(), args)

"""
    using AWSSDK.MQ.describe_configuration_revision
    describe_configuration_revision([::AWSConfig], arguments::Dict)
    describe_configuration_revision([::AWSConfig]; configuration-id=, configuration-revision=)

    using AWSCore.Services.mq
    mq([::AWSConfig], "GET", "/v1/configurations/{configuration-id}/revisions/{configuration-revision}", arguments::Dict)
    mq([::AWSConfig], "GET", "/v1/configurations/{configuration-id}/revisions/{configuration-revision}", configuration-id=, configuration-revision=)

# DescribeConfigurationRevision Operation

Returns the specified configuration revision for the specified configuration.

# Arguments

## `configuration-id = ::String` -- *Required*
The unique ID that Amazon MQ generates for the configuration.

## `configuration-revision = ::String` -- *Required*
The revision of the configuration.

# Returns

`DescribeConfigurationRevisionResponse`

# Exceptions

`NotFoundException`, `BadRequestException`, `InternalServerErrorException` or `ForbiddenException`.

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/mq-2017-11-27/DescribeConfigurationRevision)
"""
@inline describe_configuration_revision(aws::AWSConfig=default_aws_config(); args...) = describe_configuration_revision(aws, args)

@inline describe_configuration_revision(aws::AWSConfig, args) = AWSCore.Services.mq(aws, "GET", "/v1/configurations/{configuration-id}/revisions/{configuration-revision}", args)

@inline describe_configuration_revision(args) = describe_configuration_revision(default_aws_config(), args)

"""
    using AWSSDK.MQ.describe_user
    describe_user([::AWSConfig], arguments::Dict)
    describe_user([::AWSConfig]; broker-id=, username=)

    using AWSCore.Services.mq
    mq([::AWSConfig], "GET", "/v1/brokers/{broker-id}/users/{username}", arguments::Dict)
    mq([::AWSConfig], "GET", "/v1/brokers/{broker-id}/users/{username}", broker-id=, username=)

# DescribeUser Operation

Returns information about an ActiveMQ user.

# Arguments

## `broker-id = ::String` -- *Required*
The unique ID that Amazon MQ generates for the broker.

## `username = ::String` -- *Required*
The username of the ActiveMQ user. This value can contain only alphanumeric characters, dashes, periods, underscores, and tildes (- . _ ~). This value must be 2-100 characters long.

# Returns

`DescribeUserResponse`

# Exceptions

`NotFoundException`, `BadRequestException`, `InternalServerErrorException` or `ForbiddenException`.

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/mq-2017-11-27/DescribeUser)
"""
@inline describe_user(aws::AWSConfig=default_aws_config(); args...) = describe_user(aws, args)

@inline describe_user(aws::AWSConfig, args) = AWSCore.Services.mq(aws, "GET", "/v1/brokers/{broker-id}/users/{username}", args)

@inline describe_user(args) = describe_user(default_aws_config(), args)

"""
    using AWSSDK.MQ.list_brokers
    list_brokers([::AWSConfig], arguments::Dict)
    list_brokers([::AWSConfig]; <keyword arguments>)

    using AWSCore.Services.mq
    mq([::AWSConfig], "GET", "/v1/brokers", arguments::Dict)
    mq([::AWSConfig], "GET", "/v1/brokers", <keyword arguments>)

# ListBrokers Operation

Returns a list of all brokers.

# Arguments

## `maxResults = ::Int`
The maximum number of brokers that Amazon MQ can return per page (20 by default). This value must be an integer from 5 to 100.

## `nextToken = ::String`
The token that specifies the next page of results Amazon MQ should return. To request the first page, leave nextToken empty.

# Returns

`ListBrokersResponse`

# Exceptions

`BadRequestException`, `InternalServerErrorException` or `ForbiddenException`.

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/mq-2017-11-27/ListBrokers)
"""
@inline list_brokers(aws::AWSConfig=default_aws_config(); args...) = list_brokers(aws, args)

@inline list_brokers(aws::AWSConfig, args) = AWSCore.Services.mq(aws, "GET", "/v1/brokers", args)

@inline list_brokers(args) = list_brokers(default_aws_config(), args)

"""
    using AWSSDK.MQ.list_configuration_revisions
    list_configuration_revisions([::AWSConfig], arguments::Dict)
    list_configuration_revisions([::AWSConfig]; configuration-id=, <keyword arguments>)

    using AWSCore.Services.mq
    mq([::AWSConfig], "GET", "/v1/configurations/{configuration-id}/revisions", arguments::Dict)
    mq([::AWSConfig], "GET", "/v1/configurations/{configuration-id}/revisions", configuration-id=, <keyword arguments>)

# ListConfigurationRevisions Operation

Returns a list of all revisions for the specified configuration.

# Arguments

## `configuration-id = ::String` -- *Required*
The unique ID that Amazon MQ generates for the configuration.

## `maxResults = ::Int`
The maximum number of configurations that Amazon MQ can return per page (20 by default). This value must be an integer from 5 to 100.

## `nextToken = ::String`
The token that specifies the next page of results Amazon MQ should return. To request the first page, leave nextToken empty.

# Returns

`ListConfigurationRevisionsResponse`

# Exceptions

`NotFoundException`, `BadRequestException`, `InternalServerErrorException` or `ForbiddenException`.

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/mq-2017-11-27/ListConfigurationRevisions)
"""
@inline list_configuration_revisions(aws::AWSConfig=default_aws_config(); args...) = list_configuration_revisions(aws, args)

@inline list_configuration_revisions(aws::AWSConfig, args) = AWSCore.Services.mq(aws, "GET", "/v1/configurations/{configuration-id}/revisions", args)

@inline list_configuration_revisions(args) = list_configuration_revisions(default_aws_config(), args)

"""
    using AWSSDK.MQ.list_configurations
    list_configurations([::AWSConfig], arguments::Dict)
    list_configurations([::AWSConfig]; <keyword arguments>)

    using AWSCore.Services.mq
    mq([::AWSConfig], "GET", "/v1/configurations", arguments::Dict)
    mq([::AWSConfig], "GET", "/v1/configurations", <keyword arguments>)

# ListConfigurations Operation

Returns a list of all configurations.

# Arguments

## `maxResults = ::Int`
The maximum number of configurations that Amazon MQ can return per page (20 by default). This value must be an integer from 5 to 100.

## `nextToken = ::String`
The token that specifies the next page of results Amazon MQ should return. To request the first page, leave nextToken empty.

# Returns

`ListConfigurationsResponse`

# Exceptions

`BadRequestException`, `InternalServerErrorException` or `ForbiddenException`.

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/mq-2017-11-27/ListConfigurations)
"""
@inline list_configurations(aws::AWSConfig=default_aws_config(); args...) = list_configurations(aws, args)

@inline list_configurations(aws::AWSConfig, args) = AWSCore.Services.mq(aws, "GET", "/v1/configurations", args)

@inline list_configurations(args) = list_configurations(default_aws_config(), args)

"""
    using AWSSDK.MQ.list_users
    list_users([::AWSConfig], arguments::Dict)
    list_users([::AWSConfig]; broker-id=, <keyword arguments>)

    using AWSCore.Services.mq
    mq([::AWSConfig], "GET", "/v1/brokers/{broker-id}/users", arguments::Dict)
    mq([::AWSConfig], "GET", "/v1/brokers/{broker-id}/users", broker-id=, <keyword arguments>)

# ListUsers Operation

Returns a list of all ActiveMQ users.

# Arguments

## `broker-id = ::String` -- *Required*
The unique ID that Amazon MQ generates for the broker.

## `maxResults = ::Int`
The maximum number of ActiveMQ users that can be returned per page (20 by default). This value must be an integer from 5 to 100.

## `nextToken = ::String`
The token that specifies the next page of results Amazon MQ should return. To request the first page, leave nextToken empty.

# Returns

`ListUsersResponse`

# Exceptions

`NotFoundException`, `BadRequestException`, `InternalServerErrorException` or `ForbiddenException`.

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/mq-2017-11-27/ListUsers)
"""
@inline list_users(aws::AWSConfig=default_aws_config(); args...) = list_users(aws, args)

@inline list_users(aws::AWSConfig, args) = AWSCore.Services.mq(aws, "GET", "/v1/brokers/{broker-id}/users", args)

@inline list_users(args) = list_users(default_aws_config(), args)

"""
    using AWSSDK.MQ.reboot_broker
    reboot_broker([::AWSConfig], arguments::Dict)
    reboot_broker([::AWSConfig]; broker-id=)

    using AWSCore.Services.mq
    mq([::AWSConfig], "POST", "/v1/brokers/{broker-id}/reboot", arguments::Dict)
    mq([::AWSConfig], "POST", "/v1/brokers/{broker-id}/reboot", broker-id=)

# RebootBroker Operation

Reboots a broker. Note: This API is asynchronous.

# Arguments

## `broker-id = ::String` -- *Required*
The unique ID that Amazon MQ generates for the broker.

# Returns

`RebootBrokerResponse`

# Exceptions

`NotFoundException`, `BadRequestException`, `InternalServerErrorException` or `ForbiddenException`.

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/mq-2017-11-27/RebootBroker)
"""
@inline reboot_broker(aws::AWSConfig=default_aws_config(); args...) = reboot_broker(aws, args)

@inline reboot_broker(aws::AWSConfig, args) = AWSCore.Services.mq(aws, "POST", "/v1/brokers/{broker-id}/reboot", args)

@inline reboot_broker(args) = reboot_broker(default_aws_config(), args)

"""
    using AWSSDK.MQ.update_broker
    update_broker([::AWSConfig], arguments::Dict)
    update_broker([::AWSConfig]; broker-id=, <keyword arguments>)

    using AWSCore.Services.mq
    mq([::AWSConfig], "PUT", "/v1/brokers/{broker-id}", arguments::Dict)
    mq([::AWSConfig], "PUT", "/v1/brokers/{broker-id}", broker-id=, <keyword arguments>)

# UpdateBroker Operation

Adds a pending configuration change to a broker.

# Arguments

## `broker-id = ::String` -- *Required*
The name of the broker. This value must be unique in your AWS account, 1-50 characters long, must contain only letters, numbers, dashes, and underscores, and must not contain whitespaces, brackets, wildcard characters, or special characters.

## `configuration = [ ... ]`
A list of information about the configuration.
```
 configuration = [
        "id" =>  ::String,
        "revision" =>  ::Int
    ]
```

## `logs = [ ... ]`
Enables Amazon CloudWatch logging for brokers.
```
 logs = [
        "audit" =>  ::Bool,
        "general" =>  ::Bool
    ]
```

# Returns

`UpdateBrokerResponse`

# Exceptions

`NotFoundException`, `BadRequestException`, `InternalServerErrorException` or `ForbiddenException`.

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/mq-2017-11-27/UpdateBroker)
"""
@inline update_broker(aws::AWSConfig=default_aws_config(); args...) = update_broker(aws, args)

@inline update_broker(aws::AWSConfig, args) = AWSCore.Services.mq(aws, "PUT", "/v1/brokers/{broker-id}", args)

@inline update_broker(args) = update_broker(default_aws_config(), args)

"""
    using AWSSDK.MQ.update_configuration
    update_configuration([::AWSConfig], arguments::Dict)
    update_configuration([::AWSConfig]; configuration-id=, <keyword arguments>)

    using AWSCore.Services.mq
    mq([::AWSConfig], "PUT", "/v1/configurations/{configuration-id}", arguments::Dict)
    mq([::AWSConfig], "PUT", "/v1/configurations/{configuration-id}", configuration-id=, <keyword arguments>)

# UpdateConfiguration Operation

Updates the specified configuration.

# Arguments

## `configuration-id = ::String` -- *Required*
The unique ID that Amazon MQ generates for the configuration.

## `data = ::String`
Required. The base64-encoded XML configuration.

## `description = ::String`
The description of the configuration.

# Returns

`UpdateConfigurationResponse`

# Exceptions

`NotFoundException`, `BadRequestException`, `InternalServerErrorException`, `ConflictException` or `ForbiddenException`.

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/mq-2017-11-27/UpdateConfiguration)
"""
@inline update_configuration(aws::AWSConfig=default_aws_config(); args...) = update_configuration(aws, args)

@inline update_configuration(aws::AWSConfig, args) = AWSCore.Services.mq(aws, "PUT", "/v1/configurations/{configuration-id}", args)

@inline update_configuration(args) = update_configuration(default_aws_config(), args)

"""
    using AWSSDK.MQ.update_user
    update_user([::AWSConfig], arguments::Dict)
    update_user([::AWSConfig]; broker-id=, username=, <keyword arguments>)

    using AWSCore.Services.mq
    mq([::AWSConfig], "PUT", "/v1/brokers/{broker-id}/users/{username}", arguments::Dict)
    mq([::AWSConfig], "PUT", "/v1/brokers/{broker-id}/users/{username}", broker-id=, username=, <keyword arguments>)

# UpdateUser Operation

Updates the information for an ActiveMQ user.

# Arguments

## `broker-id = ::String` -- *Required*
The unique ID that Amazon MQ generates for the broker.

## `consoleAccess = ::Bool`
Enables access to the the ActiveMQ Web Console for the ActiveMQ user.

## `groups = [::String, ...]`
The list of groups (20 maximum) to which the ActiveMQ user belongs. This value can contain only alphanumeric characters, dashes, periods, underscores, and tildes (- . _ ~). This value must be 2-100 characters long.

## `password = ::String`
The password of the user. This value must be at least 12 characters long, must contain at least 4 unique characters, and must not contain commas.

## `username = ::String` -- *Required*
Required. The username of the ActiveMQ user. This value can contain only alphanumeric characters, dashes, periods, underscores, and tildes (- . _ ~). This value must be 2-100 characters long.

# Returns

`UpdateUserResponse`

# Exceptions

`NotFoundException`, `BadRequestException`, `InternalServerErrorException`, `ConflictException` or `ForbiddenException`.

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/mq-2017-11-27/UpdateUser)
"""
@inline update_user(aws::AWSConfig=default_aws_config(); args...) = update_user(aws, args)

@inline update_user(aws::AWSConfig, args) = AWSCore.Services.mq(aws, "PUT", "/v1/brokers/{broker-id}/users/{username}", args)

@inline update_user(args) = update_user(default_aws_config(), args)

end # module MQ

#==============================================================================#
# End of file
#==============================================================================#


text:
include("mod_polynomials_test.jl")

function poly_mult_benchmark()
    println("---- Multiplication Test ----")
    println("(Time for New method on top")
    println("")
    for mod in [5,41,211,1009,10007]
        println("Mod = $mod")
        println("")
        for i in [5,20,50,100,500]
            println("   Degree = $i:")
            print("     ")
            @time for _ in 1:50
                p1 = rand(PolynomialModP,mod, degree = i)
                p2 = rand(PolynomialModP,mod, degree = i)
                p1*p2
            end
            print("     ")
            @time for _ in 1:50
                p1 = rand(PolynomialModP,mod, degree = i)
                p2 = rand(PolynomialModP,mod, degree = i)
                p1*p2
            end
        end
        println("")
        @time mod_prod_test_poly(mod)
        println("")
    end
end

function big_poly_Benchmark(;n = 100::Int,coeff = 10000::Int)
    println("Time Test for One Big Polynomial")
    p1 = rand(Polynomial, degree = n,max_coeff = coeff)
    p2 = rand(Polynomial, degree = n,max_coeff = coeff)
    @time a = p1*p2
    @time b = p1*̄p2
    @assert a == b
    println("")
end

function addbench()
    println("---- Time Compairson for the Two Addition Algorithms ----")
    a = rand(PolynomialModP,101, degree = 10000)
    b = rand(PolynomialModP,101, degree = 10000)

    println("")
    println("+ function:")
    @time for _ in 1:10000
        p1 = rand(PolynomialModP,101)
        p2 = rand(PolynomialModP,101)
        p1+p2
    end

    println("")
    println("Plus() function:")
    @time for _ in 1:10000
        p1 = rand(PolynomialModP,101)
        p2 = rand(PolynomialModP,101)
        plus(p1,p2)
    end

end

function multbenchZ()
    println("---- Time Compairson for the Two Multiplication Algorithms (Z[x]) ----")
    println("")
    println("CRT: *")
    @time for _ in 1:100
        p1 = rand(Polynomial,degree = 100)
        p2 = rand(Polynomial,degree = 100)
        p1*p2
    end
    println("")
    println("Expansion: *̄()")

    @time for _ in 1:100
        p1 = rand(Polynomial, degree = 100)
        p2 = rand(Polynomial,degree = 100)
        p1 *̄ p2
    end

end

function multbenchZp()
    println("---- Time Compairson for the Four Multiplication Algorithms ----")
    println("")
    println("Vector Distribution: *")
    @time for _ in 1:100
        p1 = rand(PolynomialModP,101,degree = 100)
        p2 = rand(PolynomialModP,101,degree = 100)
        p1*p2
    end
    println("")
    println("Polynomial Distribution: mult()")

    @time for _ in 1:100
        p1 = rand(PolynomialModP,101,degree = 100)
        p2 = rand(PolynomialModP,101,degree = 100)
        mult(p1,p2)
    end
    println("")
    println("Vector Splitting: mult2()")
    @time for _ in 1:100
        p1 = rand(PolynomialModP,101,degree = 100)
        p2 = rand(PolynomialModP,101,degree = 100)
        mult2(p1,p2)
    end
    println("")
    println("Polynomial Splitting: mult3()")
    @time for _ in 1:100
        p1 = rand(PolynomialModP,101,degree = 100)
        p2 = rand(PolynomialModP,101,degree = 100)
        mult3(p1,p2)
    end
end

function powbench()
    println("")
    println("---- Time Compairson for the two Power Algorithms Z_p[x]----")
    println("Binary Expansion: ^()")
    @time for _ in 1:10
        p1 = rand(PolynomialModP,101,degree = 10)
        p1^200
    end
    println("")
    println("Repeated Multiplication: pow()")
    @time for _ in 1:10
        p1 = rand(PolynomialModP,101,degree = 10)
        pow(p1,200)
    end
end