diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 6730c157..813ba02c 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -54,7 +54,7 @@ jobs: run: | python -m pytest -m "not local" --cov=./ --cov-report=xml - name: Upload coverage to Codecov - if: matrix.os == 'ubuntu-latest' + if: matrix.os == 'ubuntu-latest' && contains(github.repository, 'PSLmodels/OG-USA') uses: codecov/codecov-action@v4 with: files: ./coverage.xml diff --git a/examples/run_og_usa.py b/examples/run_og_usa.py index 8606b1c6..1f0e501d 100644 --- a/examples/run_og_usa.py +++ b/examples/run_og_usa.py @@ -4,6 +4,7 @@ import json import time from taxcalc import Calculator +import matplotlib.pyplot as plt from ogusa.calibrate import Calibration from ogcore.parameters import Specifications from ogcore import output_tables as ot @@ -11,6 +12,13 @@ from ogcore.execute import runner from ogcore.utils import safe_read_pickle +# Use a custom matplotlib style file for plots +style_file_url = ( + "https://raw.githubusercontent.com/PSLmodels/OG-Core/" + + "master/ogcore/OGcorePlots.mplstyle" +) +plt.style.use(style_file_url) + def main(): # Define parameters to use for multiprocessing @@ -46,6 +54,7 @@ def main(): ) ) p.tax_func_type = "GS" + p.age_specific = False c = Calibration(p, estimate_tax_functions=True, client=client) # close and delete client bc cache is too large client.close() @@ -99,6 +108,7 @@ def main(): ) ) p2.tax_func_type = "GS" + p2.age_specific = False # Use calibration class to estimate reform tax functions from # Tax-Calculator, specifying reform for Tax-Calculator in iit_reform c2 = Calibration( @@ -152,12 +162,31 @@ def main(): # create plots of output op.plot_all( - base_dir, reform_dir, os.path.join(CUR_DIR, "OG-USA_example_plots") + base_dir, + reform_dir, + os.path.join(CUR_DIR, "OG-USA_example_plots_tables"), + ) + # Create CSV file with output + ot.tp_output_dump_table( + base_params, + base_tpi, + reform_params, + reform_tpi, + table_format="csv", + path=os.path.join( + CUR_DIR, + "OG-USA_example_plots_tables", + "macro_time_series_output.csv", + ), ) print("Percentage changes in aggregates:", ans) # save percentage change output to csv file - ans.to_csv("ogusa_example_output.csv") + ans.to_csv( + os.path.join( + CUR_DIR, "OG-USA_example_plots_tables", "ogusa_example_output.csv" + ) + ) if __name__ == "__main__": diff --git a/examples/run_og_usa_current_policy_baseline.py b/examples/run_og_usa_current_policy_baseline.py index 00c26180..eda391d5 100644 --- a/examples/run_og_usa_current_policy_baseline.py +++ b/examples/run_og_usa_current_policy_baseline.py @@ -5,6 +5,7 @@ import json import time from taxcalc import Calculator +import matplotlib.pyplot as plt from ogusa.calibrate import Calibration from ogcore.parameters import Specifications from ogcore import output_tables as ot @@ -13,6 +14,14 @@ from ogcore.utils import safe_read_pickle +# Use a custom matplotlib style file for plots +style_file_url = ( + "https://raw.githubusercontent.com/PSLmodels/OG-Core/" + + "master/ogcore/OGcorePlots.mplstyle" +) +plt.style.use(style_file_url) + + def main(): # Define parameters to use for multiprocessing num_workers = min(multiprocessing.cpu_count(), 7) @@ -47,6 +56,7 @@ def main(): ) ) p.tax_func_type = "GS" + p.age_specific = False # get current policy JSON file base_url = ( "github://PSLmodels:Tax-Calculator@master/taxcalc/" @@ -111,6 +121,7 @@ def main(): ) ) p2.tax_func_type = "GS" + p.age_specific = False # Use calibration class to estimate reform tax functions from # Tax-Calculator, specifying reform for Tax-Calculator in iit_reform c2 = Calibration( @@ -168,12 +179,33 @@ def main(): # create plots of output op.plot_all( - base_dir, reform_dir, os.path.join(CUR_DIR, "OG-USA_example_plots") + base_dir, + reform_dir, + os.path.join(CUR_DIR, "OG-USA_current_policy_example_plots_tables"), + ) + # Create CSV file with output + ot.tp_output_dump_table( + base_params, + base_tpi, + reform_params, + reform_tpi, + table_format="csv", + path=os.path.join( + CUR_DIR, + "OG-USA_example_plots_tables", + "macro_time_series_output.csv", + ), ) print("Percentage changes in aggregates:", ans) # save percentage change output to csv file - ans.to_csv("ogusa_example_output.csv") + ans.to_csv( + os.path.join( + CUR_DIR, + "OG-USA_current_policy_example_plots_tables", + "ogusa_example_output.csv", + ) + ) if __name__ == "__main__":