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

using Markdown
using InteractiveUtils

# ╔═╡ 5e902e3c-2c19-11ec-39df-3fba9fe5640c
begin
	import MLJLinearModels
	import MLJDecisionTreeInterface

	using DataFrames: DataFrame, select, Not
	using Distributions: Normal
	using CairoMakie: Axis, Figure, lines, lines!, scatter, scatter!, current_figure, axislegend, help, linkxaxes!, linkyaxes!, xlabel!, density, density!, hidedecorations!, violin!, boxplot!, hidexdecorations!, hideydecorations!
	using MLJ: CV, evaluate, models, matching, @load, machine, fit!, predict, predict_mode, rms
	using Random: seed!
	using Statistics: mean, std, var, median
	using MLJTuning: TunedModel, Explicit
	using MLJModelInterface: Probabilistic, Deterministic
end

# ╔═╡ ea44c5c8-02d6-4bcb-90e7-01fb3db9e44e
# hideall
md"""
Nested cross-validation is said to be an improvement over cross-validation.
Unfortunately, I found most explanations quite confusing, so decided to simulate some data and see what happens.

In this post, I simulate two models: one linear model which perfectly fits the data and one which overfits the data.
Next, cross-validation and nested cross-validation are plotted.
To keep the post short, I've hidden the code to produce the plots.
"""

# ╔═╡ b37e1bc1-2f53-4637-852b-5c8e38912a0e
# hideall
function compatible_models()
	X = (a = [1.0], b = [2.0], c = [3.0])
	y = [4.0]
	M = models(matching(X, y))
	filter(m -> m.is_pure_julia, M)
end;

# ╔═╡ b0b55bb3-d445-4f45-bd33-c26f28d074e1
# hideall
compatible_models();

# ╔═╡ e4584145-243d-4ba9-853c-82189a9b96df
y_true(x) = 2x + 10;

# ╔═╡ a998b36b-7183-4657-ae14-ab81212138ab
y_real(x) = y_true(x) + rand(Normal(0, 40));

# ╔═╡ fc89a45d-fe73-45aa-a8ef-bf090884dd00
indexes = 1.0:100;

# ╔═╡ 3f39b4eb-7aab-4dda-adbf-3be971d4cb99
df = let
	seed!(0)
	DataFrame(x = indexes, y = y_real.(indexes))
end

# ╔═╡ b641a8d6-624b-4562-92e2-276388f573de
LinearModel = @load LinearRegressor pkg=MLJLinearModels verbosity=0;

# ╔═╡ d7751696-1bb5-4ee8-a8e7-45da5dd71947
TreeModel = @load DecisionTreeRegressor pkg=DecisionTree verbosity=0;

# ╔═╡ 3f99e49e-9e51-4f8f-9c21-9f670d63f3c4
X, y = (select(df, Not(:y)), df.y);

# ╔═╡ 1e0ac73d-1faf-4250-a6f5-032c67649326
function linear_model()
	model = LinearModel(fit_intercept=true)
	mach = machine(model, X, y)
	fit!(mach)
	return mach
end;

# ╔═╡ 772ec163-7861-4bbe-a90b-d6b6f7c08040
function tree_model()
	model = TreeModel()
	mach = machine(model, X, y)
	fit!(mach)
	return mach
end;

# ╔═╡ d07d4596-bc21-4ba7-9f78-9ce00d1d9339
# hideall
let
	linear_predictions = predict(linear_model())
	tree_predictions = predict(tree_model())
	color = :black
	markersize = 2
	linewidth = 2
	fig = Figure()
	ax1 = Axis(fig[1, 1]; ylabel="y")
	ax2 = Axis(fig[2, 1]; xlabel="x", ylabel="y")
	lines!(ax1, df.x, linear_predictions; linewidth, color, label="LinearRegressor")
	lines!(ax1, df.x, y_true.(df.x); linewidth, linestyle=:dash, color, label="True model")
	scatter!(ax1, df.x, df.y; color, markersize)
	axislegend(ax1; position=:lt)
	lines!(ax2, df.x, tree_predictions; linewidth, color, label="DecisionTreeRegressor")
	lines!(ax2, df.x, y_true.(df.x); linewidth, linestyle=:dash, color, label="True model")
	scatter!(ax2, df.x, df.y; color, markersize)
	axislegend(ax2; position=:lt)
	fig
end

# ╔═╡ 86a2c569-d139-467e-948c-18f60d0cd93a
# hideall
md"""
Okay, so which model performs better. I would guess the `LinearRegressor`, but let's see what the root-mean-square error (RMS) is when we fit the models on the training data:
"""

# ╔═╡ a09b498e-931e-4fd3-b3e3-eefc16d2e65f
rms(predict(linear_model()), df.y)

# ╔═╡ 662d7494-6248-4adc-ac0d-0f4c68e4418d
rms(predict(tree_model()), df.y)

# ╔═╡ c0a0bd8b-fe78-4ea1-8619-62a26a968a10
# hideall
md"""
Clearly, the tree model is overfitting the data.
In other words, the model is not expected to perform well on new data.

Now the question is whether we can determine that the linear model is the right one via cross-validation.
Let's first plot the error for each of our $k$ folds.
"""

# ╔═╡ 696808d5-3547-4666-bfcc-46e658ebbced
# hideall
r1(x) = round(x; digits=1);

# ╔═╡ 916a78d9-a6f7-4e60-8511-9d654f74f3de
# hideall
function evaluate_model(model, resampling)
	e = evaluate(model, X, y; resampling)
	per_fold = first(e.per_fold)
end;

# ╔═╡ bfebf58b-daf5-4d74-ba9b-fc853da3b166
# hideall
foldsmean(per_fold) = fill(mean(per_fold), length(per_fold));

# ╔═╡ da994d08-9d14-45b9-a80a-7ea6a13edd67
# hideall
let
	nfolds = 10
	color = :black
	fig = Figure()
	resampling = CV(; nfolds)
	linear_per_fold = evaluate_model(LinearModel(), resampling)
	tree_per_fold = evaluate_model(TreeModel(), resampling)
	foldsmean(per_fold) = fill(mean(per_fold), length(folds))
	folds = 1:nfolds

	ax1 = Axis(fig[1, 1]; xlabel="fold", ylabel="root-mean-square error")
	lines!(ax1, folds, linear_per_fold; color, label="LinearRegressor")
	lines!(ax1, folds, foldsmean(linear_per_fold); color, linestyle=:dash, label="Mean")
	axislegend(ax1; position=:lt)

	ax2 = Axis(fig[1, 2]; xlabel="fold")
	lines!(ax2, folds, tree_per_fold; color, label="DecisionTreeRegressor")
	lines!(ax2, folds, foldsmean(tree_per_fold); color, linestyle=:dash, label="Mean")
	axislegend(ax2; position=:lt)
	hideydecorations!(ax2)

	# ax3 = Axis(fig[1, 4:5])
	# density!(ax3, linear_per_fold; strokewidth=1, strokecolor=:black, color=:white, direction=:y)
	# hidedecorations!(ax3; grid=false)

	linkyaxes!(ax1, ax2)
	current_figure()
end

# ╔═╡ 641ac771-1424-45ba-a313-d6e1e8b7eaf4
# hideall
md"""
So, basically cross-validation isn't gonna be perfect. If the data or standard deviation would have been different, then another model could have obtained a lower error according to the cross-validation.

Let's tryout nested cross-validation.

According to Zhang ([2015](https://doi.org/10.1016/j.jeconom.2015.02.006)), repeated 50- and 20- fold CV is best for $n_t$ sample points and the best cross-validation parameters for model selection are not necessarily the same the best cross-validation parameters for performance estimation (p. 104 and p. 105).
"""

# ╔═╡ d0e5d310-d09d-4e00-b942-07e48d8ab00e
function evaluate_inner_folds(nfolds::Int, ntrials::Int)
	inner_resampling = CV(; nfolds=nfolds)
	multi_model = TunedModel(; models=[LinearModel(), TreeModel()], resampling=inner_resampling);
	outer_resampling = CV(; nfolds=ntrials)
	e = evaluate(multi_model, X, y; measure=rms, resampling=outer_resampling)
	return e
end;

# ╔═╡ feaca510-5403-474f-b598-8467569161ce
# hideall
md"""
The problem of cross-validation is that it is still possible to overfit during model selection.
Therefore, the only reliable way to estimate model performance is to use nested cross-validation (Krstajic et al., [2014](https://doi.org/10.1186/1758-2946-6-10)).
Also, repeated k-fold nested cross-validation is the most promising for prediction error estimation.

Let's see how the plots for nested cross-validation look:
"""

# ╔═╡ 0024dfce-b6ff-4a38-8afc-1092591422cb
# hideall
function plot_trial_model!(ax, e, trial::Int, model::Int)
	m = e.report_per_fold[trial].history[model]
	indexes = 1:length(first(m.per_fold))
	color = :black
	label = string(m.model)
	per_fold = first(m.per_fold)
	lines!(ax, indexes, per_fold; label, color)

	# lines!(ax1, folds, linear_per_fold; color, label="LinearRegressor")
	lines!(ax, indexes, foldsmean(per_fold); color, linestyle=:dash, label="Mean")
	axislegend(ax; position=:lt)
end;

# ╔═╡ dccd8ec8-cc40-43a1-bad7-e1ad699a4a40
# hideall
function nested_variance(e)
	var(e.per_fold[1])
end;

# ╔═╡ 72012d1a-fd91-4b40-9137-18dc01205c00
# hideall
function plot_trial!(fig, e, trial::Int)
	ax1 = Axis(fig[trial, 1]; ylabel="trial $trial \n root-mean-square error")
	ax2 = Axis(fig[trial, 2])

	plot_trial_model!(ax1, e, trial, 1)
	plot_trial_model!(ax2, e, trial, 2)
	linkyaxes!(ax1, ax2)
	hideydecorations!(ax2)
	return ax1, ax2
end;

# ╔═╡ e1de9f5d-c062-4068-8652-e0bac41bee9b
e = evaluate_inner_folds(20, 20);

# ╔═╡ 5f92f025-fd2a-4ed4-84b6-ebadb0c689fe
# hideall
nested_variance(e);

# ╔═╡ 95f8e3cf-c6b9-4d84-bc35-b933008bf112
# hideall
let
	color = :black
	fig = Figure(; resolution=(900, 1500))

	plot_trial!(fig, e, 1)
	plot_trial!(fig, e, 2)
	plot_trial!(fig, e, 3)
	plot_trial!(fig, e, 4)
	plot_trial!(fig, e, 5)
	axa, axb = plot_trial!(fig, e, 6)
	axa.xlabel = "fold"
	axb.xlabel = "fold"
	current_figure()
end

# ╔═╡ 88544422-e781-43a4-8eae-35713aa59193
# hideall
foldrange = 2:2:83;

# ╔═╡ 43f00e6a-ad6d-47e9-8074-266fffa3cb82
# hideall
foldevaluations = [evaluate_inner_folds(i, 6) for i in foldrange];

# ╔═╡ 37c2861b-fed1-4c78-a8e5-0827ab98e477
# hideall
function evaluate_function!(ax, range, evaluations, f)
	results = [f(e.per_fold[1]) for e in evaluations]

	ax.ylabel = f == var ? "variance" : string(f)
	lines!(ax, range, results; color=:black)
	scatter!(ax, range, results; color=:black)
end;

# ╔═╡ 95877eb0-f7b7-4123-8718-b9d30f3e2c3f
# hideall
md"""
That looks interesting, but what happens with the median, mean and variance if we change the number of folds and trials?
"""

# ╔═╡ 626e0034-caef-4435-9716-c4449375159e
# hideall
function plot_evaluations(range, evals; xlabel=nothing)
	means = [mean(e.per_fold[1]) for e in evals]

	fig = Figure()
	ax1 = Axis(fig[1, 1])
	evaluate_function!(ax1, range, evals, median)

	ax2 = Axis(fig[2, 1])
	evaluate_function!(ax2, range, evals, mean)
	linkyaxes!(ax1, ax2)
	hidexdecorations!(ax1)

	ax3 = Axis(fig[3, 1]; xlabel)
	evaluate_function!(ax3, range, evals, var)
	hidexdecorations!(ax2)

	linkxaxes!(ax1, ax2, ax3)
	current_figure()
end;

# ╔═╡ 40f48800-1aca-4587-a26e-fea92b0ce8ba
# hideall
plot_evaluations(foldrange, foldevaluations; xlabel="number of folds")

# ╔═╡ 0630eb20-01a3-41f8-a7ad-202a56b43954
# hideall
trialrange = 2:4:60;

# ╔═╡ ad007c31-d39b-4f10-9e95-755f40cb6844
# hideall
trialevaluations = [evaluate_inner_folds(30, i) for i in trialrange];

# ╔═╡ 135f5d2b-4645-493b-97ae-e4d9e76ab8be
# hideall
plot_evaluations(trialrange, trialevaluations; xlabel="number of trials")

# ╔═╡ 734712fa-0871-4793-9ef4-74f856f2613f
# hideall
md"""
I don't know what should be the take-away here.
What kind of makes sense is that the variance increases for many trails.
The reason is most likely that the samples become too small and fitting a model is either a complete hit or miss.

Why the median and mean go down is unclear to me.
Maybe, fitting is more likely to be a hit than a miss.
Therefore, if the number of trails is increased, then more fits are a hit which result in a lower error on average.
"""

# ╔═╡ 00000000-0000-0000-0000-000000000001
PLUTO_PROJECT_TOML_CONTENTS = """
[deps]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
MLJ = "add582a8-e3ab-11e8-2d5e-e98b27df1bc7"
MLJDecisionTreeInterface = "c6f25543-311c-4c74-83dc-3ea6d1015661"
MLJLinearModels = "6ee0df7b-362f-4a72-a706-9e79364fb692"
MLJModelInterface = "e80e1ace-859a-464e-9ed9-23947d8ae3ea"
MLJTuning = "03970b2e-30c4-11ea-3135-d1576263f10f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[compat]
CairoMakie = "~0.6.5"
DataFrames = "~1.2.2"
Distributions = "~0.25.19"
MLJ = "~0.16.9"
MLJDecisionTreeInterface = "~0.1.3"
MLJLinearModels = "~0.5.6"
MLJModelInterface = "~1.3.2"
MLJTuning = "~0.6.13"
"""

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

[[ARFFFiles]]
deps = ["CategoricalArrays", "Dates", "Parsers", "Tables"]
git-tree-sha1 = "3556fa90c0bea9f965388c0e123418cb9f5ff2e3"
uuid = "da404889-ca92-49ff-9e8b-0aa6b4d38dc8"
version = "1.4.0"

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

[[AbstractTrees]]
git-tree-sha1 = "03e0550477d86222521d254b741d470ba17ea0b5"
uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
version = "0.3.4"

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

[[Animations]]
deps = ["Colors"]
git-tree-sha1 = "e81c509d2c8e49592413bfb0bb3b08150056c79d"
uuid = "27a7e980-b3e6-11e9-2bcd-0b925532e340"
version = "0.4.1"

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

[[ArrayInterface]]
deps = ["Compat", "IfElse", "LinearAlgebra", "Requires", "SparseArrays", "Static"]
git-tree-sha1 = "b8d49c34c3da35f220e7295659cd0bab8e739fed"
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
version = "3.1.33"

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

[[Automa]]
deps = ["Printf", "ScanByte", "TranscodingStreams"]
git-tree-sha1 = "d50976f217489ce799e366d9561d56a98a30d7fe"
uuid = "67c07d97-cdcb-5c2c-af73-a7f9c32a568b"
version = "0.8.2"

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

[[BSON]]
git-tree-sha1 = "ebcd6e22d69f21249b7b8668351ebf42d6dc87a1"
uuid = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0"
version = "0.3.4"

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

[[Bzip2_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "19a35467a82e236ff51bc17a3a44b69ef35185a2"
uuid = "6e34b625-4abd-537c-b88f-471c36dfa7a0"
version = "1.0.8+0"

[[CEnum]]
git-tree-sha1 = "215a9aa4a1f23fbd05b92769fdd62559488d70e9"
uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82"
version = "0.4.1"

[[Cairo]]
deps = ["Cairo_jll", "Colors", "Glib_jll", "Graphics", "Libdl", "Pango_jll"]
git-tree-sha1 = "d0b3f8b4ad16cb0a2988c6788646a5e6a17b6b1b"
uuid = "159f3aea-2a34-519c-b102-8c37f9878175"
version = "1.0.5"

[[CairoMakie]]
deps = ["Base64", "Cairo", "Colors", "FFTW", "FileIO", "FreeType", "GeometryBasics", "LinearAlgebra", "Makie", "SHA", "StaticArrays"]
git-tree-sha1 = "8664989955daccc90002629aa80193e44893bb45"
uuid = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
version = "0.6.5"

[[Cairo_jll]]
deps = ["Artifacts", "Bzip2_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "JLLWrappers", "LZO_jll", "Libdl", "Pixman_jll", "Pkg", "Xorg_libXext_jll", "Xorg_libXrender_jll", "Zlib_jll", "libpng_jll"]
git-tree-sha1 = "f2202b55d816427cd385a9a4f3ffb226bee80f99"
uuid = "83423d85-b0ee-5818-9007-b63ccbeb887a"
version = "1.16.1+0"

[[CategoricalArrays]]
deps = ["DataAPI", "Future", "Missings", "Printf", "Requires", "Statistics", "Unicode"]
git-tree-sha1 = "fbc5c413a005abdeeb50ad0e54d85d000a1ca667"
uuid = "324d7699-5711-5eae-9e2f-1d82baa6b597"
version = "0.10.1"

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

[[CodecZlib]]
deps = ["TranscodingStreams", "Zlib_jll"]
git-tree-sha1 = "ded953804d019afa9a3f98981d99b33e3db7b6da"
uuid = "944b1d66-785c-5afd-91f1-9de20f533193"
version = "0.7.0"

[[ColorBrewer]]
deps = ["Colors", "JSON", "Test"]
git-tree-sha1 = "61c5334f33d91e570e1d0c3eb5465835242582c4"
uuid = "a2cac450-b92f-5266-8821-25eda20663c8"
version = "0.4.0"

[[ColorSchemes]]
deps = ["ColorTypes", "Colors", "FixedPointNumbers", "Random"]
git-tree-sha1 = "a851fec56cb73cfdf43762999ec72eff5b86882a"
uuid = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
version = "3.15.0"

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

[[ColorVectorSpace]]
deps = ["ColorTypes", "FixedPointNumbers", "LinearAlgebra", "SpecialFunctions", "Statistics", "TensorCore"]
git-tree-sha1 = "45efb332df2e86f2cb2e992239b6267d97c9e0b6"
uuid = "c3611d14-8923-5661-9e6a-0046d554d3a4"
version = "0.9.7"

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

[[CommonSubexpressions]]
deps = ["MacroTools", "Test"]
git-tree-sha1 = "7b8a93dba8af7e3b42fecabf646260105ac373f7"
uuid = "bbf7d656-a473-5ed7-a52c-81e309532950"
version = "0.3.0"

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

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

[[ComputationalResources]]
git-tree-sha1 = "52cb3ec90e8a8bea0e62e275ba577ad0f74821f7"
uuid = "ed09eef8-17a6-5b46-8889-db040fac31e3"
version = "0.3.2"

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

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

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

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

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

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

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

[[DecisionTree]]
deps = ["DelimitedFiles", "Distributed", "LinearAlgebra", "Random", "ScikitLearnBase", "Statistics", "Test"]
git-tree-sha1 = "123adca1e427dc8abc5eec5040644e7842d53c92"
uuid = "7806a523-6efd-50cb-b5f6-3fa6f1930dbb"
version = "0.10.11"

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

[[DiffResults]]
deps = ["StaticArrays"]
git-tree-sha1 = "c18e98cba888c6c25d1c3b048e4b3380ca956805"
uuid = "163ba53b-c6d8-5494-b064-1a9d43ac40c5"
version = "1.0.3"

[[DiffRules]]
deps = ["NaNMath", "Random", "SpecialFunctions"]
git-tree-sha1 = "7220bc21c33e990c14f4a9a319b1d242ebc5b269"
uuid = "b552c78f-8df3-52c6-915a-8e097449b14b"
version = "1.3.1"

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

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

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

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

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

[[EarCut_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "3f3a2501fa7236e9b911e0f7a588c657e822bb6d"
uuid = "5ae413db-bbd1-5e63-b57d-d24a61df00f5"
version = "2.2.3+0"

[[EarlyStopping]]
deps = ["Dates", "Statistics"]
git-tree-sha1 = "9427bc7a6c186d892f71b1c36ee7619e440c9e06"
uuid = "792122b4-ca99-40de-a6bc-6742525f08b6"
version = "0.1.8"

[[EllipsisNotation]]
deps = ["ArrayInterface"]
git-tree-sha1 = "8041575f021cba5a099a456b4163c9a08b566a02"
uuid = "da5c29d0-fa7d-589e-88eb-ea29b0a81949"
version = "1.1.0"

[[Expat_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "b3bfd02e98aedfa5cf885665493c5598c350cd2f"
uuid = "2e619515-83b5-522b-bb60-26c02a35a201"
version = "2.2.10+0"

[[ExprTools]]
git-tree-sha1 = "b7e3d17636b348f005f11040025ae8c6f645fe92"
uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
version = "0.1.6"

[[FFMPEG]]
deps = ["FFMPEG_jll"]
git-tree-sha1 = "b57e3acbe22f8484b4b5ff66a7499717fe1a9cc8"
uuid = "c87230d0-a227-11e9-1b43-d7ebe4e7570a"
version = "0.4.1"

[[FFMPEG_jll]]
deps = ["Artifacts", "Bzip2_jll", "FreeType2_jll", "FriBidi_jll", "JLLWrappers", "LAME_jll", "Libdl", "Ogg_jll", "OpenSSL_jll", "Opus_jll", "Pkg", "Zlib_jll", "libass_jll", "libfdk_aac_jll", "libvorbis_jll", "x264_jll", "x265_jll"]
git-tree-sha1 = "d8a578692e3077ac998b50c0217dfd67f21d1e5f"
uuid = "b22a6f82-2f65-5046-a5b2-351ab43fb4e5"
version = "4.4.0+0"

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

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

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

[[FilePathsBase]]
deps = ["Dates", "Mmap", "Printf", "Test", "UUIDs"]
git-tree-sha1 = "7fb0eaac190a7a68a56d2407a6beff1142daf844"
uuid = "48062228-2e41-5def-b9a4-89aafe57970f"
version = "0.9.12"

[[FillArrays]]
deps = ["LinearAlgebra", "Random", "SparseArrays", "Statistics"]
git-tree-sha1 = "8756f9935b7ccc9064c6eef0bff0ad643df733a3"
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
version = "0.12.7"

[[FiniteDiff]]
deps = ["ArrayInterface", "LinearAlgebra", "Requires", "SparseArrays", "StaticArrays"]
git-tree-sha1 = "8b3c09b56acaf3c0e581c66638b85c8650ee9dca"
uuid = "6a86dc24-6348-571c-b903-95158fe2bd41"
version = "2.8.1"

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

[[Fontconfig_jll]]
deps = ["Artifacts", "Bzip2_jll", "Expat_jll", "FreeType2_jll", "JLLWrappers", "Libdl", "Libuuid_jll", "Pkg", "Zlib_jll"]
git-tree-sha1 = "21efd19106a55620a188615da6d3d06cd7f6ee03"
uuid = "a3f928ae-7b40-5064-980b-68af3947d34b"
version = "2.13.93+0"

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

[[ForwardDiff]]
deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "NaNMath", "Preferences", "Printf", "Random", "SpecialFunctions", "StaticArrays"]
git-tree-sha1 = "63777916efbcb0ab6173d09a658fb7f2783de485"
uuid = "f6369f11-7733-5829-9624-2563aa707210"
version = "0.10.21"

[[FreeType]]
deps = ["CEnum", "FreeType2_jll"]
git-tree-sha1 = "cabd77ab6a6fdff49bfd24af2ebe76e6e018a2b4"
uuid = "b38be410-82b0-50bf-ab77-7b57e271db43"
version = "4.0.0"

[[FreeType2_jll]]
deps = ["Artifacts", "Bzip2_jll", "JLLWrappers", "Libdl", "Pkg", "Zlib_jll"]
git-tree-sha1 = "87eb71354d8ec1a96d4a7636bd57a7347dde3ef9"
uuid = "d7e528f0-a631-5988-bf34-fe36492bcfd7"
version = "2.10.4+0"

[[FreeTypeAbstraction]]
deps = ["ColorVectorSpace", "Colors", "FreeType", "GeometryBasics", "StaticArrays"]
git-tree-sha1 = "19d0f1e234c13bbfd75258e55c52aa1d876115f5"
uuid = "663a7486-cb36-511b-a19d-713bb74d65c9"
version = "0.9.2"

[[FriBidi_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "aa31987c2ba8704e23c6c8ba8a4f769d5d7e4f91"
uuid = "559328eb-81f9-559d-9380-de523a88c83c"
version = "1.0.10+0"

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

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

[[Gettext_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Libiconv_jll", "Pkg", "XML2_jll"]
git-tree-sha1 = "9b02998aba7bf074d14de89f9d37ca24a1a0b046"
uuid = "78b55507-aeef-58d4-861c-77aaff3498b1"
version = "0.21.0+0"

[[Glib_jll]]
deps = ["Artifacts", "Gettext_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Libiconv_jll", "Libmount_jll", "PCRE_jll", "Pkg", "Zlib_jll"]
git-tree-sha1 = "7bf67e9a481712b3dbe9cb3dac852dc4b1162e02"
uuid = "7746bdde-850d-59dc-9ae8-88ece973131d"
version = "2.68.3+0"

[[Graphics]]
deps = ["Colors", "LinearAlgebra", "NaNMath"]
git-tree-sha1 = "1c5a84319923bea76fa145d49e93aa4394c73fc2"
uuid = "a2bd30eb-e257-5431-a919-1863eab51364"
version = "1.1.1"

[[Graphite2_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "344bf40dcab1073aca04aa0df4fb092f920e4011"
uuid = "3b182d85-2403-5c21-9c21-1e1f0cc25472"
version = "1.3.14+0"

[[GridLayoutBase]]
deps = ["GeometryBasics", "InteractiveUtils", "Match", "Observables"]
git-tree-sha1 = "e2f606c87d09d5187bb6069dab8cee0af7c77bdb"
uuid = "3955a311-db13-416c-9275-1d80ed98e5e9"
version = "0.6.1"

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

[[HTTP]]
deps = ["Base64", "Dates", "IniFile", "Logging", "MbedTLS", "NetworkOptions", "Sockets", "URIs"]
git-tree-sha1 = "14eece7a3308b4d8be910e265c724a6ba51a9798"
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
version = "0.9.16"

[[HarfBuzz_jll]]
deps = ["Artifacts", "Cairo_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "Graphite2_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Pkg"]
git-tree-sha1 = "8a954fed8ac097d5be04921d595f741115c1b2ad"
uuid = "2e76f6c2-a576-52d4-95c1-20adfe4de566"
version = "2.8.1+0"

[[IfElse]]
git-tree-sha1 = "28e837ff3e7a6c3cdb252ce49fb412c8eb3caeef"
uuid = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
version = "0.1.0"

[[ImageCore]]
deps = ["AbstractFFTs", "ColorVectorSpace", "Colors", "FixedPointNumbers", "Graphics", "MappedArrays", "MosaicViews", "OffsetArrays", "PaddedViews", "Reexport"]
git-tree-sha1 = "9a5c62f231e5bba35695a20988fc7cd6de7eeb5a"
uuid = "a09fc81d-aa75-5fe9-8630-4744c3626534"
version = "0.9.3"

[[ImageIO]]
deps = ["FileIO", "Netpbm", "OpenEXR", "PNGFiles", "TiffImages", "UUIDs"]
git-tree-sha1 = "13c826abd23931d909e4c5538643d9691f62a617"
uuid = "82e4d734-157c-48bb-816b-45c225c6df19"
version = "0.5.8"

[[Imath_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "87f7662e03a649cffa2e05bf19c303e168732d3e"
uuid = "905a6f67-0a94-5f89-b386-d35d92009cd1"
version = "3.1.2+0"

[[IndirectArrays]]
git-tree-sha1 = "012e604e1c7458645cb8b436f8fba789a51b257f"
uuid = "9b13fd28-a010-5f03-acff-a1bbcff69959"
version = "1.0.0"

[[Inflate]]
git-tree-sha1 = "f5fc07d4e706b84f72d54eedcc1c13d92fb0871c"
uuid = "d25df0c9-e2be-5dd7-82c8-3ad0b3e990b9"
version = "0.1.2"

[[IniFile]]
deps = ["Test"]
git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8"
uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f"
version = "0.5.0"

[[InlineStrings]]
deps = ["Parsers"]
git-tree-sha1 = "19cb49649f8c41de7fea32d089d37de917b553da"
uuid = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48"
version = "1.0.1"

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

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

[[Interpolations]]
deps = ["AxisAlgorithms", "ChainRulesCore", "LinearAlgebra", "OffsetArrays", "Random", "Ratios", "Requires", "SharedArrays", "SparseArrays", "StaticArrays", "WoodburyMatrices"]
git-tree-sha1 = "61aa005707ea2cebf47c8d780da8dc9bc4e0c512"
uuid = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
version = "0.13.4"

[[IntervalSets]]
deps = ["Dates", "EllipsisNotation", "Statistics"]
git-tree-sha1 = "3cc368af3f110a767ac786560045dceddfc16758"
uuid = "8197267c-284f-5f27-9208-e0e47529a953"
version = "0.5.3"

[[InvertedIndices]]
git-tree-sha1 = "bee5f1ef5bf65df56bdd2e40447590b272a5471f"
uuid = "41ab1584-1d38-5bbf-9106-f11c6c58b48f"
version = "1.1.0"

[[IrrationalConstants]]
git-tree-sha1 = "7fd44fd4ff43fc60815f8e764c0f352b83c49151"
uuid = "92d709cd-6900-40b7-9082-c6be49f344b6"
version = "0.1.1"

[[Isoband]]
deps = ["isoband_jll"]
git-tree-sha1 = "f9b6d97355599074dc867318950adaa6f9946137"
uuid = "f1662d9f-8043-43de-a69a-05efc1cc6ff4"
version = "0.1.1"

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

[[IterationControl]]
deps = ["EarlyStopping", "InteractiveUtils"]
git-tree-sha1 = "f61d5d4d0e433b3fab03ca5a1bfa2d7dcbb8094c"
uuid = "b3c1a2ee-3fec-4384-bf48-272ea71de57c"
version = "0.4.0"

[[IterativeSolvers]]
deps = ["LinearAlgebra", "Printf", "Random", "RecipesBase", "SparseArrays"]
git-tree-sha1 = "1a8c6237e78b714e901e406c096fc8a65528af7d"
uuid = "42fd0dbc-a981-5370-80f2-aaf504508153"
version = "0.9.1"

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

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

[[JLSO]]
deps = ["BSON", "CodecZlib", "FilePathsBase", "Memento", "Pkg", "Serialization"]
git-tree-sha1 = "e00feb9d56e9e8518e0d60eef4d1040b282771e2"
uuid = "9da8a3cd-07a3-59c0-a743-3fdc52c30d11"
version = "2.6.0"

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

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

[[LAME_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "f6250b16881adf048549549fba48b1161acdac8c"
uuid = "c1c5ebd0-6772-5130-a774-d5fcae4a789d"
version = "3.100.1+0"

[[LZO_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "e5b909bcf985c5e2605737d2ce278ed791b89be6"
uuid = "dd4b983a-f0e5-5f8d-a1b7-129d4a5fb1ac"
version = "2.10.1+0"

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

[[LatinHypercubeSampling]]
deps = ["Random", "StableRNGs", "StatsBase", "Test"]
git-tree-sha1 = "42938ab65e9ed3c3029a8d2c58382ca75bdab243"
uuid = "a5e1c1ea-c99a-51d3-a14d-a9a37257b02d"
version = "1.8.0"

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

[[LearnBase]]
git-tree-sha1 = "a0d90569edd490b82fdc4dc078ea54a5a800d30a"
uuid = "7f8f8fb0-2700-5f03-b4bd-41f8cfc144b6"
version = "0.4.1"

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

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

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

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

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

[[Libffi_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "761a393aeccd6aa92ec3515e428c26bf99575b3b"
uuid = "e9f186c6-92d2-5b65-8a66-fee21dc1b490"
version = "3.2.2+0"

[[Libgcrypt_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Libgpg_error_jll", "Pkg"]
git-tree-sha1 = "64613c82a59c120435c067c2b809fc61cf5166ae"
uuid = "d4300ac3-e22c-5743-9152-c294e39db1e4"
version = "1.8.7+0"

[[Libgpg_error_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "c333716e46366857753e273ce6a69ee0945a6db9"
uuid = "7add5ba3-2f88-524e-9cd5-f83b8a55f7b8"
version = "1.42.0+0"

[[Libiconv_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "42b62845d70a619f063a7da093d995ec8e15e778"
uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531"
version = "1.16.1+1"

[[Libmount_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "9c30530bf0effd46e15e0fdcf2b8636e78cbbd73"
uuid = "4b2f31a3-9ecc-558c-b454-b3730dcb73e9"
version = "2.35.0+0"

[[Libuuid_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "7f3efec06033682db852f8b3bc3c1d2b0a0ab066"
uuid = "38a345b3-de98-5d2b-a5d3-14cd9215e700"
version = "2.36.0+0"

[[LineSearches]]
deps = ["LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "Printf"]
git-tree-sha1 = "f27132e551e959b3667d8c93eae90973225032dd"
uuid = "d3d80556-e9d4-5f37-9878-2ab0fcc64255"
version = "7.1.1"

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

[[LinearMaps]]
deps = ["LinearAlgebra", "SparseArrays"]
git-tree-sha1 = "a03a9d24d4597725d9e826cee1ef5164e6bdd661"
uuid = "7a12625a-238d-50fd-b39a-03d52299707e"
version = "3.4.1"

[[LogExpFunctions]]
deps = ["ChainRulesCore", "DocStringExtensions", "IrrationalConstants", "LinearAlgebra"]
git-tree-sha1 = "34dc30f868e368f8a17b728a1238f3fcda43931a"
uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
version = "0.3.3"

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

[[LossFunctions]]
deps = ["InteractiveUtils", "LearnBase", "Markdown", "RecipesBase", "StatsBase"]
git-tree-sha1 = "0f057f6ea90a84e73a8ef6eebb4dc7b5c330020f"
uuid = "30fc2ffe-d236-52d8-8643-a9d8f7c094a7"
version = "0.7.2"

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

[[MLJ]]
deps = ["CategoricalArrays", "ComputationalResources", "Distributed", "Distributions", "LinearAlgebra", "MLJBase", "MLJEnsembles", "MLJIteration", "MLJModels", "MLJSerialization", "MLJTuning", "OpenML", "Pkg", "ProgressMeter", "Random", "ScientificTypes", "Statistics", "StatsBase", "Tables"]
git-tree-sha1 = "4c3c8c5326052a7b4f043660d65bd42dd1408040"
uuid = "add582a8-e3ab-11e8-2d5e-e98b27df1bc7"
version = "0.16.9"

[[MLJBase]]
deps = ["CategoricalArrays", "ComputationalResources", "Dates", "DelimitedFiles", "Distributed", "Distributions", "InteractiveUtils", "InvertedIndices", "LinearAlgebra", "LossFunctions", "MLJModelInterface", "Missings", "OrderedCollections", "Parameters", "PrettyTables", "ProgressMeter", "Random", "ScientificTypes", "StatisticalTraits", "Statistics", "StatsBase", "Tables"]
git-tree-sha1 = "84cd04e1df20dee21d8aa2f00a69d225ba4f19d0"
uuid = "a7f614a8-145f-11e9-1d2a-a57a1082229d"
version = "0.18.23"

[[MLJDecisionTreeInterface]]
deps = ["DecisionTree", "MLJModelInterface", "Random"]
git-tree-sha1 = "e2a5e2f0fd72cae51d72a83e6c11167de96c7a4c"
uuid = "c6f25543-311c-4c74-83dc-3ea6d1015661"
version = "0.1.3"

[[MLJEnsembles]]
deps = ["CategoricalArrays", "ComputationalResources", "Distributed", "Distributions", "MLJBase", "MLJModelInterface", "ProgressMeter", "Random", "ScientificTypes", "StatsBase"]
git-tree-sha1 = "f8ca949d52432b81f621d9da641cf59829ad2c8c"
uuid = "50ed68f4-41fd-4504-931a-ed422449fee0"
version = "0.1.2"

[[MLJIteration]]
deps = ["IterationControl", "MLJBase", "Random"]
git-tree-sha1 = "3bf120afd409c10b4689c1ad3d7bfe945092d722"
uuid = "614be32b-d00c-4edb-bd02-1eb411ab5e55"
version = "0.3.2"

[[MLJLinearModels]]
deps = ["DocStringExtensions", "IterativeSolvers", "LinearAlgebra", "LinearMaps", "MLJModelInterface", "Optim", "Parameters"]
git-tree-sha1 = "9eb4f07f23d44a898213eb4927869598442d90bb"
uuid = "6ee0df7b-362f-4a72-a706-9e79364fb692"
version = "0.5.6"

[[MLJModelInterface]]
deps = ["Random", "ScientificTypesBase", "StatisticalTraits"]
git-tree-sha1 = "91ef121a2c458806973c8aaeb502c57b2f0d74b3"
uuid = "e80e1ace-859a-464e-9ed9-23947d8ae3ea"
version = "1.3.2"

[[MLJModels]]
deps = ["CategoricalArrays", "Dates", "Distances", "Distributions", "InteractiveUtils", "LinearAlgebra", "MLJBase", "MLJModelInterface", "OrderedCollections", "Parameters", "Pkg", "REPL", "Random", "Requires", "ScientificTypes", "Statistics", "StatsBase", "Tables"]
git-tree-sha1 = "25dfbfa33d1e7dabcdec63e00585974f85715851"
uuid = "d491faf4-2d78-11e9-2867-c94bc002c0b7"
version = "0.14.12"

[[MLJSerialization]]
deps = ["IterationControl", "JLSO", "MLJBase", "MLJModelInterface"]
git-tree-sha1 = "cd6285f95948fe1047b7d6fd346c172e247c1188"
uuid = "17bed46d-0ab5-4cd4-b792-a5c4b8547c6d"
version = "1.1.2"

[[MLJTuning]]
deps = ["ComputationalResources", "Distributed", "Distributions", "LatinHypercubeSampling", "MLJBase", "ProgressMeter", "Random", "RecipesBase"]
git-tree-sha1 = "b9ddb9dcc45b1b585119d9964290def61404ef61"
uuid = "03970b2e-30c4-11ea-3135-d1576263f10f"
version = "0.6.13"

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

[[Makie]]
deps = ["Animations", "Base64", "ColorBrewer", "ColorSchemes", "ColorTypes", "Colors", "Contour", "Distributions", "DocStringExtensions", "FFMPEG", "FileIO", "FixedPointNumbers", "Formatting", "FreeType", "FreeTypeAbstraction", "GeometryBasics", "GridLayoutBase", "ImageIO", "IntervalSets", "Isoband", "KernelDensity", "LaTeXStrings", "LinearAlgebra", "MakieCore", "Markdown", "Match", "MathTeXEngine", "Observables", "Packing", "PlotUtils", "PolygonOps", "Printf", "Random", "RelocatableFolders", "Serialization", "Showoff", "SignedDistanceFields", "SparseArrays", "StaticArrays", "Statistics", "StatsBase", "StatsFuns", "StructArrays", "UnicodeFun"]
git-tree-sha1 = "7e49f989e7c7f50fe55bd92d45329c9cf3f2583d"
uuid = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
version = "0.15.2"

[[MakieCore]]
deps = ["Observables"]
git-tree-sha1 = "7bcc8323fb37523a6a51ade2234eee27a11114c8"
uuid = "20f20a25-4f0e-4fdf-b5d1-57303727442b"
version = "0.1.3"

[[MappedArrays]]
git-tree-sha1 = "e8b359ef06ec72e8c030463fe02efe5527ee5142"
uuid = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900"
version = "0.4.1"

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

[[Match]]
git-tree-sha1 = "5cf525d97caf86d29307150fcba763a64eaa9cbe"
uuid = "7eb4fadd-790c-5f42-8a69-bfa0b872bfbf"
version = "1.1.0"

[[MathTeXEngine]]
deps = ["AbstractTrees", "Automa", "DataStructures", "FreeTypeAbstraction", "GeometryBasics", "LaTeXStrings", "REPL", "RelocatableFolders", "Test"]
git-tree-sha1 = "70e733037bbf02d691e78f95171a1fa08cdc6332"
uuid = "0a4f8689-d25c-4efe-a92b-7142dfc1aa53"
version = "0.2.1"

[[MbedTLS]]
deps = ["Dates", "MbedTLS_jll", "Random", "Sockets"]
git-tree-sha1 = "1c38e51c3d08ef2278062ebceade0e46cefc96fe"
uuid = "739be429-bea8-5141-9913-cc70e7f3736d"
version = "1.0.3"

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

[[Memento]]
deps = ["Dates", "Distributed", "JSON", "Serialization", "Sockets", "Syslogs", "Test", "TimeZones", "UUIDs"]
git-tree-sha1 = "19650888f97362a2ae6c84f0f5f6cda84c30ac38"
uuid = "f28f55f0-a522-5efc-85c2-fe41dfb9b2d9"
version = "1.2.0"

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

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

[[Mocking]]
deps = ["Compat", "ExprTools"]
git-tree-sha1 = "29714d0a7a8083bba8427a4fbfb00a540c681ce7"
uuid = "78c3b35d-d492-501b-9361-3d52fe80e533"
version = "0.7.3"

[[MosaicViews]]
deps = ["MappedArrays", "OffsetArrays", "PaddedViews", "StackViews"]
git-tree-sha1 = "b34e3bc3ca7c94914418637cb10cc4d1d80d877d"
uuid = "e94cdb99-869f-56ef-bcf0-1ae2bcbe0389"
version = "0.3.3"

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

[[NLSolversBase]]
deps = ["DiffResults", "Distributed", "FiniteDiff", "ForwardDiff"]
git-tree-sha1 = "144bab5b1443545bc4e791536c9f1eacb4eed06a"
uuid = "d41bc354-129a-5804-8e4c-c37616107c6c"
version = "7.8.1"

[[NaNMath]]
git-tree-sha1 = "bfe47e760d60b82b66b61d2d44128b62e3a369fb"
uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
version = "0.3.5"

[[Netpbm]]
deps = ["FileIO", "ImageCore"]
git-tree-sha1 = "18efc06f6ec36a8b801b23f076e3c6ac7c3bf153"
uuid = "f09324ee-3d7c-5217-9330-fc30815ba969"
version = "1.0.2"

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

[[Observables]]
git-tree-sha1 = "fe29afdef3d0c4a8286128d4e45cc50621b1e43d"
uuid = "510215fc-4207-5dde-b226-833fc4488ee2"
version = "0.4.0"

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

[[Ogg_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "7937eda4681660b4d6aeeecc2f7e1c81c8ee4e2f"
uuid = "e7412a2a-1a6e-54c0-be00-318e2571c051"
version = "1.3.5+0"

[[OpenEXR]]
deps = ["Colors", "FileIO", "OpenEXR_jll"]
git-tree-sha1 = "327f53360fdb54df7ecd01e96ef1983536d1e633"
uuid = "52e1d378-f018-4a11-a4be-720524705ac7"
version = "0.3.2"

[[OpenEXR_jll]]
deps = ["Artifacts", "Imath_jll", "JLLWrappers", "Libdl", "Pkg", "Zlib_jll"]
git-tree-sha1 = "923319661e9a22712f24596ce81c54fc0366f304"
uuid = "18a262bb-aa17-5467-a713-aee519bc75cb"
version = "3.1.1+0"

[[OpenLibm_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "05823500-19ac-5b8b-9628-191a04bc5112"

[[OpenML]]
deps = ["ARFFFiles", "HTTP", "JSON", "Markdown", "Pkg", "ScientificTypes"]
git-tree-sha1 = "79ffa09cf7c730b36342699553feef3e1f169ec6"
uuid = "8b6db2d4-7670-4922-a472-f9537c81ab66"
version = "0.1.1"

[[OpenSSL_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "15003dcb7d8db3c6c857fda14891a539a8f2705a"
uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95"
version = "1.1.10+0"

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

[[Optim]]
deps = ["Compat", "FillArrays", "LineSearches", "LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "PositiveFactorizations", "Printf", "SparseArrays", "StatsBase"]
git-tree-sha1 = "7863df65dbb2a0fa8f85fcaf0a41167640d2ebed"
uuid = "429524aa-4258-5aef-a3af-852621145aeb"
version = "1.4.1"

[[Opus_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "51a08fb14ec28da2ec7a927c4337e4332c2a4720"
uuid = "91d4177d-7536-5919-b921-800302f37372"
version = "1.3.2+0"

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

[[PCRE_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "b2a7af664e098055a7529ad1a900ded962bca488"
uuid = "2f80f16e-611a-54ab-bc61-aa92de5b98fc"
version = "8.44.0+0"

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

[[PNGFiles]]
deps = ["Base64", "CEnum", "ImageCore", "IndirectArrays", "OffsetArrays", "libpng_jll"]
git-tree-sha1 = "85e3436b18980e47604dd0909e37e2f066f54398"
uuid = "f57f5aa1-a3ce-4bc8-8ab9-96f992907883"
version = "0.3.10"

[[Packing]]
deps = ["GeometryBasics"]
git-tree-sha1 = "1155f6f937fa2b94104162f01fa400e192e4272f"
uuid = "19eb6ba3-879d-56ad-ad62-d5c202156566"
version = "0.4.2"

[[PaddedViews]]
deps = ["OffsetArrays"]
git-tree-sha1 = "646eed6f6a5d8df6708f15ea7e02a7a2c4fe4800"
uuid = "5432bcbf-9aad-5242-b902-cca2824c8663"
version = "0.5.10"

[[Pango_jll]]
deps = ["Artifacts", "Cairo_jll", "Fontconfig_jll", "FreeType2_jll", "FriBidi_jll", "Glib_jll", "HarfBuzz_jll", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "9bc1871464b12ed19297fbc56c4fb4ba84988b0d"
uuid = "36c8627f-9965-5494-a995-c6b170f724f3"
version = "1.47.0+0"

[[Parameters]]
deps = ["OrderedCollections", "UnPack"]
git-tree-sha1 = "34c0e9ad262e5f7fc75b10a9952ca7692cfc5fbe"
uuid = "d96e819e-fc66-5662-9728-84c9c7592b0a"
version = "0.12.3"

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

[[Pixman_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "b4f5d02549a10e20780a24fce72bea96b6329e29"
uuid = "30392449-352a-5448-841d-b1acce4e97dc"
version = "0.40.1+0"

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

[[PkgVersion]]
deps = ["Pkg"]
git-tree-sha1 = "a7a7e1a88853564e551e4eba8650f8c38df79b37"
uuid = "eebad327-c553-4316-9ea0-9fa01ccd7688"
version = "0.1.1"

[[PlotUtils]]
deps = ["ColorSchemes", "Colors", "Dates", "Printf", "Random", "Reexport", "Statistics"]
git-tree-sha1 = "b084324b4af5a438cd63619fd006614b3b20b87b"
uuid = "995b91a9-d308-5afd-9ec6-746e21dbc043"
version = "1.0.15"

[[PolygonOps]]
git-tree-sha1 = "77b3d3605fc1cd0b42d95eba87dfcd2bf67d5ff6"
uuid = "647866c9-e3ac-4575-94e7-e3d426903924"
version = "0.1.2"

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

[[PositiveFactorizations]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "17275485f373e6673f7e7f97051f703ed5b15b20"
uuid = "85a6dd25-e78a-55b7-8502-1745935b8125"
version = "0.2.4"

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

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

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

[[ProgressMeter]]
deps = ["Distributed", "Printf"]
git-tree-sha1 = "afadeba63d90ff223a6a48d2009434ecee2ec9e8"
uuid = "92933f4c-e287-5a05-a399-4b506db050ca"
version = "1.7.1"

[[QuadGK]]
deps = ["DataStructures", "LinearAlgebra"]
git-tree-sha1 = "78aadffb3efd2155af139781b8a8df1ef279ea39"
uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
version = "2.4.2"

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

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

[[Ratios]]
deps = ["Requires"]
git-tree-sha1 = "01d341f502250e81f6fec0afe662aa861392a3aa"
uuid = "c84ed2f1-dad5-54f0-aa8e-dbefe2724439"
version = "0.4.2"

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

[[Reexport]]
git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b"
uuid = "189a3867-3050-52da-a836-e630ba90ab69"
version = "1.2.2"

[[RelocatableFolders]]
deps = ["SHA", "Scratch"]
git-tree-sha1 = "df2be5142a2a3db2da37b21d87c9fa7973486bfd"
uuid = "05181044-ff0b-4ac5-8273-598c1e38db00"
version = "0.1.2"

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

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

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

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

[[SIMD]]
git-tree-sha1 = "9ba33637b24341aba594a2783a502760aa0bff04"
uuid = "fdea26ae-647d-5447-a871-4b548cad5224"
version = "3.3.1"

[[ScanByte]]
deps = ["Libdl", "SIMD"]
git-tree-sha1 = "9cc2955f2a254b18be655a4ee70bc4031b2b189e"
uuid = "7b38b023-a4d7-4c5e-8d43-3f3097f304eb"
version = "0.3.0"

[[ScientificTypes]]
deps = ["CategoricalArrays", "ColorTypes", "Dates", "Distributions", "PrettyTables", "Reexport", "ScientificTypesBase", "StatisticalTraits", "Tables"]
git-tree-sha1 = "b58ef9adeba0d96ae1add87e8df5a7128342e312"
uuid = "321657f4-b219-11e9-178b-2701a2544e81"
version = "2.3.2"

[[ScientificTypesBase]]
git-tree-sha1 = "185e373beaf6b381c1e7151ce2c2a722351d6637"
uuid = "30f210dd-8aff-4c5f-94ba-8e64358c1161"
version = "2.3.0"

[[ScikitLearnBase]]
deps = ["LinearAlgebra", "Random", "Statistics"]
git-tree-sha1 = "7877e55c1523a4b336b433da39c8e8c08d2f221f"
uuid = "6e75b9c4-186b-50bd-896f-2d2496a4843e"
version = "0.5.0"

[[Scratch]]
deps = ["Dates"]
git-tree-sha1 = "0b4b7f1393cff97c33891da2a0bf69c6ed241fda"
uuid = "6c6a2e73-6563-6170-7368-637461726353"
version = "1.1.0"

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

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

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

[[SignedDistanceFields]]
deps = ["Random", "Statistics", "Test"]
git-tree-sha1 = "d263a08ec505853a5ff1c1ebde2070419e3f28e9"
uuid = "73760f76-fbc4-59ce-8f25-708e95d2df96"
version = "0.4.0"

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

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

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

[[SpecialFunctions]]
deps = ["ChainRulesCore", "IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"]
git-tree-sha1 = "793793f1df98e3d7d554b65a107e9c9a6399a6ed"
uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
version = "1.7.0"

[[StableRNGs]]
deps = ["Random", "Test"]
git-tree-sha1 = "3be7d49667040add7ee151fefaf1f8c04c8c8276"
uuid = "860ef19b-820b-49d6-a774-d7a799459cd3"
version = "1.0.0"

[[StackViews]]
deps = ["OffsetArrays"]
git-tree-sha1 = "46e589465204cd0c08b4bd97385e4fa79a0c770c"
uuid = "cae243ae-269e-4f55-b966-ac2d0dc13c15"
version = "0.1.1"

[[Static]]
deps = ["IfElse"]
git-tree-sha1 = "a8f30abc7c64a39d389680b74e749cf33f872a70"
uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
version = "0.3.3"

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

[[StatisticalTraits]]
deps = ["ScientificTypesBase"]
git-tree-sha1 = "730732cae4d3135e2f2182bd47f8d8b795ea4439"
uuid = "64bff920-2084-43da-a3e6-9bb72801c0c9"
version = "2.1.0"

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

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

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

[[StatsFuns]]
deps = ["ChainRulesCore", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"]
git-tree-sha1 = "95072ef1a22b057b1e80f73c2a89ad238ae4cfff"
uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
version = "0.9.12"

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

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

[[Syslogs]]
deps = ["Printf", "Sockets"]
git-tree-sha1 = "46badfcc7c6e74535cc7d833a91f4ac4f805f86d"
uuid = "cea106d9-e007-5e6c-ad93-58fe2094e9c4"
version = "0.3.0"

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

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

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

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

[[TensorCore]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "1feb45f88d133a655e001435632f019a9a1bcdb6"
uuid = "62fd8b95-f654-4bbd-a8a5-9c27f68ccd50"
version = "0.1.1"

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

[[TiffImages]]
deps = ["ColorTypes", "DocStringExtensions", "FileIO", "FixedPointNumbers", "IndirectArrays", "Inflate", "OffsetArrays", "OrderedCollections", "PkgVersion", "ProgressMeter"]
git-tree-sha1 = "945b8d87c5e8d5e34e6207ee15edb9d11ae44716"
uuid = "731e570b-9d59-4bfa-96dc-6df516fadf69"
version = "0.4.3"

[[TimeZones]]
deps = ["Dates", "Downloads", "InlineStrings", "LazyArtifacts", "Mocking", "Pkg", "Printf", "RecipesBase", "Serialization", "Unicode"]
git-tree-sha1 = "9408d0773ed2dbfba68ebc0e2d5dd388a5e668a9"
uuid = "f269a46b-ccf7-5d73-abea-4c690281aa53"
version = "1.6.0"

[[TranscodingStreams]]
deps = ["Random", "Test"]
git-tree-sha1 = "216b95ea110b5972db65aa90f88d8d89dcb8851c"
uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
version = "0.9.6"

[[URIs]]
git-tree-sha1 = "97bbe755a53fe859669cd907f2d96aee8d2c1355"
uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
version = "1.3.0"

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

[[UnPack]]
git-tree-sha1 = "387c1f73762231e86e0c9c5443ce3b4a0a9a0c2b"
uuid = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
version = "1.0.2"

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

[[UnicodeFun]]
deps = ["REPL"]
git-tree-sha1 = "53915e50200959667e78a92a418594b428dffddf"
uuid = "1cfade01-22cf-5700-b092-accc4b62d6e1"
version = "0.4.1"

[[WoodburyMatrices]]
deps = ["LinearAlgebra", "SparseArrays"]
git-tree-sha1 = "9398e8fefd83bde121d5127114bd3b6762c764a6"
uuid = "efce3f68-66dc-5838-9240-27a6d6f5f9b6"
version = "0.5.4"

[[XML2_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Pkg", "Zlib_jll"]
git-tree-sha1 = "1acf5bdf07aa0907e0a37d3718bb88d4b687b74a"
uuid = "02c8fc9c-b97f-50b9-bbe4-9be30ff0a78a"
version = "2.9.12+0"

[[XSLT_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Libgcrypt_jll", "Libgpg_error_jll", "Libiconv_jll", "Pkg", "XML2_jll", "Zlib_jll"]
git-tree-sha1 = "91844873c4085240b95e795f692c4cec4d805f8a"
uuid = "aed1982a-8fda-507f-9586-7b0439959a61"
version = "1.1.34+0"

[[Xorg_libX11_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Xorg_libxcb_jll", "Xorg_xtrans_jll"]
git-tree-sha1 = "5be649d550f3f4b95308bf0183b82e2582876527"
uuid = "4f6342f7-b3d2-589e-9d20-edeb45f2b2bc"
version = "1.6.9+4"

[[Xorg_libXau_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "4e490d5c960c314f33885790ed410ff3a94ce67e"
uuid = "0c0b7dd1-d40b-584c-a123-a41640f87eec"
version = "1.0.9+4"

[[Xorg_libXdmcp_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "4fe47bd2247248125c428978740e18a681372dd4"
uuid = "a3789734-cfe1-5b06-b2d0-1dd0d9d62d05"
version = "1.1.3+4"

[[Xorg_libXext_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Xorg_libX11_jll"]
git-tree-sha1 = "b7c0aa8c376b31e4852b360222848637f481f8c3"
uuid = "1082639a-0dae-5f34-9b06-72781eeb8cb3"
version = "1.3.4+4"

[[Xorg_libXrender_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Xorg_libX11_jll"]
git-tree-sha1 = "19560f30fd49f4d4efbe7002a1037f8c43d43b96"
uuid = "ea2f1a96-1ddc-540d-b46f-429655e07cfa"
version = "0.9.10+4"

[[Xorg_libpthread_stubs_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "6783737e45d3c59a4a4c4091f5f88cdcf0908cbb"
uuid = "14d82f49-176c-5ed1-bb49-ad3f5cbd8c74"
version = "0.1.0+3"

[[Xorg_libxcb_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "XSLT_jll", "Xorg_libXau_jll", "Xorg_libXdmcp_jll", "Xorg_libpthread_stubs_jll"]
git-tree-sha1 = "daf17f441228e7a3833846cd048892861cff16d6"
uuid = "c7cfdc94-dc32-55de-ac96-5a1b8d977c5b"
version = "1.13.0+3"

[[Xorg_xtrans_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "79c31e7844f6ecf779705fbc12146eb190b7d845"
uuid = "c5fb5394-a638-5e4d-96e5-b29de1b5cf10"
version = "1.4.0+3"

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

[[isoband_jll]]
deps = ["Libdl", "Pkg"]
git-tree-sha1 = "a1ac99674715995a536bbce674b068ec1b7d893d"
uuid = "9a68df92-36a6-505f-a73e-abb412b6bfb4"
version = "0.2.2+0"

[[libass_jll]]
deps = ["Artifacts", "Bzip2_jll", "FreeType2_jll", "FriBidi_jll", "HarfBuzz_jll", "JLLWrappers", "Libdl", "Pkg", "Zlib_jll"]
git-tree-sha1 = "5982a94fcba20f02f42ace44b9894ee2b140fe47"
uuid = "0ac62f75-1d6f-5e53-bd7c-93b484bb37c0"
version = "0.15.1+0"

[[libfdk_aac_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "daacc84a041563f965be61859a36e17c4e4fcd55"
uuid = "f638f0a6-7fb0-5443-88ba-1cc74229b280"
version = "2.0.2+0"

[[libpng_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Zlib_jll"]
git-tree-sha1 = "94d180a6d2b5e55e447e2d27a29ed04fe79eb30c"
uuid = "b53b4c65-9356-5827-b1ea-8c7a1a84506f"
version = "1.6.38+0"

[[libvorbis_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Ogg_jll", "Pkg"]
git-tree-sha1 = "c45f4e40e7aafe9d086379e5578947ec8b95a8fb"
uuid = "f27f6e37-5d2b-51aa-960f-b287f2bc3b7a"
version = "1.3.7+0"

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

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

[[x264_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "4fea590b89e6ec504593146bf8b988b2c00922b2"
uuid = "1270edf5-f2f9-52d2-97e9-ab00b5d0237a"
version = "2021.5.5+0"

[[x265_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "ee567a171cce03570d77ad3a43e90218e38937a9"
uuid = "dfaa095f-4041-5dcd-9319-2fabd8486b76"
version = "3.5.0+0"
"""

# ╔═╡ Cell order:
# ╠═ea44c5c8-02d6-4bcb-90e7-01fb3db9e44e
# ╠═5e902e3c-2c19-11ec-39df-3fba9fe5640c
# ╠═b37e1bc1-2f53-4637-852b-5c8e38912a0e
# ╠═b0b55bb3-d445-4f45-bd33-c26f28d074e1
# ╠═e4584145-243d-4ba9-853c-82189a9b96df
# ╠═a998b36b-7183-4657-ae14-ab81212138ab
# ╠═fc89a45d-fe73-45aa-a8ef-bf090884dd00
# ╠═3f39b4eb-7aab-4dda-adbf-3be971d4cb99
# ╠═b641a8d6-624b-4562-92e2-276388f573de
# ╠═d7751696-1bb5-4ee8-a8e7-45da5dd71947
# ╠═3f99e49e-9e51-4f8f-9c21-9f670d63f3c4
# ╠═1e0ac73d-1faf-4250-a6f5-032c67649326
# ╠═772ec163-7861-4bbe-a90b-d6b6f7c08040
# ╠═d07d4596-bc21-4ba7-9f78-9ce00d1d9339
# ╠═86a2c569-d139-467e-948c-18f60d0cd93a
# ╠═a09b498e-931e-4fd3-b3e3-eefc16d2e65f
# ╠═662d7494-6248-4adc-ac0d-0f4c68e4418d
# ╠═c0a0bd8b-fe78-4ea1-8619-62a26a968a10
# ╠═696808d5-3547-4666-bfcc-46e658ebbced
# ╠═916a78d9-a6f7-4e60-8511-9d654f74f3de
# ╠═bfebf58b-daf5-4d74-ba9b-fc853da3b166
# ╠═da994d08-9d14-45b9-a80a-7ea6a13edd67
# ╠═641ac771-1424-45ba-a313-d6e1e8b7eaf4
# ╠═d0e5d310-d09d-4e00-b942-07e48d8ab00e
# ╠═feaca510-5403-474f-b598-8467569161ce
# ╠═0024dfce-b6ff-4a38-8afc-1092591422cb
# ╠═dccd8ec8-cc40-43a1-bad7-e1ad699a4a40
# ╠═5f92f025-fd2a-4ed4-84b6-ebadb0c689fe
# ╠═72012d1a-fd91-4b40-9137-18dc01205c00
# ╠═e1de9f5d-c062-4068-8652-e0bac41bee9b
# ╠═95f8e3cf-c6b9-4d84-bc35-b933008bf112
# ╠═88544422-e781-43a4-8eae-35713aa59193
# ╠═43f00e6a-ad6d-47e9-8074-266fffa3cb82
# ╠═37c2861b-fed1-4c78-a8e5-0827ab98e477
# ╠═95877eb0-f7b7-4123-8718-b9d30f3e2c3f
# ╠═626e0034-caef-4435-9716-c4449375159e
# ╠═40f48800-1aca-4587-a26e-fea92b0ce8ba
# ╠═135f5d2b-4645-493b-97ae-e4d9e76ab8be
# ╠═0630eb20-01a3-41f8-a7ad-202a56b43954
# ╠═ad007c31-d39b-4f10-9e95-755f40cb6844
# ╠═734712fa-0871-4793-9ef4-74f856f2613f
# ╟─00000000-0000-0000-0000-000000000001
# ╟─00000000-0000-0000-0000-000000000002

max_stars_repo_name: rikhuijzer/franklin-blog

max_issues_repo_name: rikhuijzer/franklin-blog

max_forks_repo_name: rikhuijzer/franklin-blog


text:
const CMat = Ptr{Cvoid}
const CMatNullSpace = Ptr{Cvoid}

abstract type AbstractMat{T} <: AbstractMatrix{T} end
scalartype(::AbstractMat{T}) where {T} = T

Base.eltype(::Type{A}) where {A<:AbstractMat{T}} where {T} = T
Base.eltype(A::AbstractMat{T}) where {T} = T

"""
    MatSeqAIJ{T}

PETSc sparse array using AIJ format (also known as a compressed sparse row or CSR format).

Memory allocation is handled by PETSc.
"""
mutable struct MatSeqAIJ{T} <: AbstractMat{T}
    ptr::CMat
end

"""
    Mat{T}

Container for an abstract PETSc matrix

See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/Mat.html)
"""
mutable struct Mat{T} <: AbstractMat{T}
    ptr::CMat
end

"""
    MatSeqDense{T}

PETSc dense array. This wraps a Julia `Matrix{T}` object.
"""
mutable struct MatSeqDense{T} <: AbstractMat{T}
    ptr::CMat
    array::Matrix{T}
end

"""
    MatStencil{PetscInt}

Equivalent to the `MatStencil` in PETSc

See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatStencil.html)
"""
struct MatStencil{PetscInt}
    "third grid index"
    k::PetscInt
    "second grid index"
    j::PetscInt
    "first grid index"
    i::PetscInt
    "degree of freedom"
    c::PetscInt
    function MatStencil{PetscInt}(;i, j = 1, k = 1, c = 1) where PetscInt
      # convert to zero-based indexing
      new{PetscInt}(k - 1, j - 1, i - 1, c - 1)
    end
end
# Since julia uses 1-based indexing we need to convert on access
function Base.getproperty(obj::MatStencil{PetscInt}, sym::Symbol) where PetscInt
  if sym in (:i, :j, :k, :c)
    return getfield(obj, sym) + PetscInt(1)
  else # fallback to getfield
      return getfield(obj, sym)
  end
end
# Since julia uses 1-based indexing we need to convert on show
function Base.show(io::IO, m::MatStencil{PetscInt}) where {PetscInt}
  print(io, typeof(m))
  print(io, "(i = ", m.i,)
  print(io, ", j = ", m.j,)
  print(io, ", k = ", m.k,)
  print(io, ", c = ", m.c, ")")
end
function Base.show(io::IO, ::MIME"text/plain", m::MatStencil{PetscInt}) where PetscInt
  print(io, "(i = ", m.i,)
  print(io, ", j = ", m.j,)
  print(io, ", k = ", m.k,)
  print(io, ", c = ", m.c, ")")
end

"""
    MatNullSpace{T}

Object that removes a null space from a vector, i.e. orthogonalizes the vector
to a subspace;
see [MatNullSpace](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatNullSpace.html)
and [MatNullSpaceCreate](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatNullSpaceCreate.html)

!!! Note
    The caller is responsible for calling `destroy` on this object
"""
mutable struct MatNullSpace{T}
    ptr::CMatNullSpace
    __comm__::MPI.Comm
end
# allows us to pass XXMat objects directly into CMat ccall signatures
Base.cconvert(::Type{CMatNullSpace}, obj::MatNullSpace) = obj.ptr
# allows us to pass XXMat objects directly into Ptr{CMat} ccall signatures
Base.unsafe_convert(::Type{Ptr{CMatNullSpace}}, obj::MatNullSpace) =
    convert(Ptr{CMatNullSpace}, pointer_from_objref(obj))

"""
    MatNullSpaceRemove!(nullspace, vec)

Removes all the components of a `nullspace` from `vec`

see [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatNullSpaceRemove.html)
"""
function MatNullSpaceRemove! end

"""
    MatSetNullSpace!(mat, nullspace)

Attach `nullspace` to `mat`

see [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetNullSpace.html)
"""
function MatSetNullSpace! end

"""
    MatSetValuesStencil!(mat::AbstractMat{PetscScalar},
        rows::Vector{MatStencil{PetscInt}},
        cols::Vector{MatStencil{PetscInt}},
        vals::Vector{PetscScalar},
        mode;
        num_cols = length(col),
        num_rows = length(row)
      )

Insert the `vals` specified by `rows` and `cols` stencil indices into the `mat`.
The optional arguments `num_cosl` and `num_rows` allow the limiting of the
elements of the `rows` and `cols` vectors.

see [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetValuesStencil.html)
"""
function MatSetValuesStencil! end

@for_libpetsc begin
    function MatNullSpace{$PetscScalar}(comm::MPI.Comm, has_constant, n=0, vecs=nothing)
        @assert initialized($petsclib)
        @assert n == 0 && isnothing(vecs)
        nullspace = MatNullSpace{$PetscScalar}(C_NULL, comm)
        @chk ccall((:MatNullSpaceCreate, $libpetsc), PetscErrorCode,
                (MPI.MPI_Comm,
                 PetscBool,
                 $PetscInt,
                 Ptr{CVec},
                 Ptr{CMatNullSpace}
                ),
                comm, has_constant, n, C_NULL, nullspace)
        return nullspace
    end

    function MatNullSpaceRemove!(
        nullspace::MatNullSpace{$PetscScalar},
        vec::AbstractVec{$PetscScalar},
    )
        @chk ccall(
            (:MatNullSpaceRemove, $libpetsc),
            PetscErrorCode,
            (CMatNullSpace, CVec),
            nullspace,
            vec,
        )
        return nothing
    end

    function MatSetNullSpace!(
        mat::Mat{$PetscScalar},
        nullspace::MatNullSpace{$PetscScalar},
    )
        @chk ccall(
            (:MatSetNullSpace, $libpetsc),
            PetscErrorCode,
            (CMat, CMatNullSpace),
            mat,
            nullspace,
        )
        return nothing
    end

    function destroy(nullspace::MatNullSpace{$PetscScalar})
        finalized($petsclib) ||
        @chk ccall((:MatNullSpaceDestroy, $libpetsc), PetscErrorCode, (Ptr{CMatNullSpace},), nullspace)
        return nothing
    end

    function MatSeqAIJ{$PetscScalar}(m::Integer, n::Integer, nnz::Vector{$PetscInt})
        @assert initialized($petsclib)
        comm = MPI.COMM_SELF
        mat = MatSeqAIJ{$PetscScalar}(C_NULL)
        @chk ccall((:MatCreateSeqAIJ, $libpetsc), PetscErrorCode,
                (MPI.MPI_Comm, $PetscInt, $PetscInt, $PetscInt, Ptr{$PetscInt}, Ptr{CMat}),
                comm, m, n, 0, nnz, mat)
        finalizer(destroy, mat)
        return mat
    end
    function MatSeqDense(A::Matrix{$PetscScalar})
        @assert initialized($petsclib)
        comm = MPI.COMM_SELF
        mat = MatSeqDense(C_NULL, A)
        @chk ccall((:MatCreateSeqDense, $libpetsc), PetscErrorCode,
            (MPI.MPI_Comm, $PetscInt, $PetscInt, Ptr{$PetscScalar}, Ptr{CMat}),
            comm, size(A,1), size(A,2), A, mat)
        finalizer(destroy, mat)
        return mat
    end

    function MatSetValuesStencil!(mat::AbstractMat{$PetscScalar},
        rows::Vector{MatStencil{$PetscInt}},
        cols::Vector{MatStencil{$PetscInt}},
        vals::Vector{$PetscScalar},
        mode::InsertMode;
        num_rows = length(rows),
        num_cols = length(cols),
      )
        @assert length(vals) >= num_cols * num_rows
        @assert length(cols) >= num_cols
        @assert length(rows) >= num_rows
        @chk ccall((:MatSetValuesStencil, $libpetsc), PetscErrorCode,
                   (CMat,
                    $PetscInt, Ptr{MatStencil{$PetscInt}},
                    $PetscInt, Ptr{MatStencil{$PetscInt}},
                    Ptr{$PetscScalar}, InsertMode),
                   mat,
                   num_rows, rows,
                   num_cols, cols,
                   vals, mode
                  )
        return nothing
    end

    function destroy(M::AbstractMat{$PetscScalar})
        finalized($petsclib) ||
        @chk ccall((:MatDestroy, $libpetsc), PetscErrorCode, (Ptr{CMat},), M)
        return nothing
    end

    function setvalues!(M::AbstractMat{$PetscScalar}, row0idxs::Vector{$PetscInt}, col0idxs::Vector{$PetscInt}, rowvals::Array{$PetscScalar}, insertmode::InsertMode)
        @chk ccall((:MatSetValues, $libpetsc), PetscErrorCode,
            (CMat, $PetscInt, Ptr{$PetscInt}, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscScalar},InsertMode),
            M, length(row0idxs), row0idxs, length(col0idxs), col0idxs, rowvals, insertmode)
        return nothing
    end

    function Base.setindex!(M::AbstractMat{$PetscScalar}, val, i::Integer, j::Integer)
        @chk ccall((:MatSetValues, $libpetsc), PetscErrorCode,
            (CMat, $PetscInt, Ptr{$PetscInt}, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscScalar}, InsertMode),
            M, 1, Ref{$PetscInt}(i-1), 1, Ref{$PetscInt}(j-1), Ref{$PetscScalar}(val), INSERT_VALUES)
        return val
    end

    function Base.getindex(M::AbstractMat{$PetscScalar}, i::Integer, j::Integer)
        val = Ref{$PetscScalar}()
        @chk ccall((:MatGetValues, $libpetsc), PetscErrorCode,
            (CMat,
             $PetscInt, Ptr{$PetscInt},
             $PetscInt, Ptr{$PetscInt},
             Ptr{$PetscScalar}),
            M,
            1, Ref{$PetscInt}(i-1),
            1, Ref{$PetscInt}(j-1),
            val)
        return val[]
    end

    function assemblybegin(M::AbstractMat{$PetscScalar}, t::MatAssemblyType=MAT_FINAL_ASSEMBLY)
        @chk ccall((:MatAssemblyBegin, $libpetsc), PetscErrorCode, (CMat, MatAssemblyType), M, t)
        return nothing
    end
    function assemblyend(M::AbstractMat{$PetscScalar}, t::MatAssemblyType=MAT_FINAL_ASSEMBLY)
        @chk ccall((:MatAssemblyEnd, $libpetsc), PetscErrorCode, (CMat, MatAssemblyType), M, t)
        return nothing
    end
    function view(mat::AbstractMat{$PetscScalar}, viewer::AbstractViewer{$PetscLib}=ViewerStdout($petsclib, getcomm(mat)))
        @chk ccall((:MatView, $libpetsc), PetscErrorCode,
                    (CMat, CPetscViewer),
                mat, viewer);
        return nothing
    end

    function Base.size(A::AbstractMat{$PetscScalar})
        m = Ref{$PetscInt}()
        n = Ref{$PetscInt}()
        @chk ccall((:MatGetSize, $libpetsc), PetscErrorCode,
            (CMat, Ptr{$PetscInt}, Ptr{$PetscInt}),
            A, m, n)
        return (m[], n[])
    end
    function Base.:(==)(A::AbstractMat{$PetscScalar}, B::AbstractMat{$PetscScalar})
        fr = Ref{PetscBool}()
        @chk ccall((:MatEqual, $libpetsc), PetscErrorCode,
             (CMat, CMat, Ptr{PetscBool}),
             A, B, fr)
        return fr[] == PETSC_TRUE
    end

    function LinearAlgebra.issymmetric(A::AbstractMat{$PetscScalar}; tol=zero($PetscReal))
        fr = Ref{PetscBool}()
        @chk ccall((:MatIsSymmetric, $libpetsc), PetscErrorCode,
            (CMat, $PetscReal, Ptr{PetscBool}),
            A, tol, fr)
        return fr[] == PETSC_TRUE
    end
    function LinearAlgebra.ishermitian(A::AbstractMat{$PetscScalar}; tol=zero($PetscReal))
        fr = Ref{PetscBool}()
        @chk ccall((:MatIsHermitian, $libpetsc), PetscErrorCode,
            (CMat, $PetscReal, Ptr{PetscBool}),
            A, tol, fr)
        return fr[] == PETSC_TRUE
    end
    function LinearAlgebra.norm(M::AbstractMat{$PetscScalar}, normtype::NormType=NORM_FROBENIUS)
        r_val = Ref{$PetscReal}()
        @chk ccall((:MatNorm, $libpetsc), PetscErrorCode,
            (CMat, NormType, Ptr{$PetscReal}),
            M, normtype, r_val)
        return r_val[]
    end

    function LinearAlgebra.mul!(y::AbstractVec{$PetscScalar}, M::AbstractMat{$PetscScalar}, x::AbstractVec{$PetscScalar})
        @chk ccall((:MatMult, $libpetsc), PetscErrorCode, (CMat, CVec, CVec), M, x, y)
        return y
    end
    function LinearAlgebra.mul!(y::AbstractVec{$PetscScalar}, M::Adjoint{T,A}, x::AbstractVec{$PetscScalar}) where {T,A<:AbstractMat{$PetscScalar}}
        @chk ccall((:MatMultHermitianTranspose, $libpetsc), PetscErrorCode, (CMat, CVec, CVec), parent(M), x, y)
        return y
    end
    function LinearAlgebra.mul!(y::AbstractVec{$PetscScalar}, M::Transpose{T,A}, x::AbstractVec{$PetscScalar}) where {T,A<:AbstractMat{$PetscScalar}}
        @chk ccall((:MatMultTranspose, $libpetsc), PetscErrorCode, (CMat, CVec, CVec), parent(M), x, y)
        return y
    end

end

function assemble(M::AbstractMat, t::MatAssemblyType=MAT_FINAL_ASSEMBLY)
    assemblybegin(M, t)
    assemblyend(M, t)
end

function MatSeqAIJ(S::SparseMatrixCSC{T}) where {T}
    PetscInt = inttype(T)
    m,n = size(S)
    nnz = zeros(PetscInt,m)
    for r in S.rowval
        nnz[r] += 1
    end
    M = MatSeqAIJ{T}(m, n, nnz)
    for j = 1:n
        for ii = S.colptr[j]:S.colptr[j+1]-1
            i = S.rowval[ii]
            M[i,j] = S.nzval[ii]
        end
    end
    assemble(M)
    return M
end

function Base.copyto!(M::PETSc.MatSeqAIJ{T}, S::SparseMatrixCSC{T}) where {T}
    for j = 1:size(S,2)
        for ii = S.colptr[j]:S.colptr[j+1]-1
            i = S.rowval[ii]
            M[i,j] = S.nzval[ii]
        end
    end
    assemble(M);
end

function Base.show(io::IO, ::MIME"text/plain", mat::AbstractMat)
    _show(io, mat)
end
AbstractMat(A::Matrix) = MatSeqDense(A)
AbstractMat(A::SparseMatrixCSC) = MatSeqAIJ(A)

const MatAT{T} = Union{AbstractMat{T}, Transpose{T, <:AbstractMat{T}}, Adjoint{T, <:AbstractMat{T}}}

LinearAlgebra.mul!(y::AbstractVector{T}, M::MatAT{T}, x::AbstractVector{T}) where {T} =
    parent(LinearAlgebra.mul!(AbstractVec(y), M, AbstractVec(x)))

ext: jl


text:
"""
    train(hydromodel::HydroPowerModel;kwargs...)

Train future cost function using SDDP.

Keyword arguments (same as SDDP.train):
<https://github.com/odow/SDDP.jl/blob/0490bea2c46787e1d4d63a5491ea0106c7fe70cf/src/algorithm.jl#L780-L827>

"""
function train(hydromodel::HydroPowerModel;kwargs...)
    SDDP.train(hydromodel.policygraph; kwargs...)
end


text:
using CUDA
using CUDA: curand_rng
using CUDA.CUSPARSE: CuSparseMatrix, CuSparseMatrixCSR, CuSparseMatrixCOO
using CUDA.CUSOLVER: CuQR

export cuda_gc, gpu

const CuBaseField{B,M,T,A<:CuArray} = BaseField{B,M,T,A}

# printing
typealias(::Type{CuArray{T,N}}) where {T,N} = "CuArray{$T,$N}"
Base.print_array(io::IO, X::Diagonal{<:Any,<:CuBaseField}) = Base.print_array(io, cpu(X))

# a function version of @cuda which can be referenced before CUDA is
# loaded as long as it exists by run-time (unlike the macro @cuda which must
# exist at compile-time)
function cuda(f, args...; threads=256)
    @cuda threads=threads f(args...)
end

is_gpu_backed(::BaseField{B,M,T,A}) where {B,M,T,A<:CuArray} = true
global_rng_for(::Type{<:CuArray}) = curand_rng()

# handy conversion functions and macros
@doc doc"""

    gpu(x)

Recursively moves x to GPU, but unlike `CUDA.cu`, doesn't also convert
to Float32. Equivalent to `adapt_structure(CuArray, x)`. Returns nothing.
"""
gpu(x) = adapt_structure(CuArray, x)

adapt_structure(::CUDA.Float32Adaptor, proj::ProjLambert) = adapt_structure(CuArray{Float32}, proj)

function Cℓ_to_2D(Cℓ, proj::ProjLambert{T,<:CuArray}) where {T}
    # todo: remove needing to go through cpu here:
    gpu(Complex{T}.(nan2zero.(Cℓ.(cpu(proj.ℓmag)))))
end

### misc
# the generic versions of these trigger scalar indexing of CUDA, so provide
# specialized versions:
pinv(D::Diagonal{T,<:CuBaseField}) where {T} = Diagonal(@. ifelse(isfinite(inv(D.diag)), inv(D.diag), $zero(T)))
inv(D::Diagonal{T,<:CuBaseField}) where {T} = any(Array((D.diag.==0)[:])) ? throw(SingularException(-1)) : Diagonal(inv.(D.diag))
fill!(f::CuBaseField, x) = (fill!(f.arr,x); f)
==(a::CuBaseField, b::CuBaseField) = (==)(promote(a.arr, b.arr)...)
sum(f::CuBaseField; dims=:) = (dims == :) ? sum(f.arr) : (1 in dims) ? error("Sum over invalid dims of CuFlatS0.") : f

# adapting of SparseMatrixCSC ↔ CuSparseMatrixCSR (otherwise dense arrays created)
adapt_structure(::Type{<:CuArray}, L::SparseMatrixCSC)   = CuSparseMatrixCSR(L)
adapt_structure(::Type{<:Array},   L::CuSparseMatrixCSR) = SparseMatrixCSC(L)
adapt_structure(::Type{<:CuArray}, L::CuSparseMatrixCSR) = L
adapt_structure(::Type{<:Array},   L::SparseMatrixCSC)   = L

# CUDA somehow missing this one
# see https://github.com/JuliaGPU/CuArrays.jl/issues/103
# and https://github.com/JuliaGPU/CuArrays.jl/pull/580
ldiv!(qr::CuQR, x::CuVector) = qr.R \ (CuMatrix(qr.Q)' * x)

# some Random API which CUDA doesn't implement yet
Random.randn(rng::CUDA.CURAND.RNG, T::Random.BitFloatType) =
    cpu(randn!(rng, CuVector{T}(undef,1)))[1]

# perhaps minor type-piracy, but this lets us simulate into a CuArray using the
# CPU random number generator
Random.randn!(rng::MersenneTwister, A::CuArray) =
    (A .= adapt(CuArray, randn!(rng, adapt(Array, A))))

"""
    cuda_gc()

Gargbage collect and reclaim GPU memory (technically should never be
needed to do this by hand, but sometimes helps with GPU OOM errors)
"""
function cuda_gc()
    isdefined(Main,:Out) && empty!(Main.Out)
    GC.gc(true)
    CUDA.reclaim()
end


text:
# Base type from which all systems of equations types inherit from
abstract type AbstractEquation{NDIMS, NVARS} end

# Retrieve number of variables from equation type
@inline nvariables(::Type{AbstractEquation{NDIMS, NVARS}}) where {NDIMS, NVARS} = NVARS

# Retrieve number of variables from equation instance
@inline nvariables(::AbstractEquation{NDIMS, NVARS}) where {NDIMS, NVARS} = NVARS

# Add method to show some information on system of equations
function Base.show(io::IO, equation::AbstractEquation)
  print(io, "name = ", get_name(equation), ", n_vars = ", nvariables(equation))
end

@inline Base.ndims(::AbstractEquation{NDIMS}) where NDIMS = NDIMS

# Create an instance of a system of equation type based on a given name
function make_equations(name::String, ndims_)
  if name == "LinearScalarAdvectionEquation"
    if ndims_ == 1
      return LinearScalarAdvectionEquation1D()
    elseif ndims_ == 2
      return LinearScalarAdvectionEquation2D()
    elseif ndims_ == 3
      return LinearScalarAdvectionEquation3D()
    else
      error("Unsupported number of spatial dimensions: ", ndims_)
    end
  elseif name == "CompressibleEulerEquations"
    if ndims_ == 1
      return CompressibleEulerEquations1D()
    elseif ndims_ == 2
      return CompressibleEulerEquations2D()
    elseif ndims_ == 3
      return CompressibleEulerEquations3D()
    else
      error("Unsupported number of spatial dimensions: ", ndims_)
    end
  elseif name == "IdealGlmMhdEquations"
    if ndims_ == 2
      return IdealGlmMhdEquations2D()
    elseif ndims_ == 3
      return IdealGlmMhdEquations3D()
    else
      error("Unsupported number of spatial dimensions: ", ndims_)
    end
  elseif name == "HyperbolicDiffusionEquations"
    if ndims_ == 2
      return HyperbolicDiffusionEquations2D()
    elseif ndims_ == 3
      return HyperbolicDiffusionEquations3D()
    else
      error("Unsupported number of spatial dimensions: ", ndims_)
    end
  else
    error("'$name' does not name a valid system of equations")
  end
end

have_nonconservative_terms(::AbstractEquation) = Val(false)
default_analysis_quantities(::AbstractEquation) = (:l2_error, :linf_error, :dsdu_ut)

"""
    flux_central(u_ll, u_rr, orientation, equation::AbstractEquation)

The classical central numerical flux `f((u_ll) + f(u_rr)) / 2`. When this flux is
used as volume flux, the discretization is equivalent to the classical weak form
DG method (except floating point errors).
"""
@inline function flux_central(u_ll, u_rr, orientation, equation::AbstractEquation)
  # Calculate regular 1D fluxes
  f_ll = calcflux(u_ll, orientation, equation)
  f_rr = calcflux(u_rr, orientation, equation)

  # Average regular fluxes
  return 0.5 * (f_ll + f_rr)
end

@inline cons2cons(u, equation::AbstractEquation) = u

####################################################################################################
# Include files with actual implementations for different systems of equations.

# Linear scalar advection
abstract type AbstractLinearScalarAdvectionEquation{NDIMS, NVARS} <: AbstractEquation{NDIMS, NVARS} end
include("1d/linear_scalar_advection.jl")
include("2d/linear_scalar_advection.jl")
include("3d/linear_scalar_advection.jl")

# CompressibleEulerEquations
abstract type AbstractCompressibleEulerEquations{NDIMS, NVARS} <: AbstractEquation{NDIMS, NVARS} end
include("1d/compressible_euler.jl")
include("2d/compressible_euler.jl")
include("3d/compressible_euler.jl")

# Ideal MHD
abstract type AbstractIdealGlmMhdEquations{NDIMS, NVARS} <: AbstractEquation{NDIMS, NVARS} end
include("2d/ideal_glm_mhd.jl")
include("3d/ideal_glm_mhd.jl")

# Diffusion equation: first order hyperbolic system
abstract type AbstractHyperbolicDiffusionEquations{NDIMS, NVARS} <: AbstractEquation{NDIMS, NVARS} end
include("2d/hyperbolic_diffusion.jl")
include("3d/hyperbolic_diffusion.jl")


text:
# 普通に配列を宣言
fruits = ["apple","orange","banana"]
println(fruits)
# 別のものが混ざっても大丈夫
fruits_num = ["apple","orange",1]
println(fruits_num)

# 1-indexに注意
println(fruits[2])

# 配列に対してpush, popもできる
push!(fruits,"peach")
println(fruits)
pop!(fruits)
println(fruits)

# 参照して更新
fruits[1] = "apple2"
println(fruits)

# 多次元配列
fruits_2d = [["apple","orange","banana"],["apple2","orange2","banana2","peach2"]]
println(fruits_2d)

# 乱数生成
rand_4x3 = rand(4,3)
println(rand_4x3)

# 配列の初期化
println(zeros(4))

println(zeros(3,4))

# 型の指定
println(zeros(Int8,3,4))

zeros_array = zeros(Int8, 2,4)

println(ones(5))
print(ones(2,3))

# {0,1},{true,false}以外で埋めたいときはfillを使う
println(fill(10,(3,2)))

tmp = ones(2,4)
# 配列の次元数を取得
println(ndims(tmp))
# 配列のindexを取得
# indicesが使えない?
# println(indices(tmp))
println(size(tmp))
#　全てのよう素数を返す
println(length(tmp))

# 要素へのindexをiterableな形で取得する
#

for iter in eachindex(tmp)
    println(iter, "=>", tmp[iter])
end

# non-zeroな要素数を返してくれる関数
# これもない?
# println(coutnz(tmp))

# 配列のreshape
ones_id = ones(15)
ones_id = reshape(ones_id,(3,5))
println(ndims(ones_id))
println(size(ones_id))

# 片方の次元だけ
ones_id = reshape(ones_id,1,:)
println(size(ones_id))
println(size(vec(ones_id)))

# vertical方向に結合
a = [1 2 3 4 5]
b = [6 7 8 9 10; 11 12 13 14 15]
c = vcat(a,b)
println(c)

# horizontalな方向に結合
a = [1;2;3;4;5]
b = [6;7;8;9;10]
c = hcat(a,b)
println(c)

# 配列の演算
# 要素ごとにやりたかったら.をつける
a = [1, 2, 3, 4, 5]
println(a .+ 1)
println(a .- 1)
println(a .* 2)
println(a ./ 2)

# @. を先につけるでもいい
println(@. a + 1)
println(@. a - 1)
println(@. a * 2)
println(@. a / 2)

# 累積演算をする
println(accumulate(+, [1,2,3]))

println(accumulate(+, [1,2,3], init=100))

println(accumulate(min, [1,0,2,-1,3,45]))


text:
using JuMP
using Clp
m = Model(Clp.Optimizer)
@variable(m, x11 ≥ 0)
@variable(m, x12 ≥ 0)
@variable(m, x21  ≥ 0)
@variable(m, x22 ≥ 0)
@variable(m, x31 ≥ 0)
@variable(m, x32 ≥ 0)
@objective(m, Min, 80x11 + 100x21 + 102x31 + 251x12 + 108x22 + 68x32)
@constraint(m, x11 + x12 ≤ 1000)
@constraint(m, x21 + x22 ≤ 1500)
@constraint(m, x31 + x32 ≤ 1200)
@constraint(m, x11 + x21 + x31 == 2300)
@constraint(m, x12 + x22 + x32 == 1400)
print(m)
optimize!(m)
status = termination_status(m)
println("Solution status: ", status)
println("Objective value: ", objective_value(m))
println("x11: ", value(x11))
println("x12: ", value(x12))
println("x21 ", value(x21))
println("x22 ", value(x22))
println("x31", value(x31))
println("x32 ", value(x32))


text:
#!/usr/bin/env julia

using AcceleratedDubins
using Printf
using PyPlot

for progrun in 1:1
    mkpath("images")

    ##############################
    ### Vehicle settings
    r_min = 1.
    r_max = 5.
    params = [5, 15, 2.6, 4]

    ##############################
    ### Position settings

    alpha = 2*pi*rand()
    start = [10*rand(), -5+10*rand(), alpha]
    stop = [10+20*rand(), -5+10*rand(), 0]

    betaarr = 1:0.05:2*pi

    id = 0
    for beta in betaarr
        @printf("%d / %d\n", id, length(betaarr))
        stop[3] = beta

        fig, ax = plt.subplots(1, 2, num="Fastest vs. shortest")
        fig.set_size_inches(6.4*2, 4.8)
        ax[1].axis("equal")
        ax[1].set_xlabel("x")
        ax[1].set_ylabel("y")
        ax[2].set_ylim(-7, 7)

        ax[2].axis("equal")
        ax[2].set_ylabel("Speed [m/s]")
        ax[2].set_xlabel("Time [s]")
        ax[2].set_ylim(params[1], params[2])
        ax[2].set_xlim(-0.5, 5)

        # simple path computation
        # compute fastest path
        # tries all radii combinations
        path_fastest, _ = fastest_path(start, stop, radii_samples_exp(r_min, r_max, 5), params)
        # tries optimized path
        path_optimized, _ = optimized_path(start, stop, [r_min, r_max], params)
        # compute shortest path
        path_shortest, _ = retrieve_path(start, stop, [r_min, r_min], params)
        # sample the path for plotting
        confx, confy = sample_path(path_fastest)
        ax[1].plot(confx, confy, color="green", label="fastest")
        confx, confy = sample_path(path_optimized)
        ax[1].plot(confx, confy, color="blue", label="optimized")
        confx, confy = sample_path(path_shortest)
        ax[1].plot(confx, confy, color="orange", label="shortest")

        times, speeds = speed_profile(path_fastest, params)
        ax[2].plot(times, speeds, color="green", label="fastest")
        times, speeds = speed_profile(path_optimized, params)
        ax[2].plot(times, speeds, color="blue", label="optimized")
        times, speeds = speed_profile(path_shortest, params)
        ax[2].plot(times, speeds, color="orange", label="shortest")

        ax[2].legend(bbox_to_anchor=(1.3, 0.999))

        time_fastest = path_time(path_fastest, params)
        time_fastest_no_opt = (sum(path_fastest.lengths) / speed_by_radius(r_min, params[1], params[2]))

        time_optimized = path_time(path_optimized, params)
        time_optimized_no_opt = (sum(path_optimized.lengths) / speed_by_radius(r_min, params[1], params[2]))

        time_shortest = path_time(path_shortest, params)
        time_shortest_no_opt = (sum(path_shortest.lengths) / speed_by_radius(r_min, params[1], params[2]))

        fig.savefig(@sprintf("images/img%03d.jpg", id), bbox_inches=nothing, pad_inches=-0.1)
        id += 1
        # println("[GREEN] Fastest path:    vp = ", round(time_fastest, digits=3), "    no_opt = ", round(time_fastest_no_opt, digits=3))
        # println("[BLUE] Optimized path:   vp = ", round(time_optimized, digits=3), "    no_opt = ", round(time_optimized_no_opt, digits=3))
        # println("[ORANGE] Shortest path:  vp = ", round(time_shortest, digits=3), "    no_opt = ", round(time_shortest_no_opt, digits=3))
        fig.clear()
    end

    gifconvert = `convert -delay 12 -loop 0 "images/*.jpg" "images/myimage.gif"`
    @show gifconvert
    run(gifconvert);
    @printf("Converted.")

end


text:
function compute_π(rng, trials)
    points = rand(rng, 2, trials)
    inside = sum(sum(points.^2,1) .<= 1.0)
    4inside/trials
end

if isempty(ARGS)
    error("must provide number of trials")
end

trials = parse(Int, ARGS[1])

rng = MersenneTwister(2018)

@time compute_π(rng, trials)
@time π = compute_π(rng, trials)

println("π ≈ $π")

max_stars_repo_name: ELIFE-ASU/meet-julia

max_issues_repo_name: ELIFE-ASU/meet-julia

max_forks_repo_name: ELIFE-ASU/meet-julia


text:
# This file is a part of LegendTestData.jl, licensed under the MIT License (MIT).

# This file contains code from Pkg.operations, also licensed under the MIT License (MIT).

__precompile__(true)

module LegendTestData

using DataDeps

const testdata_url = "https://github.com/legend-exp/legend-testdata.git"
const testdata_version = "4de6dd2"

# Slightly modified version of Pkg.operations.get_github_archive_url
function github_tarball_url(url::String, ref::Union{String,Base.SHA1})
    if (m = match(r"https://github.com/(.*?)/(.*?).git", url)) != nothing
        return "https://api.github.com/repos/$(m.captures[1])/$(m.captures[2])/tarball/$(ref)"
    end
    return nothing
end

function unpack_strip_toplevel(f)
    unpack(f)
    for d in readdir(pwd())
        @assert startswith(d, "legend-exp-legend-testdata")
        for f in readdir(joinpath(pwd(), d))
            mv(joinpath(d, f), joinpath(pwd(), f))
        end
        rm(d)
    end
end

"""
    legend_test_data_path()::AbstractString

Get local path to the LEGEND test data set.

Will download the test data version matching the current version of
LegendTestData if not already present. The local copy of the test data is
managed via [DataDeps.jl](https://github.com/oxinabox/DataDeps.jl).

Set `ENV["DATADEPS_ALWAYS_ACCEPT"] = "true"` to avoid interactive prompt
asking for download permission.
"""
legend_test_data_path() = @datadep_str "legend-testdata-$(testdata_version)"
export legend_test_data_path

function __init__()
    register(
        DataDep(
            "legend-testdata-$(testdata_version)",
            """
            Dataset: LEGEND Test Data
            Authors: The LEGEND Collaboration
            Website: $(testdata_url)
            """,
            [github_tarball_url(testdata_url, testdata_version)],
            post_fetch_method = unpack_strip_toplevel
        )
    );
end

end # module


text:
using HDF5
using FileIO
using Formatting

# interprete argument
srcDir = ARGS[1]
dstFile = ARGS[2]

# parameters

# read images
aff = zeros(Float32, (1600,1600,107,3))

lst_fname = readdir(srcDir)

for c in 1:3
    for z in 1:107
	info("section $z")
	#fname = joinpath(srcDir, "c$(format(c-1, width=5, zeropadding=true))_z$(format(z-1, width=5, zeropadding=true))_y20000_x17000.tiff")
        fname = joinpath(srcDir, "c$(format(c-1, width=1, zeropadding=true))_z$(format(z-1, width=5, zeropadding=true)).tiff")
        aff2d = Array{Float32,2}( load(fname).data )
        # transpose the image for tif loading
        #aff2d = permutedims(aff2d, [2,1])
        # also swap the x and y channel
        aff[:,:,z,c] = aff2d
    end
end

# correct the affinity definition
sx,sy,sz,sc = size(aff)
aff[2:sx, :, :, 1] = aff[1:sx-1, :, :, 1]
aff[:, 2:sy, :, 2] = aff[:, 1:sy-1, :, 2]
aff[:, :, 2:sz, 3] = aff[:, :, 1:sz-1, 3]

# write result
h5write(dstFile, "main", aff)


text:
using Gadfly, RDatasets

set_default_plot_size(6inch, 3inch)

plot(dataset("datasets", "iris"), x=:SepalLength, y=:SepalWidth, color=:Species,
     Stat.x_jitter, Stat.y_jitter, Geom.point)

# make sure type-coercion works properly, the `y` values here are integers
# but will be coerced into floats.
plot(x=rand(500), y=rand(1:4, 500), Stat.y_jitter(range=0.5), Geom.point)


text:
module SimpleDelimitedFiles

@doc raw"""
    readdlm(source, [delim::Char = '\t'], [T::Type = Float64])

Read a delimited numerical matrix from the file named `source`. The elements
of the matrix should be of type `T`. The end of line delimiter is taken as `\n`.

For simple use cases, this is a more performant equivalent of `readdlm`
from `DelimitedFiles`. There are subtle differences though, for example this package
tries to aggressively remove multiple delimiters between entries, whereas `DelimitedFiles`
does not do this.

# Examples
```jldoctest
julia> f = tempname();

julia> using DelimitedFiles

julia> writedlm(f, ones(2, 2))

julia> SimpleDelimitedFiles.readdlm(f)
2×2 Matrix{Float64}:
 1.0  1.0
 1.0  1.0

julia> writedlm(f, ones(Int, 2, 2))

julia> SimpleDelimitedFiles.readdlm(f, Int)
2×2 Matrix{Int64}:
 1  1
 1  1

julia> writedlm(f, ones(Int, 2, 2), ',')

julia> SimpleDelimitedFiles.readdlm(f, ',', Int)
2×2 Matrix{Int64}:
 1  1
 1  1
```
"""
function readdlm(fname, delim::Char = '\t', T::Type = Float64)
    lines = open(fname, "r") do f
        readlines(f)
    end
    nrows = length(lines)
    r = Regex("[$delim]+")
    ncols = count(r, strip(lines[1])) + 1
    M = Matrix{T}(undef, nrows, ncols)
    for (rowind, l) in enumerate(lines)
        tokens = strip.(split(l, delim, keepempty = false))
        M[rowind, :] .= parse.(T, tokens)
    end
    return M
end
readdlm(fname, T::Type) = readdlm(fname, '\t', T)

end


text:
# This file is a part of SimilaritySearch.jl

export rebuild
export LocalSearchAlgorithm, SearchGraph, SearchGraphPools, SearchGraphCallbacks, VisitedVertices, NeighborhoodReduction, index!, push_item!
export Callback

function rebuild(g::SearchGraph)
    n = length(g)
    @assert n > 0
    direct = Vector{Vector{Int32}}(undef, n)  # this separated links version needs has easier multithreading/locking needs
    reverse = Vector{Vector{Int32}}(undef, n)

    Threads.@threads for i in 1:n
        @inbounds direct[i] = find_neighborhood(g, g[i], hints=g.links[i][1])
        reverse[i] = Vector{Int32}(undef, 0)
    end

    G = copy(g; links=direct, neighborhood=copy(g.neighborhood), locks=copy(g.locks), hints=copy(g.hints), callbacks=copy(g.callbacks), search_algo=copy(g.search_algo))
    _connect_reverse_links_neg(G.links, reverse, G.locks, 1, length(G))
    callbacks(G, force=true)
    G
end

function _connect_reverse_links_neg(direct, reverse, locks, sp, ep)
    Threads.@threads for i in sp:ep
        j = 0
        D = direct[i]
        @inbounds while j < length(D)
            j += 1
            id = D[j]
            if i == id
                D[j] = D[end]
                pop!(D)
                j -= 1
                continue
            end

            lock(locks[id])
            try
                push!(reverse[id], i)
            finally
                unlock(locks[id])
            end
        end
    end

    Threads.@threads for i in sp:ep
        @inbounds begin
            if length(direct[i]) >= length(reverse[i])
                append!(direct[i], reverse[i])
            else
                append!(reverse[i], direct[i])
                direct[i] = reverse[i]
            end
        end
    end
end

max_stars_repo_name: sadit/NNS

max_issues_repo_name: sadit/NNS

max_forks_repo_name: sadit/NNS


text:
module Transducers

export Map, Filter, Cat, MapCat, Take, PartitionBy, Scan, TeeZip, Zip,
    Replace, TakeWhile, TakeNth, Drop, DropLast, DropWhile, Keep, Distinct,
    Interpose, Dedupe, Window, GetIndex, SetIndex, Iterated, Count, Merge,
    transduce, eduction, loop,
    Completing

include("basics.jl")
include("core.jl")
include("library.jl")
include("processes.jl")
include("lister.jl")

end # module


text:
using ImageShow
using ImageShow: read_key

@testset "keyboard" begin
    # TODO: Ctrl-C (InterruptException) is not tested
    @testset "read_key" begin
        inputs = [
            (UInt8['\e', '[', 'A'], :CONTROL_BACKWARD), # UP
            (UInt8['\e', '[', 'D'], :CONTROL_BACKWARD), # LEFT
            (UInt8['\e', '[', 'B'], :CONTROL_FORWARD), # DOWN
            (UInt8['\e', '[', 'C'], :CONTROL_FORWARD), # RIGHT

            (UInt8[' '],            :CONTROL_PAUSE), # SPACE
            (UInt8['p'],            :CONTROL_PAUSE),
            (UInt8['P'],            :CONTROL_PAUSE),
            (UInt8['q'],            :CONTROL_EXIT),
            (UInt8['Q'],            :CONTROL_EXIT),
            (UInt8['f'],            :CONTROL_FORWARD),
            (UInt8['F'],            :CONTROL_FORWARD),
            (UInt8['b'],            :CONTROL_BACKWARD),
            (UInt8['B'],            :CONTROL_BACKWARD),

            # key events that currenctly has no effect

            # although VIM users might want this :)
            (UInt8['j'],            :CONTROL_VOID),
            (UInt8['k'],            :CONTROL_VOID),
            (UInt8['h'],            :CONTROL_VOID),
            (UInt8['l'],            :CONTROL_VOID),
        ]
        for (chs, ref) in inputs
            io = IOBuffer(chs)
            @test ref == read_key(io)
        end
    end
end