Skip to content

Commit 0019995

Browse files
Thore KockerolsThore Kockerols
authored andcommitted
create reduced vectors to separate model name
1 parent 4889d61 commit 0019995

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

ext/StatsPlotsExt.jl

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ const args_and_kwargs_names = Dict(:model_name => "Model",
3333
:generalised_irf => "Generalised IRF",
3434
:ignore_obc => "Ignore OBC",
3535
# :tol => "Tolerance",
36-
# :quadratic_matrix_equation_algorithm => "Quadratic Matrix Equation Algorithm",
37-
# :sylvester_algorithm => "Sylvester Algorithm",
38-
# :lyapunov_algorithm => "Lyapunov Algorithm"
36+
:quadratic_matrix_equation_algorithm => "Quadratic Matrix Equation Algorithm",
37+
:sylvester_algorithm => "Sylvester Algorithm",
38+
:lyapunov_algorithm => "Lyapunov Algorithm"
3939
)
4040

4141
@stable default_mode = "disable" begin
@@ -1330,7 +1330,24 @@ function plot_irf!(𝓂::ℳ;
13301330
:var_idx => var_idx)
13311331

13321332
push!(irf_active_plot_container, args_and_kwargs)
1333-
1333+
1334+
# 1. Keep only certain keys from each dictionary
1335+
keys_to_keep = [:model_name, :periods, :shocks] # adapt to your needs
1336+
1337+
reduced_vector = [
1338+
Dict(k => d[k] for k in keys(args_and_kwargs_names) if haskey(d, k))
1339+
for d in irf_active_plot_container
1340+
]
1341+
# println(reduced_vector)
1342+
# 2. Group the original vector by :model_name
1343+
grouped_by_model = Dict{Any, Vector{Dict}}()
1344+
1345+
for d in irf_active_plot_container
1346+
model = d[:model_name]
1347+
d_sub = Dict(k => d[k] for k in setdiff(keys(args_and_kwargs),keys(args_and_kwargs_names)) if haskey(d, k))
1348+
push!(get!(grouped_by_model, model, Vector{Dict}()), d_sub)
1349+
end
1350+
# println(grouped_by_model)
13341351
diffdict = compare_args_and_kwargs(irf_active_plot_container)
13351352

13361353
@assert haskey(diffdict, :parameters) || haskey(diffdict, :shock_names) || any(haskey.(Ref(diffdict), keys(args_and_kwargs_names))) "New plot must be different from previous plot. Use the version without ! to plot."
@@ -1358,7 +1375,9 @@ function plot_irf!(𝓂::ℳ;
13581375

13591376
same_shock_direction = true
13601377

1361-
for k in setdiff(keys(args_and_kwargs), [:periods, :shocks, :variables, :parameters, :initial_state, :plot_data, :tol, :reference_steady_state, :quadratic_matrix_equation_algorithm, :sylvester_algorithm, :lyapunov_algorithm, :variable_names, :shock_names, :shock_idx, :var_idx])
1378+
for k in setdiff(keys(args_and_kwargs), [:periods, :shocks, :variables, :parameters, :initial_state, :plot_data, :tol, :reference_steady_state,
1379+
# :quadratic_matrix_equation_algorithm, :sylvester_algorithm, :lyapunov_algorithm,
1380+
:variable_names, :shock_names, :shock_idx, :var_idx])
13621381
if haskey(diffdict, k)
13631382
push!(annotate_diff_input, args_and_kwargs_names[k] => reduce(vcat,diffdict[k]))
13641383

0 commit comments

Comments
 (0)