Skip to content

Commit 30cc60e

Browse files
committed
move epsilon.jl test to deterministic, clean deterministic output test
1 parent 07abfbb commit 30cc60e

File tree

5 files changed

+36
-40
lines changed

5 files changed

+36
-40
lines changed

test/deterministic/deterministic_ouput_t1_t5.jl

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
@testset "time 1 and 5 deterministic" begin
22

33
dir = @__DIR__
4-
54
T = 1
65
parameters = BeforeIT.AUSTRIA2010Q1.parameters
76
initial_conditions = BeforeIT.AUSTRIA2010Q1.initial_conditions
@@ -28,29 +27,28 @@
2827
end
2928
end
3029

31-
32-
T = 4
33-
parameters = matread(joinpath(dir, "../../data/austria/parameters/2010Q1.mat"))
34-
initial_conditions = matread(joinpath(dir, "../../data/austria/initial_conditions/2010Q1.mat"))
30+
T = 5
31+
parameters = BeforeIT.AUSTRIA2010Q1.parameters
32+
initial_conditions = BeforeIT.AUSTRIA2010Q1.initial_conditions
3533
model = BeforeIT.initialise_model(parameters, initial_conditions, T)
3634
data = BeforeIT.initialise_data(model)
37-
for t in 1:T-1
35+
for t in 1:T
3836
BeforeIT.one_epoch!(model; multi_threading = false)
3937
BeforeIT.update_data!(data, model)
4038
end
4139

42-
output_t5 = matread(joinpath(dir, "../matlab_code/output_t5.mat"))list
40+
output_t5 = matread(joinpath(dir, "../matlab_code/output_t5.mat"))
4341

4442
# confront results between julia and matlab code
4543

4644
for fieldname in fieldnames(typeof(data))
4745
julia_output = getfield(data, fieldname)
4846
matlab_output = output_t5[string(fieldname)]
4947

50-
if length(size(julia_output)) == 1
51-
@test isapprox(julia_output, matlab_output', rtol = 1e-4)
48+
if length(julia_output) == 6
49+
@test isapprox(julia_output[2:end], matlab_output', rtol = 1e-4)
5250
else
53-
@test isapprox(julia_output, matlab_output, rtol = 1e-5)
51+
@test isapprox(julia_output[2:end, :], matlab_output, rtol = 1e-5)
5452
end
5553
end
5654

test/deterministic/epsilon.jl

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using BeforeIT
2+
using Test
3+
import Random: randn
4+
5+
6+
function randn(n1::Int, n2::Int)
7+
return ones(n1, n2)
8+
end
9+
10+
# Define a fixed covariance matrix
11+
C = [
12+
2.0 0.5 0.3
13+
0.5 1.5 0.2
14+
0.3 0.2 1.0
15+
]
16+
17+
# results from original matlab code with rand = false
18+
expected_eps_Y_EA = 1.4142135623731
19+
expected_eps_E = 1.52615733054913
20+
expected_eps_I = 1.29014186522609
21+
22+
eps_Y_EA, eps_E, eps_I = BeforeIT.epsilon(C)
23+
24+
25+
@test isapprox(eps_Y_EA, expected_eps_Y_EA)
26+
@test isapprox(eps_E, expected_eps_E)
27+
@test isapprox(eps_I, expected_eps_I)

test/deterministic/runtests_deterministic.jl

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@warn "making the model deterministic all subsequent calls to the model will be deterministic."
2+
include("epsilon.jl")
23
include("make_model_deterministic.jl")
34
include("initialize_deterministic.jl")
45
include("one_epoch_deterministic.jl")

test/runtests.jl

-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
using BeforeIT, Test
22

33
#utils
4-
include("utils/epsilon.jl")
54
include("utils/positive.jl")
65
include("utils/randpl.jl")
76
include("utils/nfvar3_and_estimate.jl")
8-
97
include("utils/estimations.jl")
108

119
# search_and_matching

test/utils/epsilon.jl

-28
This file was deleted.

0 commit comments

Comments
 (0)