From 609b2c81171a906d2b0c25eb0cd3e16fe26a07ff Mon Sep 17 00:00:00 2001 From: "martin.holmer@gmail.com" Date: Mon, 27 May 2024 17:46:28 -0400 Subject: [PATCH 01/20] Change 2034 to 2074 in parameter files --- taxcalc/consumption.json | 2 +- taxcalc/growdiff.json | 2 +- taxcalc/policy.py | 2 +- taxcalc/policy_current_law.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/taxcalc/consumption.json b/taxcalc/consumption.json index 1b0e4d8e9..415d526e2 100644 --- a/taxcalc/consumption.json +++ b/taxcalc/consumption.json @@ -6,7 +6,7 @@ "validators": { "range": { "min": 2013, - "max": 2034 + "max": 2074 } } }, diff --git a/taxcalc/growdiff.json b/taxcalc/growdiff.json index c8b09ef2a..a200e75e5 100644 --- a/taxcalc/growdiff.json +++ b/taxcalc/growdiff.json @@ -6,7 +6,7 @@ "validators": { "range": { "min": 2013, - "max": 2034 + "max": 2074 } } }, diff --git a/taxcalc/policy.py b/taxcalc/policy.py index c0aefa806..65119de2f 100644 --- a/taxcalc/policy.py +++ b/taxcalc/policy.py @@ -39,7 +39,7 @@ class instance: Policy JSON_START_YEAR = 2013 # remains the same unless earlier data added LAST_KNOWN_YEAR = 2022 # last year for which indexed param vals are known # should increase LAST_KNOWN_YEAR by one every calendar year - LAST_BUDGET_YEAR = 2034 # last extrapolation year + LAST_BUDGET_YEAR = 2074 # last extrapolation year # should increase LAST_BUDGET_YEAR by one every calendar year DEFAULT_NUM_YEARS = LAST_BUDGET_YEAR - JSON_START_YEAR + 1 diff --git a/taxcalc/policy_current_law.json b/taxcalc/policy_current_law.json index c99a152e3..f513681f9 100644 --- a/taxcalc/policy_current_law.json +++ b/taxcalc/policy_current_law.json @@ -6,7 +6,7 @@ "validators": { "range": { "min": 2013, - "max": 2034 + "max": 2074 } } }, From 4a8621651b9f23e546c205d8598dae0ecadfbb6b Mon Sep 17 00:00:00 2001 From: jdebacker Date: Fri, 26 Jul 2024 09:46:38 -0400 Subject: [PATCH 02/20] revert years --- taxcalc.egg-info/SOURCES.txt | 208 +++++++++++++++++++++++++++++++- taxcalc/consumption.json | 2 +- taxcalc/growdiff.json | 2 +- taxcalc/policy.py | 2 +- taxcalc/policy_current_law.json | 2 +- 5 files changed, 211 insertions(+), 5 deletions(-) diff --git a/taxcalc.egg-info/SOURCES.txt b/taxcalc.egg-info/SOURCES.txt index b9685d567..270ae666f 100644 --- a/taxcalc.egg-info/SOURCES.txt +++ b/taxcalc.egg-info/SOURCES.txt @@ -1,7 +1,104 @@ +.coveragerc +.gitignore LICENSE MANIFEST.in +Makefile +PSL_catalog.json README.md +codecov.yml +csv_show.sh +csv_vars.sh +environment.yml +extend_tcja.py +gitpr +gitpr.bat +gitsync +gitsync.bat +ppp.py +pytest.ini setup.py +tctest-nojit.sh +.github/FUNDING.yml +.github/workflows/build_and_test.yml +.github/workflows/check_jupyterbook.yml +.github/workflows/deploy_jupyterbook.yml +.github/workflows/deploy_parameters_docs.yml +conda.recipe/bld.bat +conda.recipe/build.sh +conda.recipe/meta.yaml +docs/PSL.svg +docs/_config.yml +docs/_toc.yml +docs/index.md +docs/use_cases.md +docs/_static/atr.png +docs/_static/mtr.png +docs/_static/pch.png +docs/about/LICENSE.md +docs/about/history.md +docs/about/releases.md +docs/about/roadmap.md +docs/api/calcfunctions.rst +docs/api/calculator.rst +docs/api/consumption.rst +docs/api/data.rst +docs/api/decorators.rst +docs/api/growdiff.rst +docs/api/growfactors.rst +docs/api/parameters.rst +docs/api/policy.rst +docs/api/public_api.rst +docs/api/records.rst +docs/api/taxcalcio.rst +docs/api/utils.rst +docs/api/utilsprvt.rst +docs/contributing/RELEASING.md +docs/contributing/contributor_guide.md +docs/contributing/dependencies.md +docs/contributing/param_naming.md +docs/contributing/pr_workflow.md +docs/contributing/testing.md +docs/guide/README.md +docs/guide/assumption_params.md +docs/guide/cli.md +docs/guide/index.md +docs/guide/input_vars.md +docs/guide/output_vars.md +docs/guide/policy_params.md +docs/guide/python_interface.md +docs/guide/make/make_io_vars.py +docs/guide/make/make_params.py +docs/guide/make/make_uguide.py +docs/guide/templates/assumption_params_template.md +docs/guide/templates/input_vars_template.md +docs/guide/templates/output_vars_template.md +docs/guide/templates/policy_params_template.md +docs/recipes/README.md +docs/recipes/convert_all.sh +docs/recipes/index.md +docs/recipes/recipe00.ipynb +docs/recipes/recipe01.ipynb +docs/recipes/recipe02.ipynb +docs/recipes/recipe03.ipynb +docs/recipes/recipe04.ipynb +docs/recipes/recipe04_pandas.ipynb +docs/recipes/recipe05.ipynb +docs/recipes/recipe06.ipynb +docs/recipes/_static/reformA.json +docs/recipes/_static/reformB.json +docs/recipes/_static/reformC.json +docs/recipes/md_src/recipe00.md +docs/recipes/md_src/recipe01.md +docs/recipes/md_src/recipe02.md +docs/recipes/md_src/recipe03.md +docs/recipes/md_src/recipe04.md +docs/recipes/md_src/recipe04_pandas.md +docs/recipes/md_src/recipe05.md +docs/recipes/md_src/recipe06.md +docs/usage/data.md +docs/usage/overview.md +docs/usage/starting.md +docs/usage/tcja_after_2025.md taxcalc/__init__.py taxcalc/calcfunctions.py taxcalc/calculator.py @@ -34,5 +131,114 @@ taxcalc.egg-info/dependency_links.txt taxcalc.egg-info/entry_points.txt taxcalc.egg-info/requires.txt taxcalc.egg-info/top_level.txt +taxcalc/assumptions/ASSUMPTIONS.md +taxcalc/assumptions/README.md +taxcalc/assumptions/economic_assumptions_template.json taxcalc/cli/__init__.py -taxcalc/cli/tc.py \ No newline at end of file +taxcalc/cli/tc.py +taxcalc/reforms/2017_law.json +taxcalc/reforms/2017_law.out.csv +taxcalc/reforms/ARPA.json +taxcalc/reforms/ARPA.out.csv +taxcalc/reforms/BrownKhanna.json +taxcalc/reforms/BrownKhanna.out.csv +taxcalc/reforms/CARES.json +taxcalc/reforms/CARES.out.csv +taxcalc/reforms/ConsolidatedAppropriationsAct2021.json +taxcalc/reforms/ConsolidatedAppropriationsAct2021.out.csv +taxcalc/reforms/Larson2019.json +taxcalc/reforms/Larson2019.out.csv +taxcalc/reforms/README.md +taxcalc/reforms/REFORMS.md +taxcalc/reforms/Renacci.json +taxcalc/reforms/Renacci.out.csv +taxcalc/reforms/SandersDeFazio.json +taxcalc/reforms/SandersDeFazio.out.csv +taxcalc/reforms/TCJA.json +taxcalc/reforms/TCJA.md +taxcalc/reforms/TCJA.out.csv +taxcalc/reforms/Trump2016.json +taxcalc/reforms/Trump2016.out.csv +taxcalc/reforms/Trump2017.json +taxcalc/reforms/Trump2017.out.csv +taxcalc/reforms/cases.csv +taxcalc/reforms/clp.out.csv +taxcalc/reforms/ext.json +taxcalc/reforms/ptaxes0.json +taxcalc/reforms/ptaxes0.out.csv +taxcalc/reforms/ptaxes1.json +taxcalc/reforms/ptaxes1.out.csv +taxcalc/reforms/ptaxes2.json +taxcalc/reforms/ptaxes2.out.csv +taxcalc/reforms/ptaxes3.json +taxcalc/reforms/ptaxes3.out.csv +taxcalc/reforms/rounding2022.json +taxcalc/reforms/rounding2022.out.csv +taxcalc/reforms/archive/Clinton2016.json +taxcalc/reforms/archive/RyanBrady.json +taxcalc/reforms/archive/TCJA_House.json +taxcalc/reforms/archive/TCJA_House_Amended.json +taxcalc/reforms/archive/TCJA_Reconciliation.json +taxcalc/reforms/archive/TCJA_Senate.json +taxcalc/reforms/archive/TCJA_Senate_111417.json +taxcalc/reforms/archive/TCJA_Senate_120117.json +taxcalc/tests/benefits_expect.csv +taxcalc/tests/cmpi_cps_expect.txt +taxcalc/tests/cmpi_puf_expect.txt +taxcalc/tests/conftest.py +taxcalc/tests/cpscsv_agg_expect.csv +taxcalc/tests/puf_var_correl_coeffs_2016.csv +taxcalc/tests/puf_var_wght_means_by_year.csv +taxcalc/tests/pufcsv_agg_expect.csv +taxcalc/tests/pufcsv_mtr_expect.txt +taxcalc/tests/reforms.json +taxcalc/tests/reforms_expect.csv +taxcalc/tests/test_4package.py +taxcalc/tests/test_benefits.py +taxcalc/tests/test_calcfunctions.py +taxcalc/tests/test_calculator.py +taxcalc/tests/test_compare.py +taxcalc/tests/test_compatible_data.py +taxcalc/tests/test_consumption.py +taxcalc/tests/test_cpscsv.py +taxcalc/tests/test_data.py +taxcalc/tests/test_decorators.py +taxcalc/tests/test_growdiff.py +taxcalc/tests/test_growfactors.py +taxcalc/tests/test_parameters.py +taxcalc/tests/test_policy.py +taxcalc/tests/test_puf_var_stats.py +taxcalc/tests/test_pufcsv.py +taxcalc/tests/test_records.py +taxcalc/tests/test_reforms.py +taxcalc/tests/test_responses.py +taxcalc/tests/test_taxcalcio.py +taxcalc/tests/test_tmdcsv.py +taxcalc/tests/test_utils.py +taxcalc/validation/CSV_INPUT_VARS.md +taxcalc/validation/CSV_OUTPUT_VARS.md +taxcalc/validation/README.md +taxcalc/validation/tests_35.sh +taxcalc/validation/taxsim35/Differences_Explained.md +taxcalc/validation/taxsim35/README.md +taxcalc/validation/taxsim35/input_setup.py +taxcalc/validation/taxsim35/main_comparison.py +taxcalc/validation/taxsim35/prepare_taxcalc_input.py +taxcalc/validation/taxsim35/process_taxcalc_output.py +taxcalc/validation/taxsim35/taxsim_emulation.json +taxcalc/validation/taxsim35/taxsim_input.py +taxcalc/validation/taxsim35/tc_sims.py +taxcalc/validation/taxsim35/tests_35.py +taxcalc/validation/taxsim35/expected_differences/a17-taxdiffs-expect.csv +taxcalc/validation/taxsim35/expected_differences/a18-taxdiffs-expect.csv +taxcalc/validation/taxsim35/expected_differences/a19-taxdiffs-expect.csv +taxcalc/validation/taxsim35/expected_differences/a20-taxdiffs-expect.csv +taxcalc/validation/taxsim35/expected_differences/a21-taxdiffs-expect.csv +taxcalc/validation/taxsim35/expected_differences/b17-taxdiffs-expect.csv +taxcalc/validation/taxsim35/expected_differences/b18-taxdiffs-expect.csv +taxcalc/validation/taxsim35/expected_differences/b19-taxdiffs-expect.csv +taxcalc/validation/taxsim35/expected_differences/b20-taxdiffs-expect.csv +taxcalc/validation/taxsim35/expected_differences/b21-taxdiffs-expect.csv +taxcalc/validation/taxsim35/expected_differences/c17-taxdiffs-expect.csv +taxcalc/validation/taxsim35/expected_differences/c18-taxdiffs-expect.csv +taxcalc/validation/taxsim35/expected_differences/c19-taxdiffs-expect.csv \ No newline at end of file diff --git a/taxcalc/consumption.json b/taxcalc/consumption.json index 415d526e2..1b0e4d8e9 100644 --- a/taxcalc/consumption.json +++ b/taxcalc/consumption.json @@ -6,7 +6,7 @@ "validators": { "range": { "min": 2013, - "max": 2074 + "max": 2034 } } }, diff --git a/taxcalc/growdiff.json b/taxcalc/growdiff.json index a200e75e5..c8b09ef2a 100644 --- a/taxcalc/growdiff.json +++ b/taxcalc/growdiff.json @@ -6,7 +6,7 @@ "validators": { "range": { "min": 2013, - "max": 2074 + "max": 2034 } } }, diff --git a/taxcalc/policy.py b/taxcalc/policy.py index 65119de2f..c0aefa806 100644 --- a/taxcalc/policy.py +++ b/taxcalc/policy.py @@ -39,7 +39,7 @@ class instance: Policy JSON_START_YEAR = 2013 # remains the same unless earlier data added LAST_KNOWN_YEAR = 2022 # last year for which indexed param vals are known # should increase LAST_KNOWN_YEAR by one every calendar year - LAST_BUDGET_YEAR = 2074 # last extrapolation year + LAST_BUDGET_YEAR = 2034 # last extrapolation year # should increase LAST_BUDGET_YEAR by one every calendar year DEFAULT_NUM_YEARS = LAST_BUDGET_YEAR - JSON_START_YEAR + 1 diff --git a/taxcalc/policy_current_law.json b/taxcalc/policy_current_law.json index 28d5feb18..68117a77f 100644 --- a/taxcalc/policy_current_law.json +++ b/taxcalc/policy_current_law.json @@ -6,7 +6,7 @@ "validators": { "range": { "min": 2013, - "max": 2074 + "max": 2034 } } }, From ed2ace3cdb3a8d05d6ec4476c53d07732a0a8c03 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Tue, 30 Jul 2024 00:28:47 -0400 Subject: [PATCH 03/20] trying new param tools --- taxcalc.egg-info/PKG-INFO | 7 +++++++ taxcalc/parameters.py | 8 ++++++++ taxcalc/policy.py | 18 +++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/taxcalc.egg-info/PKG-INFO b/taxcalc.egg-info/PKG-INFO index 53bab738d..49fb2cacb 100644 --- a/taxcalc.egg-info/PKG-INFO +++ b/taxcalc.egg-info/PKG-INFO @@ -19,6 +19,13 @@ Classifier: Programming Language :: Python :: 3.12 Classifier: Topic :: Software Development :: Libraries :: Python Modules Description-Content-Type: text/markdown License-File: LICENSE +Requires-Dist: setuptools +Requires-Dist: numpy +Requires-Dist: pandas +Requires-Dist: bokeh +Requires-Dist: numba +Requires-Dist: requests +Requires-Dist: paramtools | | | | --- | --- | diff --git a/taxcalc/parameters.py b/taxcalc/parameters.py index 8ebbf04cb..d3eac686f 100644 --- a/taxcalc/parameters.py +++ b/taxcalc/parameters.py @@ -102,6 +102,14 @@ def __init__(self, start_year=None, num_years=None, last_known_year=None, self.DEFAULTS_FILE_NAME ) + # def get_defaults(self): + """ + Method to allow for the defaults to be modified. + """ + label = self.default["schema"]["labels"]["year"] + label["validators"]["range"]["max"] = 2074#year_to_extend + return self.defaults + if last_known_year is None: self._last_known_year = start_year else: diff --git a/taxcalc/policy.py b/taxcalc/policy.py index c0aefa806..04d1ba527 100644 --- a/taxcalc/policy.py +++ b/taxcalc/policy.py @@ -39,7 +39,7 @@ class instance: Policy JSON_START_YEAR = 2013 # remains the same unless earlier data added LAST_KNOWN_YEAR = 2022 # last year for which indexed param vals are known # should increase LAST_KNOWN_YEAR by one every calendar year - LAST_BUDGET_YEAR = 2034 # last extrapolation year + LAST_BUDGET_YEAR = 2074 # last extrapolation year # should increase LAST_BUDGET_YEAR by one every calendar year DEFAULT_NUM_YEARS = LAST_BUDGET_YEAR - JSON_START_YEAR + 1 @@ -83,6 +83,8 @@ class instance: Policy def __init__(self, gfactors=None, only_reading_defaults=False, **kwargs): # put JSON contents of DEFAULTS_FILE_NAME into self._vals dictionary super().__init__() + # print(self.__dict__) + # self._vals["schema"]["labels"]["year"]["validators"]["range"]["max"] = 2074 # handle gfactors argument if gfactors is None: self._gfactors = GrowFactors() @@ -100,6 +102,20 @@ def __init__(self, gfactors=None, only_reading_defaults=False, **kwargs): Policy.REMOVED_PARAMS, Policy.REDEFINED_PARAMS, Policy.WAGE_INDEXED_PARAMS, **kwargs) + print("Defaults = ", self.defaults) + # json_params = self.get_defaults() + # label = json_params["schema"]["labels"]["year"] + # label["validators"]["range"]["max"] = 2074 + # return self.defaults + # json_params["schema"]["labels"]["year"]["validators"]["range"]["max"] = 2074 + # self.defaults = json_params + self.initialize(syr, nyrs, Policy.LAST_KNOWN_YEAR, + Policy.REMOVED_PARAMS, + Policy.REDEFINED_PARAMS, + Policy.WAGE_INDEXED_PARAMS, **kwargs) + # quit() + print("Num years = ", nyrs) + # self.defaults = self.get_defaults() @staticmethod def read_json_reform(obj): From f7611594dc7c7b6c90254196cc82e4de7d4c05a6 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Fri, 22 Nov 2024 21:40:29 -0500 Subject: [PATCH 04/20] allow flexible budget year end year --- taxcalc/calculator.py | 2 +- taxcalc/consumption.py | 8 +++++--- taxcalc/growdiff.py | 10 +++++++--- taxcalc/parameters.py | 22 ++++++++++++---------- taxcalc/policy.py | 29 ++++++----------------------- 5 files changed, 31 insertions(+), 40 deletions(-) diff --git a/taxcalc/calculator.py b/taxcalc/calculator.py index d0b92a598..14129d585 100644 --- a/taxcalc/calculator.py +++ b/taxcalc/calculator.py @@ -105,7 +105,7 @@ def __init__(self, policy=None, records=None, verbose=False, if self.__policy.current_year < self.__records.data_year: self.__policy.set_year(self.__records.data_year) if consumption is None: - self.__consumption = Consumption() + self.__consumption = Consumption(policy.nyrs) elif isinstance(consumption, Consumption): self.__consumption = copy.deepcopy(consumption) else: diff --git a/taxcalc/consumption.py b/taxcalc/consumption.py index 0be9ea904..bfc12b4e1 100644 --- a/taxcalc/consumption.py +++ b/taxcalc/consumption.py @@ -28,14 +28,16 @@ class instance: Consumption """ JSON_START_YEAR = Policy.JSON_START_YEAR - DEFAULT_NUM_YEARS = Policy.DEFAULT_NUM_YEARS + NUM_YEARS = Policy.NUM_YEARS DEFAULTS_FILE_NAME = 'consumption.json' DEFAULTS_FILE_PATH = os.path.abspath(os.path.dirname(__file__)) - def __init__(self): + def __init__(self, nyrs=NUM_YEARS): + # put JSON contents of DEFAULTS_FILE_NAME into self._vals dictionary super().__init__() + print("Consumption num years = ", nyrs) self.initialize(Consumption.JSON_START_YEAR, - Consumption.DEFAULT_NUM_YEARS) + nyrs) @staticmethod def read_json_update(obj): diff --git a/taxcalc/growdiff.py b/taxcalc/growdiff.py index e4cc4ac9e..8f45d6727 100644 --- a/taxcalc/growdiff.py +++ b/taxcalc/growdiff.py @@ -28,14 +28,18 @@ class instance: GrowDiff """ JSON_START_YEAR = Policy.JSON_START_YEAR - DEFAULT_NUM_YEARS = Policy.DEFAULT_NUM_YEARS + NUM_YEARS = Policy.NUM_YEARS DEFAULTS_FILE_NAME = 'growdiff.json' DEFAULTS_FILE_PATH = os.path.abspath(os.path.dirname(__file__)) - def __init__(self): + def __init__(self, nyrs=NUM_YEARS): + # Update defaults to user defined budget window + self.defaults = super().get_defaults() + label = self.defaults["schema"]["labels"]["year"] + label["validators"]["range"]["max"] = GrowDiff.JSON_START_YEAR + nyrs - 1 super().__init__() self.initialize(GrowDiff.JSON_START_YEAR, - GrowDiff.DEFAULT_NUM_YEARS) + nyrs) @staticmethod def read_json_update(obj, topkey): diff --git a/taxcalc/parameters.py b/taxcalc/parameters.py index d3eac686f..f4e3d1b85 100644 --- a/taxcalc/parameters.py +++ b/taxcalc/parameters.py @@ -102,19 +102,12 @@ def __init__(self, start_year=None, num_years=None, last_known_year=None, self.DEFAULTS_FILE_NAME ) - # def get_defaults(self): - """ - Method to allow for the defaults to be modified. - """ - label = self.default["schema"]["labels"]["year"] - label["validators"]["range"]["max"] = 2074#year_to_extend - return self.defaults - + last_budget_year = start_year + num_years - 1 if last_known_year is None: self._last_known_year = start_year else: assert last_known_year >= start_year - assert last_known_year <= self.LAST_BUDGET_YEAR + assert last_known_year <= last_budget_year self._last_known_year = last_known_year self._removed_params = removed or self.REMOVED_PARAMS @@ -129,8 +122,17 @@ def __init__(self, start_year=None, num_years=None, last_known_year=None, kwargs["initial_state"] = { "year": start_year or self.JSON_START_YEAR } + # Update defaults to user defined budget window + self.defaults = super().get_defaults() + label = self.defaults["schema"]["labels"]["year"] + label["validators"]["range"]["max"] = start_year + num_years - 1 super().__init__(**kwargs) + # def get_defaults(self): + # label = self.defaults["schema"]["labels"]["year"] + # label["validators"]["range"]["max"] = 2074 + # return self.defaults + def adjust( self, params_or_path, print_warnings=True, raise_errors=True, **kwargs ): @@ -827,4 +829,4 @@ def is_paramtools_format(params: Union[TaxcalcReform, ParamToolsAdjustment]): else: # Not doing a specific check to see if the value is a list # since it could be a list or just a scalar value. - return True + return True \ No newline at end of file diff --git a/taxcalc/policy.py b/taxcalc/policy.py index 435f3c3c1..4a8279417 100644 --- a/taxcalc/policy.py +++ b/taxcalc/policy.py @@ -40,9 +40,8 @@ class instance: Policy JSON_START_YEAR = 2013 # remains the same unless earlier data added LAST_KNOWN_YEAR = 2025 # last year for which indexed param vals are known # should increase LAST_KNOWN_YEAR by one every calendar year - LAST_BUDGET_YEAR = 2074 # last extrapolation year - # should increase LAST_BUDGET_YEAR by one every calendar year - DEFAULT_NUM_YEARS = LAST_BUDGET_YEAR - JSON_START_YEAR + 1 + DEFAULT_LAST_BUDGET_YEAR = 2034 # last extrapolation year + NUM_YEARS = DEFAULT_LAST_BUDGET_YEAR - JSON_START_YEAR + 1 # NOTE: the following three data structures use internal parameter names: # (1) specify which Policy parameters have been removed or renamed @@ -81,11 +80,9 @@ class instance: Policy # (3) specify which Policy parameters are wage (rather than price) indexed WAGE_INDEXED_PARAMS = ['SS_Earnings_c', 'SS_Earnings_thd'] - def __init__(self, gfactors=None, **kwargs): + def __init__(self, gfactors=None, last_budget_year=DEFAULT_LAST_BUDGET_YEAR, **kwargs): # put JSON contents of DEFAULTS_FILE_NAME into self._vals dictionary super().__init__() - # print(self.__dict__) - # self._vals["schema"]["labels"]["year"]["validators"]["range"]["max"] = 2074 # handle gfactors argument if gfactors is None: self._gfactors = GrowFactors() @@ -95,27 +92,13 @@ def __init__(self, gfactors=None, **kwargs): raise ValueError('gfactors is not None or a GrowFactors instance') # read default parameters and initialize syr = Policy.JSON_START_YEAR - nyrs = Policy.DEFAULT_NUM_YEARS + self.nyrs = last_budget_year - syr + 1 self._inflation_rates = None self._wage_growth_rates = None - self.initialize(syr, nyrs, Policy.LAST_KNOWN_YEAR, + self.initialize(syr, self.nyrs, Policy.LAST_KNOWN_YEAR, Policy.REMOVED_PARAMS, Policy.REDEFINED_PARAMS, Policy.WAGE_INDEXED_PARAMS, **kwargs) - print("Defaults = ", self.defaults) - # json_params = self.get_defaults() - # label = json_params["schema"]["labels"]["year"] - # label["validators"]["range"]["max"] = 2074 - # return self.defaults - # json_params["schema"]["labels"]["year"]["validators"]["range"]["max"] = 2074 - # self.defaults = json_params - self.initialize(syr, nyrs, Policy.LAST_KNOWN_YEAR, - Policy.REMOVED_PARAMS, - Policy.REDEFINED_PARAMS, - Policy.WAGE_INDEXED_PARAMS, **kwargs) - # quit() - print("Num years = ", nyrs) - # self.defaults = self.get_defaults() @staticmethod def tmd_constructor(growfactors_path): # pragma: no cover @@ -191,4 +174,4 @@ def set_rates(self): self._wage_growth_rates = self._gfactors.wage_growth_rates( self.start_year, self.end_year - ) + ) \ No newline at end of file From 0e57edd992fe03d820e2ce123e56834cba3c8ad2 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Sun, 24 Nov 2024 10:12:53 -0500 Subject: [PATCH 05/20] clean up print command --- taxcalc/consumption.py | 1 - 1 file changed, 1 deletion(-) diff --git a/taxcalc/consumption.py b/taxcalc/consumption.py index bfc12b4e1..232a53754 100644 --- a/taxcalc/consumption.py +++ b/taxcalc/consumption.py @@ -35,7 +35,6 @@ class instance: Consumption def __init__(self, nyrs=NUM_YEARS): # put JSON contents of DEFAULTS_FILE_NAME into self._vals dictionary super().__init__() - print("Consumption num years = ", nyrs) self.initialize(Consumption.JSON_START_YEAR, nyrs) From 259cf72acedebd68e3a5cccc7685cdfe053037cf Mon Sep 17 00:00:00 2001 From: jdebacker Date: Mon, 25 Nov 2024 20:07:59 -0500 Subject: [PATCH 06/20] consistent num years --- taxcalc.egg-info/PKG-INFO | 7 ------- taxcalc.egg-info/SOURCES.txt | 7 ++++++- taxcalc/calculator.py | 2 +- taxcalc/growdiff.py | 5 ----- taxcalc/parameters.py | 11 +++-------- taxcalc/policy.py | 5 +++-- taxcalc/tests/test_calculator.py | 8 ++++---- taxcalc/tests/test_growdiff.py | 2 +- taxcalc/tests/test_policy.py | 2 +- 9 files changed, 19 insertions(+), 30 deletions(-) diff --git a/taxcalc.egg-info/PKG-INFO b/taxcalc.egg-info/PKG-INFO index 4841fd28a..9cca249d7 100644 --- a/taxcalc.egg-info/PKG-INFO +++ b/taxcalc.egg-info/PKG-INFO @@ -18,13 +18,6 @@ Classifier: Programming Language :: Python :: 3.12 Classifier: Topic :: Software Development :: Libraries :: Python Modules Description-Content-Type: text/markdown License-File: LICENSE -Requires-Dist: setuptools -Requires-Dist: numpy -Requires-Dist: pandas -Requires-Dist: bokeh -Requires-Dist: numba -Requires-Dist: requests -Requires-Dist: paramtools>=0.18.3 | | | | --- | --- | diff --git a/taxcalc.egg-info/SOURCES.txt b/taxcalc.egg-info/SOURCES.txt index 6937d2e4c..312f71696 100644 --- a/taxcalc.egg-info/SOURCES.txt +++ b/taxcalc.egg-info/SOURCES.txt @@ -18,6 +18,7 @@ ppp.py pytest.ini setup.py tctest-nojit.sh +update_pcl.py .github/FUNDING.yml .github/workflows/build_and_test.yml .github/workflows/check_jupyterbook.yml @@ -171,6 +172,8 @@ taxcalc/reforms/ptaxes2.json taxcalc/reforms/ptaxes2.out.csv taxcalc/reforms/ptaxes3.json taxcalc/reforms/ptaxes3.out.csv +taxcalc/reforms/rounding.json +taxcalc/reforms/rounding.out.csv taxcalc/reforms/archive/Clinton2016.json taxcalc/reforms/archive/RyanBrady.json taxcalc/reforms/archive/TCJA_House.json @@ -237,4 +240,6 @@ taxcalc/validation/taxsim35/expected_differences/b20-taxdiffs-expect.csv taxcalc/validation/taxsim35/expected_differences/b21-taxdiffs-expect.csv taxcalc/validation/taxsim35/expected_differences/c17-taxdiffs-expect.csv taxcalc/validation/taxsim35/expected_differences/c18-taxdiffs-expect.csv -taxcalc/validation/taxsim35/expected_differences/c19-taxdiffs-expect.csv \ No newline at end of file +taxcalc/validation/taxsim35/expected_differences/c19-taxdiffs-expect.csv +taxcalc/validation/taxsim35/expected_differences/c20-taxdiffs-expect.csv +taxcalc/validation/taxsim35/expected_differences/c21-taxdiffs-expect.csv \ No newline at end of file diff --git a/taxcalc/calculator.py b/taxcalc/calculator.py index 14129d585..b386253a2 100644 --- a/taxcalc/calculator.py +++ b/taxcalc/calculator.py @@ -105,7 +105,7 @@ def __init__(self, policy=None, records=None, verbose=False, if self.__policy.current_year < self.__records.data_year: self.__policy.set_year(self.__records.data_year) if consumption is None: - self.__consumption = Consumption(policy.nyrs) + self.__consumption = Consumption(policy.NUM_YEARS) elif isinstance(consumption, Consumption): self.__consumption = copy.deepcopy(consumption) else: diff --git a/taxcalc/growdiff.py b/taxcalc/growdiff.py index 8f45d6727..c1489659a 100644 --- a/taxcalc/growdiff.py +++ b/taxcalc/growdiff.py @@ -33,11 +33,6 @@ class instance: GrowDiff DEFAULTS_FILE_PATH = os.path.abspath(os.path.dirname(__file__)) def __init__(self, nyrs=NUM_YEARS): - # Update defaults to user defined budget window - self.defaults = super().get_defaults() - label = self.defaults["schema"]["labels"]["year"] - label["validators"]["range"]["max"] = GrowDiff.JSON_START_YEAR + nyrs - 1 - super().__init__() self.initialize(GrowDiff.JSON_START_YEAR, nyrs) diff --git a/taxcalc/parameters.py b/taxcalc/parameters.py index f4e3d1b85..2b8c4a326 100644 --- a/taxcalc/parameters.py +++ b/taxcalc/parameters.py @@ -102,12 +102,12 @@ def __init__(self, start_year=None, num_years=None, last_known_year=None, self.DEFAULTS_FILE_NAME ) - last_budget_year = start_year + num_years - 1 + self.LAST_BUDGET_YEAR = start_year + num_years - 1 if last_known_year is None: self._last_known_year = start_year else: assert last_known_year >= start_year - assert last_known_year <= last_budget_year + assert last_known_year <= self.LAST_BUDGET_YEAR self._last_known_year = last_known_year self._removed_params = removed or self.REMOVED_PARAMS @@ -125,14 +125,9 @@ def __init__(self, start_year=None, num_years=None, last_known_year=None, # Update defaults to user defined budget window self.defaults = super().get_defaults() label = self.defaults["schema"]["labels"]["year"] - label["validators"]["range"]["max"] = start_year + num_years - 1 + label["validators"]["range"]["max"] = self.LAST_BUDGET_YEAR super().__init__(**kwargs) - # def get_defaults(self): - # label = self.defaults["schema"]["labels"]["year"] - # label["validators"]["range"]["max"] = 2074 - # return self.defaults - def adjust( self, params_or_path, print_warnings=True, raise_errors=True, **kwargs ): diff --git a/taxcalc/policy.py b/taxcalc/policy.py index 4a8279417..2f22e5799 100644 --- a/taxcalc/policy.py +++ b/taxcalc/policy.py @@ -92,10 +92,11 @@ def __init__(self, gfactors=None, last_budget_year=DEFAULT_LAST_BUDGET_YEAR, ** raise ValueError('gfactors is not None or a GrowFactors instance') # read default parameters and initialize syr = Policy.JSON_START_YEAR - self.nyrs = last_budget_year - syr + 1 + nyrs = last_budget_year - syr + 1 + Policy.NUM_YEARS = nyrs self._inflation_rates = None self._wage_growth_rates = None - self.initialize(syr, self.nyrs, Policy.LAST_KNOWN_YEAR, + self.initialize(syr, nyrs, Policy.LAST_KNOWN_YEAR, Policy.REMOVED_PARAMS, Policy.REDEFINED_PARAMS, Policy.WAGE_INDEXED_PARAMS, **kwargs) diff --git a/taxcalc/tests/test_calculator.py b/taxcalc/tests/test_calculator.py index c9f2cb743..eb3fc635e 100644 --- a/taxcalc/tests/test_calculator.py +++ b/taxcalc/tests/test_calculator.py @@ -74,9 +74,9 @@ def test_make_calculator_with_policy_reform(cps_subsample): assert calc.current_year == year assert calc.policy_param('II_em') == 4000 assert np.allclose(calc.policy_param('_II_em'), - np.array([4000] * Policy.DEFAULT_NUM_YEARS)) + np.array([4000] * Policy.NUM_YEARS)) exp_STD_Aged = [[1600, 1300, 1300, - 1600, 1600]] * Policy.DEFAULT_NUM_YEARS + 1600, 1600]] * Policy.NUM_YEARS assert np.allclose(calc.policy_param('_STD_Aged'), np.array(exp_STD_Aged)) assert np.allclose(calc.policy_param('STD_Aged'), @@ -100,10 +100,10 @@ def test_make_calculator_with_multiyear_reform(cps_subsample): # create a Calculator object using this policy-reform calc = Calculator(policy=pol, records=rec) # check that Policy object embedded in Calculator object is correct - assert pol.num_years == Policy.DEFAULT_NUM_YEARS + assert pol.num_years == Policy.NUM_YEARS assert calc.current_year == year assert calc.policy_param('II_em') == 3950 - exp_II_em = [3900, 3950, 5000] + [6000] * (Policy.DEFAULT_NUM_YEARS - 3) + exp_II_em = [3900, 3950, 5000] + [6000] * (Policy.NUM_YEARS - 3) assert np.allclose(calc.policy_param('_II_em'), np.array(exp_II_em)) calc.increment_year() diff --git a/taxcalc/tests/test_growdiff.py b/taxcalc/tests/test_growdiff.py index 74bd49db5..c1620197a 100644 --- a/taxcalc/tests/test_growdiff.py +++ b/taxcalc/tests/test_growdiff.py @@ -10,7 +10,7 @@ def test_year_consistency(): assert GrowDiff.JSON_START_YEAR == Policy.JSON_START_YEAR - assert GrowDiff.DEFAULT_NUM_YEARS == Policy.DEFAULT_NUM_YEARS + assert GrowDiff.NUM_YEARS == Policy.NUM_YEARS def test_update_and_apply_growdiff(): diff --git a/taxcalc/tests/test_policy.py b/taxcalc/tests/test_policy.py index 41ba8db3e..dddf12b79 100644 --- a/taxcalc/tests/test_policy.py +++ b/taxcalc/tests/test_policy.py @@ -248,7 +248,7 @@ def test_multi_year_reform(): """ # specify dimensions of policy Policy object syr = Policy.JSON_START_YEAR - nyrs = Policy.DEFAULT_NUM_YEARS + nyrs = Policy.NUM_YEARS pol = Policy() iratelist = pol.inflation_rates() ifactor = {} From 4340ef9430d616e81632deedfb85abf680df3b56 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Tue, 26 Nov 2024 09:34:04 -0500 Subject: [PATCH 07/20] update default num years name --- taxcalc/tests/test_consumption.py | 10 +++++----- taxcalc/tests/test_growdiff.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/taxcalc/tests/test_consumption.py b/taxcalc/tests/test_consumption.py index eaaa24831..e7cefd767 100644 --- a/taxcalc/tests/test_consumption.py +++ b/taxcalc/tests/test_consumption.py @@ -10,7 +10,7 @@ def test_year_consistency(): assert Consumption.JSON_START_YEAR == Policy.JSON_START_YEAR - assert Consumption.DEFAULT_NUM_YEARS == Policy.DEFAULT_NUM_YEARS + assert Consumption.NUM_YEARS == Policy.NUM_YEARS def test_validity_of_consumption_vars_set(): @@ -31,23 +31,23 @@ def test_update_consumption(): 2015: 0.80} } consump.update_consumption(revision) - expected_mpc_e20400 = np.full((Consumption.DEFAULT_NUM_YEARS,), 0.06) + expected_mpc_e20400 = np.full((Consumption.NUM_YEARS,), 0.06) expected_mpc_e20400[0] = 0.0 expected_mpc_e20400[1] = 0.05 assert np.allclose(consump._MPC_e20400, expected_mpc_e20400, rtol=0.0) assert np.allclose(consump._MPC_e17500, - np.zeros((Consumption.DEFAULT_NUM_YEARS,)), + np.zeros((Consumption.NUM_YEARS,)), rtol=0.0) - expected_ben_mcare_value = np.full((Consumption.DEFAULT_NUM_YEARS,), 0.80) + expected_ben_mcare_value = np.full((Consumption.NUM_YEARS,), 0.80) expected_ben_mcare_value[0] = 1.0 expected_ben_mcare_value[1] = 0.75 assert np.allclose(consump._BEN_mcare_value, expected_ben_mcare_value, rtol=0.0) assert np.allclose(consump._BEN_snap_value, - np.ones((Consumption.DEFAULT_NUM_YEARS,)), + np.ones((Consumption.NUM_YEARS,)), rtol=0.0) consump.set_year(2015) assert consump.current_year == 2015 diff --git a/taxcalc/tests/test_growdiff.py b/taxcalc/tests/test_growdiff.py index c1620197a..9b504c47c 100644 --- a/taxcalc/tests/test_growdiff.py +++ b/taxcalc/tests/test_growdiff.py @@ -22,13 +22,13 @@ def test_update_and_apply_growdiff(): } gdiff.update_growdiff(diffs) expected_wage_diffs = [0.00, 0.01, 0.01, 0.02, 0.02] - extra_years = GrowDiff.DEFAULT_NUM_YEARS - len(expected_wage_diffs) + extra_years = GrowDiff.NUM_YEARS - len(expected_wage_diffs) expected_wage_diffs.extend([0.02] * extra_years) assert np.allclose(gdiff._AWAGE, expected_wage_diffs, atol=0.0, rtol=0.0) # apply growdiff to GrowFactors instance gf = GrowFactors() syr = GrowDiff.JSON_START_YEAR - nyrs = GrowDiff.DEFAULT_NUM_YEARS + nyrs = GrowDiff.NUM_YEARS lyr = syr + nyrs - 1 pir_pre = gf.price_inflation_rates(syr, lyr) wgr_pre = gf.wage_growth_rates(syr, lyr) From 826592634cd684f7a3edf8d05711803135a99553 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Thu, 28 Nov 2024 17:37:11 -0500 Subject: [PATCH 08/20] pt 19 --- environment.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/environment.yml b/environment.yml index 8032c1e8d..3d0b1983c 100644 --- a/environment.yml +++ b/environment.yml @@ -3,7 +3,7 @@ channels: - conda-forge dependencies: - "python>=3.10, <3.13" -- "numpy>=1.26,<1.27" +- "numpy>=1.26" - "pandas>=2.2" - "bokeh>=2.4" - numba @@ -18,4 +18,4 @@ dependencies: - pip - pip: - jupyter-book - - "paramtools>=0.18.3" + - "paramtools>=0.19.0" From 828e932b936fc44a768ea0a449091b42406ef0d3 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Thu, 28 Nov 2024 19:20:16 -0500 Subject: [PATCH 09/20] consistency in meta.yaml --- conda.recipe/meta.yaml | 4 ++-- taxcalc.egg-info/PKG-INFO | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml index d618a778f..7abe02338 100755 --- a/conda.recipe/meta.yaml +++ b/conda.recipe/meta.yaml @@ -9,10 +9,10 @@ build: requirements: build: - "python>=3.10, <3.13" - - "numpy>=1.26,<1.27" + - "numpy>=1.26" - "pandas>=2.2" - "bokeh>=2.4" - - "paramtools>=0.18.3" + - "paramtools>=0.19.0" - numba - curl - openpyxl diff --git a/taxcalc.egg-info/PKG-INFO b/taxcalc.egg-info/PKG-INFO index 9cca249d7..4841fd28a 100644 --- a/taxcalc.egg-info/PKG-INFO +++ b/taxcalc.egg-info/PKG-INFO @@ -18,6 +18,13 @@ Classifier: Programming Language :: Python :: 3.12 Classifier: Topic :: Software Development :: Libraries :: Python Modules Description-Content-Type: text/markdown License-File: LICENSE +Requires-Dist: setuptools +Requires-Dist: numpy +Requires-Dist: pandas +Requires-Dist: bokeh +Requires-Dist: numba +Requires-Dist: requests +Requires-Dist: paramtools>=0.18.3 | | | | --- | --- | From d814a1de212588a512491d01cb376903d835f0d8 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Thu, 28 Nov 2024 21:01:46 -0500 Subject: [PATCH 10/20] consistency in meta.yaml --- conda.recipe/meta.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml index 7abe02338..790148875 100755 --- a/conda.recipe/meta.yaml +++ b/conda.recipe/meta.yaml @@ -20,10 +20,10 @@ requirements: run: - "python>=3.10, <3.13" - - "numpy>=1.26,<1.27" + - "numpy>=1.26" - "pandas>=2.2" - "bokeh>=2.4" - - "paramtools>=0.18.3" + - "paramtools>=0.19.0" - numba - curl - openpyxl From 9c14ec8b5143dc040c1d19fd4069709556b3f995 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Fri, 6 Dec 2024 14:39:52 -0500 Subject: [PATCH 11/20] update paramtools in setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fb16ce918..10d5d3615 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ "bokeh", "numba", "requests", - "paramtools>=0.18.3", + "paramtools>=0.19.0", ], "classifiers": [ "Development Status :: 4 - Beta", From 6f3372b69e3177cfe601f258662f852701ec73ed Mon Sep 17 00:00:00 2001 From: jdebacker Date: Sun, 8 Dec 2024 20:45:49 -0500 Subject: [PATCH 12/20] add pins to setup.py --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 10d5d3615..9472f96fb 100644 --- a/setup.py +++ b/setup.py @@ -19,9 +19,9 @@ "name": "taxcalc", "install_requires": [ "setuptools", - "numpy", - "pandas", - "bokeh", + "numpy>=1.26", + "pandas>=2.2", + "bokeh>=2.4", "numba", "requests", "paramtools>=0.19.0", From 6cac8fc2fc7e3895059b439b0e18c0f603f86828 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Mon, 9 Dec 2024 22:05:34 -0500 Subject: [PATCH 13/20] update tmd constructor --- taxcalc/policy.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/taxcalc/policy.py b/taxcalc/policy.py index ce5fece40..42dad3a30 100644 --- a/taxcalc/policy.py +++ b/taxcalc/policy.py @@ -102,7 +102,8 @@ def __init__(self, gfactors=None, last_budget_year=DEFAULT_LAST_BUDGET_YEAR, ** Policy.WAGE_INDEXED_PARAMS, **kwargs) @staticmethod - def tmd_constructor(growfactors: Path | GrowFactors): # pragma: no cover + def tmd_constructor(growfactors: Path | GrowFactors, + last_budget_year=DEFAULT_LAST_BUDGET_YEAR): # pragma: no cover """ Static method returns a Policy object instantiated with TMD input data. This convenience method works in a analogous way @@ -113,7 +114,8 @@ def tmd_constructor(growfactors: Path | GrowFactors): # pragma: no cover growfactors = GrowFactors(growfactors_filename=str(growfactors)) else: assert isinstance(growfactors, GrowFactors) - return Policy(gfactors=growfactors) + return Policy(gfactors=growfactors, + last_budget_year=last_budget_year) @staticmethod def read_json_reform(obj): From 680d5c3db3fbab0390db142b319aee8c0f2eec21 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Mon, 9 Dec 2024 22:06:17 -0500 Subject: [PATCH 14/20] add pins to setup.py --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 9472f96fb..4ee4a2665 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,6 @@ "include_package_data": True, "name": "taxcalc", "install_requires": [ - "setuptools", "numpy>=1.26", "pandas>=2.2", "bokeh>=2.4", From 3d17daae349018193e0a3d562bd3212f5e521fcf Mon Sep 17 00:00:00 2001 From: jdebacker Date: Mon, 9 Dec 2024 22:06:38 -0500 Subject: [PATCH 15/20] add requests to meta and env --- conda.recipe/meta.yaml | 2 ++ environment.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml index 790148875..261d52f08 100755 --- a/conda.recipe/meta.yaml +++ b/conda.recipe/meta.yaml @@ -14,6 +14,7 @@ requirements: - "bokeh>=2.4" - "paramtools>=0.19.0" - numba + - requests - curl - openpyxl - behresp @@ -25,6 +26,7 @@ requirements: - "bokeh>=2.4" - "paramtools>=0.19.0" - numba + - requests - curl - openpyxl - behresp diff --git a/environment.yml b/environment.yml index 3d0b1983c..a087bf959 100644 --- a/environment.yml +++ b/environment.yml @@ -7,7 +7,9 @@ dependencies: - "pandas>=2.2" - "bokeh>=2.4" - numba +- requests - curl +- setuptools - pytest - pytest-xdist - pycodestyle From 71b228ebb55efe253a1ed17c5341a51541813cc8 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Tue, 10 Dec 2024 14:59:04 -0500 Subject: [PATCH 16/20] test setup file --- taxcalc/tests/test_4package.py | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/taxcalc/tests/test_4package.py b/taxcalc/tests/test_4package.py index 6e6e89de3..0c5d24e76 100644 --- a/taxcalc/tests/test_4package.py +++ b/taxcalc/tests/test_4package.py @@ -10,6 +10,34 @@ import subprocess import yaml import pytest +import ast + + +def extract_install_requires(setup_py_content): + """ + Extract the install_requires list from a setup.py file content. + + Args: + setup_py_content (str): The full content of the setup.py file + + Returns: + list: A list of package requirements + """ + # Use regex to find the install_requires list + match = re.search(r'"install_requires"\s*:\s*\[([^\]]+)\]', setup_py_content, re.DOTALL) + + if match: + # Extract the contents of the list and split into packages + packages_str = match.group(1) + # Use ast.literal_eval to safely parse the string representations + packages = [ + ast.literal_eval(f'{pkg.strip()}') + for pkg in packages_str.split(',') + if pkg.strip() + ] + return packages + + return [] @pytest.mark.local @@ -38,6 +66,7 @@ def test_for_consistency(tests_path): 'coverage', "pip", "jupyter-book", + "setuptools" ]) # read conda.recipe/meta.yaml requirements meta_file = os.path.join(tests_path, '..', '..', @@ -65,3 +94,16 @@ def test_for_consistency(tests_path): # confirm that extras in env (relative to run) equal the dev_pkgs set extras = env - run assert extras == dev_pkgs + # Read the setup.py file and extract the install_requires list + setup_file = os.path.join(tests_path, '..', '..', + 'setup.py') + with open(setup_file, 'r') as f: + setup_py_content = f.read() + setup = set(extract_install_requires(setup_py_content)) + # confirm that setup.py + print("Setup packages = ", setup) + print("Meta packages = ", bld) + # if package in both, confirm that the version is the same + for pkg in setup.intersection(bld): + assert pkg in setup + assert pkg in bld From 502f5aea02fcf1caa2885a44a459660d4c6e78e6 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Fri, 13 Dec 2024 15:12:06 -0500 Subject: [PATCH 17/20] fix typo --- taxcalc/taxcalcio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taxcalc/taxcalcio.py b/taxcalc/taxcalcio.py index 2ead655e2..47ff507d7 100644 --- a/taxcalc/taxcalcio.py +++ b/taxcalc/taxcalcio.py @@ -35,7 +35,7 @@ class TaxCalcIO(): string is name of INPUT file that is CSV formatted containing variable names in the Records USABLE_READ_VARS set, or Pandas DataFrame is INPUT data containing variable names in - the Records USABLE_READ_VARS set. INPUT vsrisbles not in the + the Records USABLE_READ_VARS set. INPUT variables not in the Records USABLE_READ_VARS set can be present but are ignored. tax_year: integer From a77816768daca1d76517a3b858c10809a9f555a3 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Sat, 14 Dec 2024 17:08:11 -0500 Subject: [PATCH 18/20] add test of flexible end year --- taxcalc/tests/test_cpscsv.py | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/taxcalc/tests/test_cpscsv.py b/taxcalc/tests/test_cpscsv.py index 7517b6adb..821c85971 100644 --- a/taxcalc/tests/test_cpscsv.py +++ b/taxcalc/tests/test_cpscsv.py @@ -161,3 +161,52 @@ def isfloat(value): else: return True return False + + +def test_flexible_last_budget_year(cps_fullsample): + """ + Test flexible LAST_BUDGET_YEAR logic using cps.csv file. + """ + tax_calc_year = Policy.DEFAULT_LAST_BUDGET_YEAR - 1 + growdiff_year = tax_calc_year - 1 + growdiff_dict = {'AWAGE': {growdiff_year: 0.01, tax_calc_year: 0.0}} + + def default_calculator(growdiff_dictionary): + """ + Return CPS-based Calculator object using default LAST_BUDGET_YEAR. + """ + g_factors = GrowFactors() + gdiff = GrowDiff() + gdiff.update_growdiff(growdiff_dictionary) + gdiff.apply_to(g_factors) + pol = Policy(gfactors=g_factors) + rec = Records.cps_constructor(data=cps_fullsample, gfactors=g_factors) + calc = Calculator(policy=pol, records=rec) + return calc + + def flexible_calculator(growdiff_dictionary, last_b_year, num_years): + """ + Return CPS-based Calculator object using custom LAST_BUDGET_YEAR. + """ + g_factors = GrowFactors() + gdiff = GrowDiff(nyrs=num_years) + gdiff.update_growdiff(growdiff_dictionary) + gdiff.apply_to(g_factors) + pol = Policy(gfactors=g_factors, last_budget_year=last_b_year) + rec = Records.cps_constructor(data=cps_fullsample, gfactors=g_factors) + calc = Calculator(policy=pol, records=rec) + return calc + + # begin main test logic + cdef = default_calculator(growdiff_dict) + cdef.advance_to_year(tax_calc_year) + cdef.calc_all() + iitax_def = round(cdef.weighted_total('iitax')) + + num_years = tax_calc_year - Policy.JSON_START_YEAR + 1 + cflx = flexible_calculator(growdiff_dict, tax_calc_year, num_years) + cflx.advance_to_year(tax_calc_year) + cflx.calc_all() + iitax_flx = round(cflx.weighted_total('iitax')) + + assert np.allclose([iitax_flx], [iitax_def]) \ No newline at end of file From 2593f2b7ac9188a21d26b7284e203039c0277224 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Sun, 15 Dec 2024 14:57:53 -0500 Subject: [PATCH 19/20] add budget year end to command line args --- taxcalc/cli/tc.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/taxcalc/cli/tc.py b/taxcalc/cli/tc.py index f27fc3c40..fefe49caa 100644 --- a/taxcalc/cli/tc.py +++ b/taxcalc/cli/tc.py @@ -27,6 +27,8 @@ def cli_tc_main(): # parse command-line arguments: usage_str = 'tc INPUT TAXYEAR {}{}{}{}{}'.format( '[--help]\n', + (' ' + '[--budgetend BUDGETENDYEAR]\n'), (' ' '[--baseline BASELINE] [--reform REFORM] [--assump ASSUMP]\n'), (' ' @@ -56,6 +58,15 @@ def cli_tc_main(): 'are computed.'), type=int, default=0) + parser.add_argument('--budgetend', + help=('BUDGETENDYEAR is name of optional ' + 'calendar year that is the last year ' + 'of the budget window to be analyzed. ' + 'No --budget implies the budget window ' + 'extends until ' + 'Policy.DEFAULT_LAST_BUDGET_YEAR.'), + default=None) + parser.add_argument('--reform', parser.add_argument('--baseline', help=('BASELINE is name of optional JSON reform file. ' 'No --baseline implies baseline policy is ' @@ -164,6 +175,7 @@ def cli_tc_main(): taxyear = args.TAXYEAR # instantiate TaxCalcIO object and do tax analysis tcio = tc.TaxCalcIO(input_data=inputfn, tax_year=taxyear, + bugdet_end_year=args.budgetend, baseline=args.baseline, reform=args.reform, assump=args.assump, outdir=args.outdir) @@ -179,6 +191,7 @@ def cli_tc_main(): if args.timings: stime = time.time() tcio.init(input_data=inputfn, tax_year=taxyear, + budget_end_year=args.budgetend, baseline=args.baseline, reform=args.reform, assump=args.assump, aging_input_data=aging, From 2cce10bfa0f362d181cfe9376886f1d2691b4456 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Sun, 15 Dec 2024 20:40:09 -0500 Subject: [PATCH 20/20] passing of tmd and year --- taxcalc.egg-info/PKG-INFO | 9 ++++----- taxcalc.egg-info/requires.txt | 9 ++++----- taxcalc/cli/tc.py | 4 ++-- taxcalc/growfactors.py | 1 + taxcalc/policy.py | 4 +++- taxcalc/taxcalcio.py | 30 +++++++++++++++++++++++------- 6 files changed, 37 insertions(+), 20 deletions(-) diff --git a/taxcalc.egg-info/PKG-INFO b/taxcalc.egg-info/PKG-INFO index 60eb54244..34725fec3 100644 --- a/taxcalc.egg-info/PKG-INFO +++ b/taxcalc.egg-info/PKG-INFO @@ -18,13 +18,12 @@ Classifier: Programming Language :: Python :: 3.12 Classifier: Topic :: Software Development :: Libraries :: Python Modules Description-Content-Type: text/markdown License-File: LICENSE -Requires-Dist: setuptools -Requires-Dist: numpy -Requires-Dist: pandas -Requires-Dist: bokeh +Requires-Dist: numpy>=1.26 +Requires-Dist: pandas>=2.2 +Requires-Dist: bokeh>=2.4 Requires-Dist: numba Requires-Dist: requests -Requires-Dist: paramtools>=0.18.3 +Requires-Dist: paramtools>=0.19.0 | | | | --- | --- | diff --git a/taxcalc.egg-info/requires.txt b/taxcalc.egg-info/requires.txt index 2e5f43376..a5c9f5570 100644 --- a/taxcalc.egg-info/requires.txt +++ b/taxcalc.egg-info/requires.txt @@ -1,7 +1,6 @@ -setuptools -numpy -pandas -bokeh +numpy>=1.26 +pandas>=2.2 +bokeh>=2.4 numba requests -paramtools>=0.18.3 +paramtools>=0.19.0 diff --git a/taxcalc/cli/tc.py b/taxcalc/cli/tc.py index fefe49caa..140539ccd 100644 --- a/taxcalc/cli/tc.py +++ b/taxcalc/cli/tc.py @@ -65,8 +65,8 @@ def cli_tc_main(): 'No --budget implies the budget window ' 'extends until ' 'Policy.DEFAULT_LAST_BUDGET_YEAR.'), + type=int, default=None) - parser.add_argument('--reform', parser.add_argument('--baseline', help=('BASELINE is name of optional JSON reform file. ' 'No --baseline implies baseline policy is ' @@ -175,7 +175,7 @@ def cli_tc_main(): taxyear = args.TAXYEAR # instantiate TaxCalcIO object and do tax analysis tcio = tc.TaxCalcIO(input_data=inputfn, tax_year=taxyear, - bugdet_end_year=args.budgetend, + budget_end_year=args.budgetend, baseline=args.baseline, reform=args.reform, assump=args.assump, outdir=args.outdir) diff --git a/taxcalc/growfactors.py b/taxcalc/growfactors.py index 8be68f1fb..a1f89a749 100644 --- a/taxcalc/growfactors.py +++ b/taxcalc/growfactors.py @@ -84,6 +84,7 @@ def __init__(self, growfactors_filename=None): # determine first_year and last_year from gfdf self._first_year = min(gfdf.index) self._last_year = max(gfdf.index) + print("IN Gfactors last year is ", self._last_year) # set gfdf as attribute of class self.gfdf = pd.DataFrame() setattr(self, 'gfdf', gfdf.astype(np.float64)) diff --git a/taxcalc/policy.py b/taxcalc/policy.py index 42dad3a30..6c69accc2 100644 --- a/taxcalc/policy.py +++ b/taxcalc/policy.py @@ -80,7 +80,9 @@ class instance: Policy # (3) specify which Policy parameters are wage (rather than price) indexed WAGE_INDEXED_PARAMS = ['SS_Earnings_c', 'SS_Earnings_thd'] - def __init__(self, gfactors=None, last_budget_year=DEFAULT_LAST_BUDGET_YEAR, **kwargs): + def __init__(self, gfactors=None, + last_budget_year=DEFAULT_LAST_BUDGET_YEAR, + **kwargs): # put JSON contents of DEFAULTS_FILE_NAME into self._vals dictionary super().__init__() # handle gfactors argument diff --git a/taxcalc/taxcalcio.py b/taxcalc/taxcalcio.py index 47ff507d7..9d4178471 100644 --- a/taxcalc/taxcalcio.py +++ b/taxcalc/taxcalcio.py @@ -41,6 +41,10 @@ class TaxCalcIO(): tax_year: integer calendar year for which taxes will be computed for INPUT. + budget_end_year: integer + last calendar year in the budget window for which taxes will + be computed for INPUT. + baseline: None or string None implies baseline policy is current-law policy, or string is name of optional BASELINE file that is a JSON @@ -64,8 +68,8 @@ class instance: TaxCalcIO """ # pylint: disable=too-many-instance-attributes - def __init__(self, input_data, tax_year, baseline, reform, assump, - outdir=None): + def __init__(self, input_data, tax_year, budget_end_year, baseline, + reform, assump, outdir=None): # pylint: disable=too-many-arguments,too-many-locals # pylint: disable=too-many-branches,too-many-statements self.errmsg = '' @@ -227,8 +231,8 @@ def __init__(self, input_data, tax_year, baseline, reform, assump, self.param_dict = None self.policy_dicts = [] - def init(self, input_data, tax_year, baseline, reform, assump, - aging_input_data, exact_calculations): + def init(self, input_data, tax_year, budget_end_year, baseline, + reform, assump, aging_input_data, exact_calculations): """ TaxCalcIO class post-constructor method that completes initialization. @@ -252,6 +256,11 @@ def init(self, input_data, tax_year, baseline, reform, assump, basedict = Calculator.read_json_param_objects(baseline, None) # get assumption sub-dictionaries paramdict = Calculator.read_json_param_objects(None, assump) + # Set budget window end year + if budget_end_year is None: + budget_end_year = Policy.DEFAULT_LAST_BUDGET_YEAR + else: + Policy.DEFAULT_LAST_BUDGET_YEAR = budget_end_year # get policy parameter dictionaries from --reform file(s) policydicts = [] if self.specified_reform: @@ -290,7 +299,10 @@ def init(self, input_data, tax_year, baseline, reform, assump, gdiff_response.apply_to(gfactors_ref) # create Policy objects: # ... the baseline Policy object - base = Policy(gfactors=gfactors_base) + print("GF BASE = ", gfactors_base.last_year, max(gfactors_base.gfdf.index)) + print("GF BASE = ", gfactors_base.last_year) + base = Policy(gfactors=gfactors_base, + last_budget_year=budget_end_year) try: base.implement_reform(basedict['policy'], print_warnings=True, @@ -301,7 +313,8 @@ def init(self, input_data, tax_year, baseline, reform, assump, self.errmsg += valerr_msg.__str__() # ... the reform Policy object if self.specified_reform: - pol = Policy(gfactors=gfactors_ref) + pol = Policy(gfactors=gfactors_ref, + last_budget_year=budget_end_year) for poldict in policydicts: try: pol.implement_reform(poldict, @@ -314,7 +327,8 @@ def init(self, input_data, tax_year, baseline, reform, assump, except paramtools.ValidationError as valerr_msg: self.errmsg += valerr_msg.__str__() else: - pol = Policy(gfactors=gfactors_base) + pol = Policy(gfactors=gfactors_base, + last_budget_year=budget_end_year) # create Consumption object con = Consumption() try: @@ -349,6 +363,8 @@ def init(self, input_data, tax_year, baseline, reform, assump, ) elif self.tmd_input_data: # pragma: no cover wghts = pd.read_csv(self.tmd_weights) + print("WEIGHTS = ", wghts.head()) + print("G FACTORS = ", gfactors_ref) recs = Records( data=pd.read_csv(input_data), start_year=Records.TMDCSV_YEAR,