Skip to content

Commit

Permalink
Refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm committed Mar 16, 2021
1 parent 1041a7d commit 3a1b332
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 17 deletions.
4 changes: 0 additions & 4 deletions src/fitting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Licensed under the MIT License. See LICENCE in the project root.
# ------------------------------------------------------------------


"""
log_gpd_pdf(arg, μ, σ, ξ)
Expand All @@ -20,7 +19,6 @@ function log_gpd_pdf(_x, μ, σ, ξ)
expn - log(σ)
end


"""
log_gev_pdf(arg, μ, σ, ξ)
Expand All @@ -38,7 +36,6 @@ function log_gev_pdf(_x, μ, σ, ξ)
+1)*tx - exp(tx) - log(σ)
end


"""
fit_mle(gev, bm)
Expand Down Expand Up @@ -79,7 +76,6 @@ function fit_mle(::Type{GeneralizedExtremeValue}, bm::BlockMaxima;
end
end


"""
fit_mle(gp, pm)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 12 additions & 12 deletions test/fitting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
dist1 = GeneralizedExtremeValue(0.0, 1.0, 0.0)
dist2 = GeneralizedExtremeValue(0.0, 1.0, 0.5)
dist3 = GeneralizedExtremeValue(1.0, 1.0, 0.5) # The problem distribution...
r_gev_1 = readdlm("R_fit_results/R_gev_dist1_fits.csv", ',')
r_gev_2 = readdlm("R_fit_results/R_gev_dist2_fits.csv", ',')
r_gev_3 = readdlm("R_fit_results/R_gev_dist3_fits.csv", ',')
r_gev_1 = readdlm(joinpath(datadir,"R_gev_dist1_fits.csv"), ',')
r_gev_2 = readdlm(joinpath(datadir,"R_gev_dist2_fits.csv"), ',')
r_gev_3 = readdlm(joinpath(datadir,"R_gev_dist3_fits.csv"), ',')
r_result = zip(eachrow(r_gev_1), eachrow(r_gev_2), eachrow(r_gev_3))
for (test_ix, r_gev_ix) in enumerate(r_result)
for (r_mle, dist) in zip(r_gev_ix, (dist1, dist2, dist3))
Expand All @@ -28,9 +28,9 @@
dist1 = GeneralizedPareto(0.0, 1.0, 0.0)
dist2 = GeneralizedPareto(0.0, 1.0, 0.5)
dist3 = GeneralizedPareto(1.0, 1.0, 0.5)
r_gpd_1 = readdlm("R_fit_results/R_gpd_dist1_fits.csv", ',')
r_gpd_2 = readdlm("R_fit_results/R_gpd_dist2_fits.csv", ',')
r_gpd_3 = readdlm("R_fit_results/R_gpd_dist3_fits.csv", ',')
r_gpd_1 = readdlm(joinpath(datadir,"R_gpd_dist1_fits.csv"), ',')
r_gpd_2 = readdlm(joinpath(datadir,"R_gpd_dist2_fits.csv"), ',')
r_gpd_3 = readdlm(joinpath(datadir,"R_gpd_dist3_fits.csv"), ',')
r_result = zip(eachrow(r_gpd_1), eachrow(r_gpd_2), eachrow(r_gpd_3))
for (test_ix, r_gpd_ix) in enumerate(r_result)
for (r_mle, dist) in zip(r_gpd_ix, (dist1, dist2, dist3))
Expand Down Expand Up @@ -85,10 +85,10 @@ for test_ix in 1:10
end
using DelimitedFiles
writedlm("R_fit_results/R_gev_dist1_fits.csv", getindex.(gev_R_results, 1), ',')
writedlm("R_fit_results/R_gev_dist2_fits.csv", getindex.(gev_R_results, 2), ',')
writedlm("R_fit_results/R_gev_dist3_fits.csv", getindex.(gev_R_results, 3), ',')
writedlm("R_fit_results/R_gpd_dist1_fits.csv", getindex.(gpd_R_results, 1), ',')
writedlm("R_fit_results/R_gpd_dist2_fits.csv", getindex.(gpd_R_results, 2), ',')
writedlm("R_fit_results/R_gpd_dist3_fits.csv", getindex.(gpd_R_results, 3), ',')
writedlm("data/R_gev_dist1_fits.csv", getindex.(gev_R_results, 1), ',')
writedlm("data/R_gev_dist2_fits.csv", getindex.(gev_R_results, 2), ',')
writedlm("data/R_gev_dist3_fits.csv", getindex.(gev_R_results, 3), ',')
writedlm("data/R_gpd_dist1_fits.csv", getindex.(gpd_R_results, 1), ',')
writedlm("data/R_gpd_dist2_fits.csv", getindex.(gpd_R_results, 2), ',')
writedlm("data/R_gpd_dist3_fits.csv", getindex.(gpd_R_results, 3), ',')
=#
3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using ExtremeStats
using Distributions
using StableRNGs
using DelimitedFiles
using Plots; gr(size=(600,400))
using ReferenceTests, ImageIO
using Test, Random
using DelimitedFiles, StableRNGs # for fitting

# workaround GR warnings
ENV["GKSwstype"] = "100"
Expand Down

0 comments on commit 3a1b332

Please sign in to comment.