From a9346db5794e0025b8f7e20b45463be31797e16c Mon Sep 17 00:00:00 2001 From: "martin.holmer@gmail.com" Date: Sun, 8 Dec 2024 16:12:24 -0500 Subject: [PATCH 1/2] Fix documentation link in economic_assumptions_template.json --- taxcalc/assumptions/economic_assumptions_template.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taxcalc/assumptions/economic_assumptions_template.json b/taxcalc/assumptions/economic_assumptions_template.json index 68ef2a6b4..89c67d509 100644 --- a/taxcalc/assumptions/economic_assumptions_template.json +++ b/taxcalc/assumptions/economic_assumptions_template.json @@ -4,7 +4,7 @@ // about how individuals and the overall economy respond to a tax reform. // // Detailed documentation on these parameters can be found at -// . +// . { "consumption": { "MPC_e17500": {"2017": 0.0}, From 2e912acf3c92001e568c59d1e3f98ac267d1ae9e Mon Sep 17 00:00:00 2001 From: "martin.holmer@gmail.com" Date: Mon, 9 Dec 2024 12:07:14 -0500 Subject: [PATCH 2/2] Generalize tmd_constructor for Records and Policy --- taxcalc/policy.py | 15 ++++++++------- taxcalc/records.py | 9 ++++++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/taxcalc/policy.py b/taxcalc/policy.py index bda068914..1c5bf52f7 100644 --- a/taxcalc/policy.py +++ b/taxcalc/policy.py @@ -53,7 +53,7 @@ class instance: Policy 'DependentCredit_before_CTC': 'is a removed parameter name', 'FilerCredit_c': 'is a removed parameter name', 'ALD_InvInc_ec_base_RyanBrady': 'is a removed parameter name', - # TODO: following parameter renamed in PR 2292 merged on 2019-04-15 + # following parameter renamed in PR 2292 merged on 2019-04-15 "cpi_offset": ( "was renamed parameter_indexing_CPI_offset. " "See documentation for change in usage." @@ -62,7 +62,7 @@ class instance: Policy "was renamed parameter_indexing_CPI_offset. " "See documentation for change in usage." ), - # TODO: following parameters renamed in PR 2345 merged on 2019-06-24 + # following parameters renamed in PR 2345 merged on 2019-06-24 'PT_excl_rt': 'was renamed PT_qbid_rt in release 2.4.0', 'PT_excl_wagelim_thd': @@ -102,17 +102,18 @@ def __init__(self, gfactors=None, **kwargs): Policy.WAGE_INDEXED_PARAMS, **kwargs) @staticmethod - def tmd_constructor(growfactors_path): # pragma: no cover + def tmd_constructor(growfactors: Path | GrowFactors): # pragma: no cover """ Static method returns a Policy object instantiated with TMD input data. This convenience method works in a analogous way to Policy(), which returns a Policy object instantiated with non-TMD input data. """ - assert isinstance(growfactors_path, Path) - gf_filename = str(growfactors_path) - tmd_growfactors = GrowFactors(growfactors_filename=gf_filename) - return Policy(gfactors=tmd_growfactors) + if isinstance(growfactors, Path): + growfactors = GrowFactors(growfactors_filename=str(growfactors)) + else: + assert isinstance(growfactors, GrowFactors) + return Policy(gfactors=growfactors) @staticmethod def read_json_reform(obj): diff --git a/taxcalc/records.py b/taxcalc/records.py index b67987bf1..6d5a25295 100644 --- a/taxcalc/records.py +++ b/taxcalc/records.py @@ -235,7 +235,7 @@ def cps_constructor(data=None, def tmd_constructor( data_path: Path, weights_path: Path, - growfactors_path: Path, + growfactors: Path | GrowFactors, exact_calculations=False, ): # pragma: no cover """ @@ -250,12 +250,15 @@ def tmd_constructor( """ assert isinstance(data_path, Path) assert isinstance(weights_path, Path) - assert isinstance(growfactors_path, Path) + if isinstance(growfactors, Path): + growfactors = GrowFactors(growfactors_filename=str(growfactors)) + else: + assert isinstance(growfactors, GrowFactors) return Records( data=pd.read_csv(data_path), start_year=Records.TMDCSV_YEAR, weights=pd.read_csv(weights_path), - gfactors=GrowFactors(growfactors_filename=str(growfactors_path)), + gfactors=growfactors, adjust_ratios=None, exact_calculations=exact_calculations, weights_scale=1.0,