Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidanthoff committed Mar 9, 2019
1 parent c092812 commit 2fea967
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using MimiFUND
using Mimi
using Test
using DataFrames
Expand All @@ -11,15 +12,12 @@ using CSVFiles

@testset "fund-model" begin

include("../src/fund.jl")
using .Fund

#default model exported by fund module
global default_nsteps = 1050
global m = getfund()
run(m)
@test Mimi.time_labels(m) == collect(1950:1:1950+default_nsteps)

#default model created by getfund()
global m1 = getfund()
run(m1)
Expand All @@ -39,9 +37,6 @@ end #fund-model testset

Mimi.reset_compdefs()

include("../src/fund.jl")
using .Fund

global m = getfund()
run(m)

Expand All @@ -52,14 +47,14 @@ err_array = 0.0
for c in map(name, Mimi.compdefs(m)), v in Mimi.variable_names(m, c)

#load data for comparison
filename = joinpath(@__DIR__, "../contrib/validation_data_v040/$c-$v.csv")
filename = joinpath(@__DIR__, "../contrib/validation_data_v040/$c-$v.csv")
results = m[c, v]

df = load(filename) |> DataFrame
if typeof(results) <: Number
validation_results = df[1,1]
@test results validation_results atol = err_number #slight imprecision with these values due to rounding

else
validation_results = convert(Array, df)

Expand All @@ -71,9 +66,9 @@ for c in map(name, Mimi.compdefs(m)), v in Mimi.variable_names(m, c)
if size(validation_results,1) == 1
validation_results = validation_results'
end

@test results validation_results atol = err_array

end
end

Expand All @@ -83,7 +78,7 @@ end #fund-integration testset
# 3. Test marginal damages functions (test that each function does not error)
#------------------------------------------------------------------------------

@testset "test-marginaldamages" begin
@testset "test-marginaldamages" begin

include("../src/marginaldamages.jl")
md = getmarginaldamages()
Expand All @@ -102,7 +97,7 @@ end #marginaldamages testset
# 4. Run basic test of MCS functionality
#------------------------------------------------------------------------------

@testset "test-mcs" begin
@testset "test-mcs" begin

include("../src/montecarlo/run_fund_mcs.jl")
include("../src/montecarlo/run_fund_scc_mcs.jl")
Expand Down

0 comments on commit 2fea967

Please sign in to comment.