Skip to content

Commit

Permalink
Merge pull request #962 from jdebacker/debt_gdp_labels
Browse files Browse the repository at this point in the history
Merging
  • Loading branch information
rickecon authored Aug 10, 2024
2 parents f21d2f0 + 79dcd46 commit 6b4cccb
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 13 deletions.
21 changes: 20 additions & 1 deletion ogcore/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
BASELINE_DIR = "OUTPUT_BASELINE"

# Default year for model runs
DEFAULT_START_YEAR = 2021
DEFAULT_START_YEAR = 2025


VAR_LABELS = {
Expand Down Expand Up @@ -83,16 +83,35 @@
}

ToGDP_LABELS = {
"Y": "GDP-to-GDP (=1 ;-))",
"B": "Savings-to-GDP ($B_{t}/Y_t$)",
"C": "Consumption-to-GDP ($C_{t}/Y_t$)",
"D": "Debt-to-GDP ($D_{t}/Y_t$)",
"D_d": "Domestically-owned Debt-to-GDP ($D^d_{t}/Y_t$)",
"D_f": "Foreign-owned Debt-to-GDP ($D^f_{t}/Y_t$)",
"G": "Govt Spending-to-GDP ($G_{t}/Y_t$)",
"K": "Capital-Output Ratio ($K_{t}/Y_t$)",
"K_d": "Domestically-owned Capital-Output Ratio ($K^d_{t}/Y_t$)",
"K_f": "Foreign-owned Capital-Output Ratio ($K^f_{t}/Y_t$)",
"K_g": "Infrastructure-Output Ratio ($K^g_{t}/Y_t$)",
"C": "Consumption-Output Ratio ($C_{t}/Y_t$)",
"I": "Investment-Output Ratio ($I_{t}/Y_t$)",
"I_total": "Investment-Output Ratio ($I_{t}/Y_t$)",
"I_d": "Domestic Investment-Output Ratio ($I^d_{t}/Y_t$)",
"I_g": "Infrastructure Investment-Output Ratio ($I^g_{t}/Y_t$)",
"total_tax_revenue": "Tax Revenue-to-GDP ($REV_{t}/Y_t$)",
"TR": "Transfer Spending-to-GDP ($TR_{t}/Y_t$)",
"BQ": "Bequests-to-GDP ($BQ_{t}/Y_t$)",
"total_tax_revenue": "Tax Revenue-to-GDP ($Revenue_{t}/Y_t$)",
"business_tax_revenue": "Corporate Tax Revenue-to-GDP",
"iit_revenue": "Personal Income Tax Revenue-to-GDP",
"iit_payroll_revenue": "Personal Income + Payroll Tax Revenue-to-GDP",
"payroll_tax_revenue": "Payroll Tax Revenue-to-GDP",
"bequest_tax_revenue": "Bequest Tax Revenue-to-GDP",
"wealth_tax_revenue": "Wealth Tax Revenue-to-GDP",
"cons_tax_revenue": "Consumption Tax Revenue-to-GDP",
"agg_pension_outlays": "Pension Outlays-to-GDP ($Pensions_{t}/Y_t$)",
"UBI_path": "UBI Outlays-to-GDP ($UBI_{t}/Y_t$)",
}

GROUP_LABELS = {
Expand Down
9 changes: 9 additions & 0 deletions ogcore/output_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def plot_aggregates(
assert reform_tpi is not None
fig1, ax1 = plt.subplots()
for i, v in enumerate(var_list):
assert (
v in VAR_LABELS.keys()
), "{} is not in the list of variable labels".format(v)
if plot_type == "pct_diff":
if v in ["r_gov", "r", "r_p"]:
# Compute just percentage point changes for rates
Expand Down Expand Up @@ -237,6 +240,9 @@ def plot_industry_aggregates(
assert reform_tpi is not None
fig1, ax1 = plt.subplots()
for i, v in enumerate(var_list):
assert (
v in VAR_LABELS.keys()
), "{} is not in the list of variable labels".format(v)
if len(var_list) == 1:
var_label = ""
else:
Expand Down Expand Up @@ -449,6 +455,9 @@ def plot_gdp_ratio(
start_index = start_year - base_params.start_year
fig1, ax1 = plt.subplots()
for i, v in enumerate(var_list):
assert (
v in ToGDP_LABELS.keys()
), "{} is not in the list of variable labels".format(v)
if plot_type == "levels":
plot_var_base = (
base_tpi[v][: base_params.T] / base_tpi["Y"][: base_params.T]
Expand Down
4 changes: 3 additions & 1 deletion ogcore/parameter_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ def param_table(p, table_format="tex", path=None):
value = getattr(p, k)
if hasattr(value, "__len__") & ~isinstance(value, str):
if value.ndim > 1:
report = "See elsewhere"
report = (
"Too large to report here, see default parameters JSON"
)
else:
report = (
"["
Expand Down
20 changes: 10 additions & 10 deletions ogcore/pensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ def delta_ret(r, Y, p):
return delta_ret


@numba.jit
@numba.jit(nopython=True)
def deriv_DB_loop(
w, e, S, S_ret, per_rmn, avg_earn_num_years, alpha_db, yr_contr
):
Expand Down Expand Up @@ -744,7 +744,7 @@ def deriv_DB_loop(
return d_theta


@numba.jit
@numba.jit(nopython=True)
def deriv_PS_loop(w, e, S, S_ret, per_rmn, d_theta, vpoint, factor):
"""
Change in points system pension benefits for another unit of
Expand Down Expand Up @@ -776,7 +776,7 @@ def deriv_PS_loop(w, e, S, S_ret, per_rmn, d_theta, vpoint, factor):
return d_theta


@numba.jit
@numba.jit(nopython=True)
def deriv_NDC_loop(
w, e, per_rmn, S, S_ret, tau_p, g_ndc_value, delta_ret_value, d_theta
):
Expand Down Expand Up @@ -813,7 +813,7 @@ def deriv_NDC_loop(
return d_theta


@numba.jit
@numba.jit(nopython=True)
def delta_ret_loop(S, S_ret, surv_rates, g_dir_value, dir_delta_s):
"""
Compute conversion coefficient for the NDC pension amount
Expand Down Expand Up @@ -842,7 +842,7 @@ def delta_ret_loop(S, S_ret, surv_rates, g_dir_value, dir_delta_s):
return dir_delta


@numba.jit
@numba.jit(nopython=True)
def PS_1dim_loop(w, e, n, S_ret, S, g_y, vpoint, factor, L_inc_avg_s, PS):
"""
Calculate public pension from a points system.
Expand Down Expand Up @@ -876,7 +876,7 @@ def PS_1dim_loop(w, e, n, S_ret, S, g_y, vpoint, factor, L_inc_avg_s, PS):
return PS


@numba.jit
@numba.jit(nopython=True)
def PS_2dim_loop(w, e, n, S_ret, S, J, g_y, vpoint, factor, L_inc_avg_sj, PS):
"""
Calculate public pension from a points system.
Expand Down Expand Up @@ -912,7 +912,7 @@ def PS_2dim_loop(w, e, n, S_ret, S, J, g_y, vpoint, factor, L_inc_avg_sj, PS):
return PS


@numba.jit
@numba.jit(nopython=True)
def DB_1dim_loop(
w,
e,
Expand Down Expand Up @@ -962,7 +962,7 @@ def DB_1dim_loop(
return DB


@numba.jit
@numba.jit(nopython=True)
def DB_2dim_loop(
w,
e,
Expand Down Expand Up @@ -1010,7 +1010,7 @@ def DB_2dim_loop(
return DB


@numba.jit
@numba.jit(nopython=True)
def NDC_1dim_loop(w, e, n, S_ret, S, g_y, tau_p, g_ndc, delta_ret, NDC_s, NDC):
"""
Calculate public pension from a notional defined contribution
Expand Down Expand Up @@ -1046,7 +1046,7 @@ def NDC_1dim_loop(w, e, n, S_ret, S, g_y, tau_p, g_ndc, delta_ret, NDC_s, NDC):
return NDC


@numba.jit
@numba.jit(nopython=True)
def NDC_2dim_loop(
w, e, n, S_ret, S, g_y, tau_p, g_ndc, delta_ret, NDC_sj, NDC
):
Expand Down
6 changes: 5 additions & 1 deletion ogcore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def save_return_table(table_df, output_type, path, precision=2):
Args:
table_df (Pandas DataFrame): table
output_type (string): specifies the type of file to save
table to: 'csv', 'tex', 'excel', 'json'
table to: 'csv', 'tex', 'excel', 'json', 'md'
path (string): specifies path to save file with table to
precision (integer): number of significant digits to print.
Defaults to 0.
Expand Down Expand Up @@ -433,6 +433,10 @@ def save_return_table(table_df, output_type, path, precision=2):
table_df.to_csv(path_or_buf=path, index=False, na_rep="")
elif output_type == "json":
table_df.to_json(path_or_buf=path, double_precision=precision)
elif output_type == "md":
table_df.to_markdown(
buf=path, index=False, floatfmt=".{}f".format(precision)
)
elif output_type == "excel":
table_df.to_excel(excel_writer=path, index=False, na_rep="")
else:
Expand Down

0 comments on commit 6b4cccb

Please sign in to comment.