diff --git a/ogcore/constants.py b/ogcore/constants.py index 877de6da8..f5298b1f9 100644 --- a/ogcore/constants.py +++ b/ogcore/constants.py @@ -4,7 +4,7 @@ BASELINE_DIR = "OUTPUT_BASELINE" # Default year for model runs -DEFAULT_START_YEAR = 2021 +DEFAULT_START_YEAR = 2025 VAR_LABELS = { @@ -83,6 +83,9 @@ } 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$)", @@ -90,9 +93,25 @@ "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 = { diff --git a/ogcore/output_plots.py b/ogcore/output_plots.py index 50a5a7094..fdc07a224 100644 --- a/ogcore/output_plots.py +++ b/ogcore/output_plots.py @@ -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 @@ -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: @@ -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] diff --git a/ogcore/parameter_tables.py b/ogcore/parameter_tables.py index b567dc90a..dbaa75d2d 100644 --- a/ogcore/parameter_tables.py +++ b/ogcore/parameter_tables.py @@ -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 = ( "[" diff --git a/ogcore/pensions.py b/ogcore/pensions.py index 41dbd11d4..35b28cadf 100644 --- a/ogcore/pensions.py +++ b/ogcore/pensions.py @@ -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 ): @@ -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 @@ -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 ): @@ -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 @@ -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. @@ -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. @@ -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, @@ -962,7 +962,7 @@ def DB_1dim_loop( return DB -@numba.jit +@numba.jit(nopython=True) def DB_2dim_loop( w, e, @@ -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 @@ -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 ): diff --git a/ogcore/utils.py b/ogcore/utils.py index 1bde6c585..25896a551 100644 --- a/ogcore/utils.py +++ b/ogcore/utils.py @@ -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. @@ -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: