Skip to content

Commit 600a52c

Browse files
Thore KockerolsThore Kockerols
authored andcommitted
more test for plotting, label and plot_type
1 parent 595590b commit 600a52c

File tree

1 file changed

+107
-7
lines changed

1 file changed

+107
-7
lines changed

test/functionality_tests.jl

Lines changed: 107 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ function functionality_test(m; algorithm = :first_order, plots = true)
279279
plot_model_estimates(m, data,
280280
algorithm = algorithm,
281281
parameters = params[1],
282+
label = "baseline",
282283
data_in_levels = false)
283284

284285
plot_model_estimates!(m, data_in_levels,
@@ -323,7 +324,7 @@ function functionality_test(m; algorithm = :first_order, plots = true)
323324
end
324325
# end
325326
end
326-
327+
327328
@testset "plot_solution" begin
328329

329330

@@ -484,6 +485,20 @@ function functionality_test(m; algorithm = :first_order, plots = true)
484485
end
485486

486487

488+
plot_irf(m, algorithm = algorithm)
489+
490+
for negative_shock in [true,false]
491+
for shock_size in [.1,1]
492+
for plot_type in [:compare, :stack]
493+
plot_irf!(m, algorithm = algorithm,
494+
plot_type = plot_type,
495+
negative_shock = negative_shock,
496+
shock_size = shock_size)
497+
end
498+
end
499+
end
500+
501+
487502
shock_mat = randn(m.timings.nExo,3)
488503

489504
shock_mat2 = KeyedArray(randn(m.timings.nExo,10),Shocks = m.timings.exo, Periods = 1:10)
@@ -573,8 +588,8 @@ function functionality_test(m; algorithm = :first_order, plots = true)
573588
plot_irf(m, algorithm = algorithm)
574589

575590
i = 1
576-
577-
for shocks in [:none, :all, :all_excluding_obc, :simulate, m.timings.exo[1], m.timings.exo[1:2], reshape(m.exo,1,length(m.exo)), Tuple(m.exo), Tuple(string.(m.exo)), string(m.timings.exo[1]), reshape(string.(m.exo),1,length(m.exo)), string.(m.timings.exo[1:2]), shock_mat, shock_mat2, shock_mat3]
591+
592+
for variables in vars
578593
if i % 4 == 0
579594
plot_irf(m, algorithm = algorithm)
580595
end
@@ -583,20 +598,48 @@ function functionality_test(m; algorithm = :first_order, plots = true)
583598

584599
clear_solution_caches!(m, algorithm)
585600

586-
plot_irf!(m, algorithm = algorithm, shocks = shocks)
601+
plot_irf!(m, algorithm = algorithm, variables = variables)
587602
end
588603

604+
589605
for shocks in [:all, :all_excluding_obc, :none, :simulate, m.timings.exo[1], m.timings.exo[1:2], reshape(m.exo,1,length(m.exo)), Tuple(m.exo), Tuple(string.(m.exo)), string(m.timings.exo[1]), reshape(string.(m.exo),1,length(m.exo)), string.(m.timings.exo[1:2]), shock_mat, shock_mat2, shock_mat3]
590606
clear_solution_caches!(m, algorithm)
591607

592608
plot_irf(m, algorithm = algorithm, shocks = shocks)
593609
end
594610

611+
plot_irf(m, algorithm = algorithm)
612+
613+
i = 1
614+
615+
for shocks in [:none, :all, :all_excluding_obc, :simulate, m.timings.exo[1], m.timings.exo[1:2], reshape(m.exo,1,length(m.exo)), Tuple(m.exo), Tuple(string.(m.exo)), string(m.timings.exo[1]), reshape(string.(m.exo),1,length(m.exo)), string.(m.timings.exo[1:2]), shock_mat, shock_mat2, shock_mat3]
616+
if i % 4 == 0
617+
plot_irf(m, algorithm = algorithm)
618+
end
619+
620+
i += 1
621+
622+
clear_solution_caches!(m, algorithm)
623+
624+
plot_irf!(m, algorithm = algorithm, shocks = shocks)
625+
end
626+
627+
595628
for plot_attributes in [Dict(), Dict(:plot_titlefontcolor => :red)]
596629
for plots_per_page in [4,6]
597-
plot_irf(m, algorithm = algorithm,
598-
plot_attributes = plot_attributes,
599-
plots_per_page = plots_per_page)
630+
for label in [:dil, "data in levels", 0, 0.01]
631+
plot_irf(m, algorithm = algorithm,
632+
label = "baseline",
633+
parameters = params[1],
634+
plot_attributes = plot_attributes,
635+
plots_per_page = plots_per_page)
636+
637+
plot_irf!(m, algorithm = algorithm,
638+
parameters = params[2],
639+
label = label,
640+
plot_attributes = plot_attributes,
641+
plots_per_page = plots_per_page)
642+
end
600643
end
601644
end
602645

@@ -611,6 +654,14 @@ function functionality_test(m; algorithm = :first_order, plots = true)
611654
for save_plots_path in (save_plots ? [pwd(), "../"] : [pwd()])
612655
for save_plots_format in (save_plots ? [:pdf,:png,:ps,:svg] : [:pdf]) # (save_plots ? backend == :gr ? (save_plots ? [:pdf,:png,:ps,:svg] : [:pdf]) : [:html,:json,:pdf,:png,:svg] : [:pdf])
613656
plot_irf(m, algorithm = algorithm,
657+
parameters = params[1],
658+
show_plots = show_plots,
659+
save_plots = save_plots,
660+
save_plots_path = save_plots_path,
661+
save_plots_format = save_plots_format)
662+
663+
plot_irf!(m, algorithm = algorithm,
664+
parameters = params[2],
614665
show_plots = show_plots,
615666
save_plots = save_plots,
616667
save_plots_path = save_plots_path,
@@ -789,6 +840,18 @@ function functionality_test(m; algorithm = :first_order, plots = true)
789840
plots_per_page = plots_per_page,
790841
save_plots_path = save_plots_path,
791842
save_plots_format = save_plots_format)
843+
844+
plot_conditional_forecast!(m, conditions[end],
845+
conditions_in_levels = false,
846+
initial_state = [0.0],
847+
algorithm = algorithm,
848+
shocks = shocks[1],
849+
plot_attributes = plot_attributes,
850+
show_plots = show_plots,
851+
save_plots = save_plots,
852+
plots_per_page = plots_per_page,
853+
save_plots_path = save_plots_path,
854+
save_plots_format = save_plots_format)
792855
end
793856
end
794857
end
@@ -812,6 +875,15 @@ function functionality_test(m; algorithm = :first_order, plots = true)
812875
quadratic_matrix_equation_algorithm = quadratic_matrix_equation_algorithm,
813876
lyapunov_algorithm = lyapunov_algorithm,
814877
sylvester_algorithm = sylvester_algorithm)
878+
879+
plot_conditional_forecast!(m, conditions[1],
880+
conditions_in_levels = false,
881+
algorithm = algorithm,
882+
shocks = shocks[end],
883+
tol = tol,
884+
quadratic_matrix_equation_algorithm = quadratic_matrix_equation_algorithm,
885+
lyapunov_algorithm = lyapunov_algorithm,
886+
sylvester_algorithm = sylvester_algorithm)
815887
end
816888
end
817889
end
@@ -901,6 +973,19 @@ function functionality_test(m; algorithm = :first_order, plots = true)
901973
variables = variables)
902974
end
903975

976+
plot_conditional_forecast(m, conditions[end],
977+
conditions_in_levels = false,
978+
algorithm = algorithm)
979+
980+
for variables in vars
981+
plot_conditional_forecast!(m, conditions[end],
982+
conditions_in_levels = false,
983+
initial_state = init_states[end],
984+
variables = variables,
985+
algorithm = algorithm)
986+
end
987+
988+
904989
for initial_state in init_states
905990
plot_conditional_forecast(m, conditions[end],
906991
conditions_in_levels = false,
@@ -977,6 +1062,21 @@ function functionality_test(m; algorithm = :first_order, plots = true)
9771062
algorithm = algorithm)
9781063
end
9791064

1065+
1066+
plot_conditional_forecast(m, conditions[end],
1067+
conditions_in_levels = false,
1068+
algorithm = algorithm,
1069+
shocks = shocks[end])
1070+
1071+
for cndtns in conditions
1072+
for plot_type in [:compare, :stack]
1073+
plot_conditional_forecast!(m, cndtns,
1074+
conditions_in_levels = false,
1075+
plot_type = plot_type,
1076+
algorithm = algorithm)
1077+
end
1078+
end
1079+
9801080
# plotlyjs_backend()
9811081

9821082
# plot_conditional_forecast(m, conditions[end],

0 commit comments

Comments
 (0)