From a2f905c7bf7cf5f4d6ca313c3d7e3a427ca34cf8 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Thu, 23 May 2024 09:22:09 -0400 Subject: [PATCH 01/16] pass more info on tax microdata in Specifications --- ccc/get_taxcalc_rates.py | 12 +++--------- ccc/parameters.py | 26 +++++++++++++++++++------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/ccc/get_taxcalc_rates.py b/ccc/get_taxcalc_rates.py index f464cd48..6b03f0b3 100644 --- a/ccc/get_taxcalc_rates.py +++ b/ccc/get_taxcalc_rates.py @@ -53,15 +53,9 @@ def get_calculator( else: records1 = Records() # pragma: no cover - if baseline: - if ( - baseline_policy - ): # if something other than current law policy baseline - update_policy(policy1, baseline_policy) - - if not baseline: - if baseline_policy: # update baseline policy to layer reform on top - update_policy(policy1, baseline_policy) + if baseline_policy: # if something other than current law policy baseline + update_policy(policy1, baseline_policy) + if reform: # if there is a reform update_policy(policy1, reform) # the default set up increments year to 2013 diff --git a/ccc/parameters.py b/ccc/parameters.py index 2851c478..b3adca0f 100644 --- a/ccc/parameters.py +++ b/ccc/parameters.py @@ -4,7 +4,7 @@ # import ccc from ccc.get_taxcalc_rates import get_rates -from ccc.utils import DEFAULT_START_YEAR +from ccc.utils import DEFAULT_START_YEAR, RECORDS_START_YEAR import ccc.paramfunctions as pf CURRENT_PATH = os.path.abspath(os.path.dirname(__file__)) @@ -23,32 +23,42 @@ class Specification(paramtools.Parameters): def __init__( self, test=False, - baseline=False, year=DEFAULT_START_YEAR, call_tc=False, baseline_policy=None, - iit_reform={}, + iit_reform=None, data="cps", + gfactors=None, + weights=None, + records_start_year=RECORDS_START_YEAR, ): super().__init__() self.set_state(year=year) self.test = test - self.baseline = baseline self.year = year self.baseline_policy = baseline_policy self.iit_reform = iit_reform self.data = data # initialize parameter values from JSON - self.ccc_initialize(call_tc=call_tc) + self.ccc_initialize(call_tc=call_tc, gfactors=gfactors, weights=weights) - def ccc_initialize(self, call_tc=False): + def ccc_initialize(self, call_tc=False, gfactors=None, weights=None, records_start_year=RECORDS_START_YEAR): """ ParametersBase reads JSON file and sets attributes to self Next call self.compute_default_params for further initialization Args: + test (bool): whether to run in test mode + year (int): start year for simulation call_tc (bool): whether to use Tax-Calculator to estimate marginal tax rates + baseline_policy (dict): individual income tax baseline + policy parameters, reform dict makes changes relative + to this baseline + iit_reform (dict): individual income tax reform parameters + data (str): data source for Tax-Calculator + gfactors (dict): growth factors for Tax-Calculator + weights (str): weights for Tax-Calculator Returns: None @@ -57,11 +67,13 @@ def ccc_initialize(self, call_tc=False): if call_tc: # Find individual income tax rates from Tax-Calculator indiv_rates = get_rates( - self.baseline, self.year, self.baseline_policy, self.iit_reform, self.data, + gfactors, + weights, + records_start_year ) self.tau_pt = indiv_rates["tau_pt"] self.tau_div = indiv_rates["tau_div"] From 8fe0bbd55bfe74c402ae2a5c40ffa9858f7bbd88 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Thu, 23 May 2024 09:46:41 -0400 Subject: [PATCH 02/16] format --- ccc/parameters.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ccc/parameters.py b/ccc/parameters.py index b3adca0f..89e58044 100644 --- a/ccc/parameters.py +++ b/ccc/parameters.py @@ -40,9 +40,17 @@ def __init__( self.iit_reform = iit_reform self.data = data # initialize parameter values from JSON - self.ccc_initialize(call_tc=call_tc, gfactors=gfactors, weights=weights) + self.ccc_initialize( + call_tc=call_tc, gfactors=gfactors, weights=weights + ) - def ccc_initialize(self, call_tc=False, gfactors=None, weights=None, records_start_year=RECORDS_START_YEAR): + def ccc_initialize( + self, + call_tc=False, + gfactors=None, + weights=None, + records_start_year=RECORDS_START_YEAR, + ): """ ParametersBase reads JSON file and sets attributes to self Next call self.compute_default_params for further initialization @@ -73,7 +81,7 @@ def ccc_initialize(self, call_tc=False, gfactors=None, weights=None, records_sta self.data, gfactors, weights, - records_start_year + records_start_year, ) self.tau_pt = indiv_rates["tau_pt"] self.tau_div = indiv_rates["tau_div"] From 9e8fd882271b320b6b87b1bd1ae6bc66e728ac7c Mon Sep 17 00:00:00 2001 From: jdebacker Date: Thu, 23 May 2024 10:08:30 -0400 Subject: [PATCH 03/16] only upload to codeco v in upstream repo --- .github/workflows/build_and_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 2ef7f828..270c5036 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -36,7 +36,7 @@ jobs: run: | pytest -m 'not needs_puf' --cov=./ --cov-report=xml - name: Upload coverage to Codecov - if: matrix.os == 'ubuntu-latest' + if: matrix.os == 'ubuntu-latest' && contains(github.repository, 'PSLmodels/Cost-of-Capital-Calculator') uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos From 2a56bfe2141073634a0e66666f771df2210c6330 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Thu, 23 May 2024 15:07:27 -0400 Subject: [PATCH 04/16] update args --- ccc/get_taxcalc_rates.py | 20 ++++++++++++++------ ccc/tests/test_get_taxcalc_rates.py | 21 +++++++++------------ ccc/tests/test_start_years.py | 2 +- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/ccc/get_taxcalc_rates.py b/ccc/get_taxcalc_rates.py index 6b03f0b3..c0bc5b0b 100644 --- a/ccc/get_taxcalc_rates.py +++ b/ccc/get_taxcalc_rates.py @@ -5,7 +5,6 @@ def get_calculator( - baseline, calculator_start_year, baseline_policy=None, reform=None, @@ -18,7 +17,6 @@ def get_calculator( This function creates the tax calculator object for the microsim Args: - baseline (bool): `True` if baseline tax policy calculator_start_year (integer): first year of budget window baseline_policy (dictionary): IIT baseline parameters reform (dictionary): IIT reform parameters @@ -73,20 +71,28 @@ def get_calculator( def get_rates( - baseline=False, start_year=DEFAULT_START_YEAR, baseline_policy=None, reform={}, data="cps", + gfactors=None, + weights=None, + records_start_year=RECORDS_START_YEAR, ): """ This function computes weighted average marginal tax rates using micro data from the tax calculator Args: - baseline (bool): `True` if baseline tax policy, `False` if reform - start_year (integer): first year of budget window + start_year (integer): start year for the simulations + baseline_policy (dict): baseline parameters reform (dict): reform parameters + data (string or Pandas DataFrame): path to file or DataFrame + for Tax-Calculator Records object (optional) + gfactors (Tax-Calculator GrowFactors object): grow factors + weights (str): path to weights file for Tax-Calculator + Records object + records_start_year (integer): the start year for the microdata Returns: individual_rates (dict): individual income (IIT+payroll) @@ -94,11 +100,13 @@ def get_rates( """ calc1 = get_calculator( - baseline=baseline, calculator_start_year=start_year, baseline_policy=baseline_policy, reform=reform, data=data, + gfactors=None, + weights=None, + records_start_year=RECORDS_START_YEAR, ) # running all the functions and calculates taxes diff --git a/ccc/tests/test_get_taxcalc_rates.py b/ccc/tests/test_get_taxcalc_rates.py index 75af0383..1682b8e4 100644 --- a/ccc/tests/test_get_taxcalc_rates.py +++ b/ccc/tests/test_get_taxcalc_rates.py @@ -6,22 +6,21 @@ @pytest.mark.parametrize( - "baseline", - [(True), (False)], + "reform", + [(None), ({"FICA_ss_trt": {2018: 0.125}})], ids=["baseline", "reform"], ) -def test_get_calculator_cps(baseline): +def test_get_calculator_cps(reform): """ Test the get_calculator() function """ calc1 = tc.get_calculator( - baseline, 2019, baseline_policy={"FICA_ss_trt": {2018: 0.15}}, - reform={"FICA_ss_trt": {2018: 0.125}}, + reform=reform, ) assert calc1.current_year == 2019 - if baseline: + if reform is None: assert calc1.policy_param("FICA_ss_trt") == 0.15 else: assert calc1.policy_param("FICA_ss_trt") == 0.125 @@ -29,16 +28,15 @@ def test_get_calculator_cps(baseline): @pytest.mark.needs_puf @pytest.mark.parametrize( - "baseline,data", - [(True, "puf.csv"), (True, None), (False, None)], - ids=["baseline,data=PUF", "baseline,data=None", "reform,data=None"], + "data", + [("puf.csv"), (None)], + ids=["baseline,data=PUF", "baseline,data=None"], ) -def test_get_calculator(baseline, data): +def test_get_calculator(data): """ Test the get_calculator() function """ calc1 = tc.get_calculator( - baseline, 2019, baseline_policy={"FICA_ss_trt": {2018: 0.15}}, reform={"FICA_ss_trt": {2018: 0.125}}, @@ -61,7 +59,6 @@ def test_get_rates(): """ p = Specification(year=2020) # has default tax rates, with should equal TC test_dict = tc.get_rates( - baseline=False, start_year=2020, baseline_policy={}, reform={}, diff --git a/ccc/tests/test_start_years.py b/ccc/tests/test_start_years.py index a1eab1af..8b8743c4 100644 --- a/ccc/tests/test_start_years.py +++ b/ccc/tests/test_start_years.py @@ -12,7 +12,7 @@ def test_tc_start_year(year): Test that different start years work in functions calling Tax-Calculator """ - get_rates(True, year) + get_rates(year) @pytest.mark.parametrize( From 938f987d071c3ecfe509437248c24d49719f7346 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Thu, 23 May 2024 17:44:41 -0400 Subject: [PATCH 05/16] pass through records year --- ccc/get_taxcalc_rates.py | 8 ++++++-- ccc/parameters.py | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ccc/get_taxcalc_rates.py b/ccc/get_taxcalc_rates.py index c0bc5b0b..c924e7cd 100644 --- a/ccc/get_taxcalc_rates.py +++ b/ccc/get_taxcalc_rates.py @@ -1,6 +1,6 @@ # imports import numpy as np -from taxcalc import Policy, Records, Calculator +from taxcalc import Policy, Records, Calculator, GrowFactors from ccc.utils import DEFAULT_START_YEAR, TC_LAST_YEAR, RECORDS_START_YEAR @@ -34,6 +34,7 @@ def get_calculator( # create a calculator policy1 = Policy() if data is not None and "cps" in data: + print("Using CPS") records1 = Records.cps_constructor() # impute short and long term capital gains if using CPS data # in 2012 SOI data 6.587% of CG as short-term gains @@ -42,6 +43,9 @@ def get_calculator( # set total capital gains to zero records1.e01100 = np.zeros(records1.e01100.shape[0]) elif data is not None: # pragma: no cover + print("Data is ", data) + print("Weights are ", weights) + print("Records start year is ", records_start_year) records1 = Records( data=data, gfactors=gfactors, @@ -106,7 +110,7 @@ def get_rates( data=data, gfactors=None, weights=None, - records_start_year=RECORDS_START_YEAR, + records_start_year=records_start_year, ) # running all the functions and calculates taxes diff --git a/ccc/parameters.py b/ccc/parameters.py index 89e58044..a1313157 100644 --- a/ccc/parameters.py +++ b/ccc/parameters.py @@ -41,7 +41,10 @@ def __init__( self.data = data # initialize parameter values from JSON self.ccc_initialize( - call_tc=call_tc, gfactors=gfactors, weights=weights + call_tc=call_tc, + gfactors=gfactors, + weights=weights, + records_start_year=records_start_year, ) def ccc_initialize( From 37d743e26c214bf0f33b112353c194b169dafdc3 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Thu, 30 May 2024 14:37:42 -0400 Subject: [PATCH 06/16] use tmd constructor --- ccc/get_taxcalc_rates.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ccc/get_taxcalc_rates.py b/ccc/get_taxcalc_rates.py index c924e7cd..bb5cf590 100644 --- a/ccc/get_taxcalc_rates.py +++ b/ccc/get_taxcalc_rates.py @@ -15,6 +15,11 @@ def get_calculator( ): """ This function creates the tax calculator object for the microsim + model. + + Note: gfactors and weights are only used if provide custom data + path or file with those gfactors and weights. Otherwise, the + model defaults to those gfactors and weights from Tax-Calculator. Args: calculator_start_year (integer): first year of budget window @@ -22,6 +27,7 @@ def get_calculator( reform (dictionary): IIT reform parameters data (string or Pandas DataFrame): path to file or DataFrame for Tax-Calculator Records object (optional) + gfactors (str or DataFrame): grow factors to extrapolate data weights (DataFrame): weights DataFrame for Tax-Calculator Records object (optional) records_start_year (integer): the start year for the data and @@ -42,6 +48,12 @@ def get_calculator( records1.p23250 = (1 - 0.06587) * records1.e01100 # set total capital gains to zero records1.e01100 = np.zeros(records1.e01100.shape[0]) + elif data is None or "puf" in data: # pragma: no cover + print("Using PUF") + records1 = Records() + elif data is not None and "tmd" in data: # pragma: no cover + print("Using TMD") + records1 = Records.tmd_constructor() elif data is not None: # pragma: no cover print("Data is ", data) print("Weights are ", weights) @@ -52,8 +64,8 @@ def get_calculator( weights=weights, start_year=records_start_year, ) # pragma: no cover - else: - records1 = Records() # pragma: no cover + else: # pragma: no cover + raise ValueError("Please provide data or use CPS, PUF, or TMD.") if baseline_policy: # if something other than current law policy baseline update_policy(policy1, baseline_policy) From d34b35ef584f938c59be3376a608c2b009060440 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Thu, 30 May 2024 17:58:42 -0400 Subject: [PATCH 07/16] include markers in pytest.ini --- pytest.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pytest.ini b/pytest.ini index 79f7f6c5..7752a361 100644 --- a/pytest.ini +++ b/pytest.ini @@ -4,6 +4,8 @@ testpaths = cs-config/cs_config/tests markers = pep8 + needs_puf + needs_tmd pep8ignore = ccc/calcfunctions.py E501 ccc/controls_callback_script.py E501 From e36b0db2ab1e2fc88f96f0bd93a116035568749e Mon Sep 17 00:00:00 2001 From: jdebacker Date: Thu, 30 May 2024 17:59:09 -0400 Subject: [PATCH 08/16] updates to test with all three files --- ccc/get_taxcalc_rates.py | 2 +- ccc/tests/test_get_taxcalc_rates.py | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ccc/get_taxcalc_rates.py b/ccc/get_taxcalc_rates.py index bb5cf590..c9de2308 100644 --- a/ccc/get_taxcalc_rates.py +++ b/ccc/get_taxcalc_rates.py @@ -53,7 +53,7 @@ def get_calculator( records1 = Records() elif data is not None and "tmd" in data: # pragma: no cover print("Using TMD") - records1 = Records.tmd_constructor() + records1 = Records.tmd_constructor("tmd.csv.gz") elif data is not None: # pragma: no cover print("Data is ", data) print("Weights are ", weights) diff --git a/ccc/tests/test_get_taxcalc_rates.py b/ccc/tests/test_get_taxcalc_rates.py index 1682b8e4..aeed34ac 100644 --- a/ccc/tests/test_get_taxcalc_rates.py +++ b/ccc/tests/test_get_taxcalc_rates.py @@ -32,7 +32,7 @@ def test_get_calculator_cps(reform): [("puf.csv"), (None)], ids=["baseline,data=PUF", "baseline,data=None"], ) -def test_get_calculator(data): +def test_get_calculator_puf(data): """ Test the get_calculator() function """ @@ -45,6 +45,25 @@ def test_get_calculator(data): assert calc1.current_year == 2019 +@pytest.mark.needs_tmd +@pytest.mark.parametrize( + "data", + [("tmd.csv")], + ids=["baseline,data=TMD"], +) +def test_get_calculator_tmd(data): + """ + Test the get_calculator() function + """ + calc1 = tc.get_calculator( + 2021, + baseline_policy={"FICA_ss_trt": {2021: 0.15}}, + reform={"FICA_ss_trt": {2022: 0.125}}, + data=data, + ) + assert calc1.current_year == 2021 + + def test_get_calculator_exception(): """ Test the get_calculator() function From 9ef74b4bfdd0ed2e4f7fe4f5fe8200ccaccd4e95 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Thu, 30 May 2024 21:53:04 -0400 Subject: [PATCH 09/16] update how cs read data --- cs-config/cs_config/functions.py | 47 ++++++++++++++++++++++++++++---- cs-config/cs_config/helpers.py | 40 +++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 5 deletions(-) diff --git a/cs-config/cs_config/functions.py b/cs-config/cs_config/functions.py index c66a4a32..09aaf973 100644 --- a/cs-config/cs_config/functions.py +++ b/cs-config/cs_config/functions.py @@ -6,9 +6,10 @@ from bokeh.embed import json_item import os import paramtools -from taxcalc import Policy +import pandas as pd +from taxcalc import Policy, Records, Growfactors from collections import OrderedDict -from .helpers import retrieve_puf +from .helpers import retrieve_puf, retrieve_tmd import cs2tc AWS_ACCESS_KEY_ID = os.environ.get("AWS_ACCESS_KEY_ID") @@ -16,6 +17,9 @@ PUF_S3_FILE_LOCATION = os.environ.get( "PUF_S3_LOCATION", "s3://ospc-data-files/puf.20210720.csv.gz" ) +TMD_S3_FILE_LOCATION = os.environ.get( + "TMD_S3_LOCATION", "s3://ospc-data-files/puf.20210720.csv.gz" +) class MetaParams(paramtools.Parameters): @@ -45,7 +49,7 @@ class MetaParams(paramtools.Parameters): "description": "Data source for Tax-Calculator to use", "type": "str", "value": "CPS", - "validators": {"choice": {"choices": ["PUF", "CPS"]}}, + "validators": {"choice": {"choices": ["PUF", "CPS", "TMD"]}}, }, } @@ -180,8 +184,35 @@ def run_model(meta_param_dict, adjustment): data = retrieve_puf( PUF_S3_FILE_LOCATION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY ) - else: + weights = Records.PUF_WEIGHTS_FILENAME + records_start_year = Records.PUFCSV_YEAR + if data is not None: + if not isinstance(data, pd.DataFrame): + raise TypeError("'data' must be a Pandas DataFrame.") + else: + # Access keys are not available. Default to the CPS. + print("Defaulting to the CPS") + meta_params.adjust({"data_source": "CPS"}) + elif meta_params.data_source == "TMD": + data = retrieve_tmd( + TMD_S3_FILE_LOCATION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY + ) + weights = Records.TMD_WEIGHTS_FILENAME + records_start_year = Records.TMDCSV_YEAR + if data is not None: + if not isinstance(data, pd.DataFrame): + raise TypeError("'data' must be a Pandas DataFrame.") + else: + # Access keys are not available. Default to the CPS. + print("Defaulting to the CPS") + meta_params.adjust({"data_source": "CPS"}) + elif meta_params.data_source == "CPS": data = "cps" + weights = Records.PUF_WEIGHTS_FILENAME + else: + raise ValueError( + f"Data source '{meta_params.data_source}' is not supported." + ) # Get TC params adjustments iit_mods = cs2tc.convert_policy_adjustment( adjustment["Individual and Payroll Tax Parameters"] @@ -228,7 +259,13 @@ def run_model(meta_param_dict, adjustment): calc1 = Calculator(params, dp, assets) # Reform CCC calculator - includes TC adjustments params2 = Specification( - year=meta_params.year, call_tc=True, iit_reform=iit_mods, data=data + year=meta_params.year, + call_tc=True, + iit_reform=iit_mods, + data=data, + gfactors=Growfactors.FILE_NAME, + weights=weights, + records_start_year=records_start_year, ) params2.update_specification(adjustment["Business Tax Parameters"]) calc2 = Calculator(params2, dp, assets) diff --git a/cs-config/cs_config/helpers.py b/cs-config/cs_config/helpers.py index 1dfc1335..3d28b686 100644 --- a/cs-config/cs_config/helpers.py +++ b/cs-config/cs_config/helpers.py @@ -19,6 +19,9 @@ PUF_S3_FILE_LOCATION = os.environ.get( "PUF_S3_LOCATION", "s3://ospc-data-files/puf.20210720.csv.gz" ) +TMD_S3_FILE_LOCATION = os.environ.get( + "TMD_S3_LOCATION", "s3://ospc-data-files/puf.20210720.csv.gz" +) POLICY_SCHEMA = { "labels": { @@ -115,3 +118,40 @@ def retrieve_puf( f"s3_reader_installed={s3_reader_installed})" ) return None + + +def retrieve_tmd( + tmd_s3_file_location=TMD_S3_FILE_LOCATION, + aws_access_key_id=AWS_ACCESS_KEY_ID, + aws_secret_access_key=AWS_SECRET_ACCESS_KEY, +): + """ + Function for retrieving the TMD from the S3 bucket + """ + s3_reader_installed = S3FileSystem is not None + has_credentials = ( + aws_access_key_id is not None and aws_secret_access_key is not None + ) + if tmd_s3_file_location and has_credentials and s3_reader_installed: + print("Reading tmd from S3 bucket.", tmd_s3_file_location) + fs = S3FileSystem( + key=AWS_ACCESS_KEY_ID, + secret=AWS_SECRET_ACCESS_KEY, + ) + with fs.open(tmd_s3_file_location) as f: + # Skips over header from top of file. + tmd_df = pd.read_csv(f) + return tmd_df + elif Path("tmd.csv.gz").exists(): + print("Reading tmd from tmd.csv.gz.") + return pd.read_csv("tmd.csv.gz", compression="gzip") + elif Path("tmd.csv").exists(): + print("Reading tmd from tmd.csv.") + return pd.read_csv("tmd.csv") + else: + warnings.warn( + f"TMD file not available (tmd_location={tmd_s3_file_location}, " + f"has_credentials={has_credentials}, " + f"s3_reader_installed={s3_reader_installed})" + ) + return None From 06378b975da362459684c3a9181445206787a730 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Fri, 31 May 2024 09:14:14 -0400 Subject: [PATCH 10/16] start year for cps data in cs config: --- cs-config/cs_config/functions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cs-config/cs_config/functions.py b/cs-config/cs_config/functions.py index 09aaf973..52adee73 100644 --- a/cs-config/cs_config/functions.py +++ b/cs-config/cs_config/functions.py @@ -7,7 +7,7 @@ import os import paramtools import pandas as pd -from taxcalc import Policy, Records, Growfactors +from taxcalc import Policy, Records, GrowFactors from collections import OrderedDict from .helpers import retrieve_puf, retrieve_tmd import cs2tc @@ -209,6 +209,7 @@ def run_model(meta_param_dict, adjustment): elif meta_params.data_source == "CPS": data = "cps" weights = Records.PUF_WEIGHTS_FILENAME + records_start_year = Records.CPSCSV_YEAR else: raise ValueError( f"Data source '{meta_params.data_source}' is not supported." @@ -263,7 +264,7 @@ def run_model(meta_param_dict, adjustment): call_tc=True, iit_reform=iit_mods, data=data, - gfactors=Growfactors.FILE_NAME, + gfactors=GrowFactors.FILE_NAME, weights=weights, records_start_year=records_start_year, ) From e94dc69945b99e917085b1aa8715b79cfc020e08 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Fri, 31 May 2024 10:10:31 -0400 Subject: [PATCH 11/16] don't run tmd tests on gh action --- .github/workflows/build_and_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 270c5036..a962ecb8 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -34,7 +34,7 @@ jobs: shell: bash -l {0} working-directory: ./ run: | - pytest -m 'not needs_puf' --cov=./ --cov-report=xml + pytest -m 'not needs_puf and not needs_tmd' --cov=./ --cov-report=xml - name: Upload coverage to Codecov if: matrix.os == 'ubuntu-latest' && contains(github.repository, 'PSLmodels/Cost-of-Capital-Calculator') uses: codecov/codecov-action@v4 From 088e9bc0620ca59c1e4159d0404e2d2e48f95659 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Fri, 31 May 2024 11:24:56 -0400 Subject: [PATCH 12/16] test year beyond --- ccc/tests/test_get_taxcalc_rates.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccc/tests/test_get_taxcalc_rates.py b/ccc/tests/test_get_taxcalc_rates.py index aeed34ac..011fa3ac 100644 --- a/ccc/tests/test_get_taxcalc_rates.py +++ b/ccc/tests/test_get_taxcalc_rates.py @@ -69,7 +69,7 @@ def test_get_calculator_exception(): Test the get_calculator() function """ with pytest.raises(Exception): - assert tc.get_calculator(True, TC_LAST_YEAR + 1) + assert tc.get_calculator(TC_LAST_YEAR + 1) def test_get_rates(): From d3dc2fa1ff19fe9cdd68acf9006cefaf6e2a1af9 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Sun, 9 Jun 2024 21:31:39 -0400 Subject: [PATCH 13/16] bump version --- README.md | 2 +- ccc/__init__.py | 2 +- docs/book/content/intro.md | 2 +- setup.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4600139c..ca66deab 100644 --- a/README.md +++ b/README.md @@ -53,4 +53,4 @@ Results will change as the underlying models improve. A fundamental reason for a ## Citing the Cost-of-Capital-Calculator Model -Cost-of-Capital-Calculator (Version 1.4.0)[Source code], https://github.com/PSLmodels/Cost-of-Capital-Calculator +Cost-of-Capital-Calculator (Version 1.4.1)[Source code], https://github.com/PSLmodels/Cost-of-Capital-Calculator diff --git a/ccc/__init__.py b/ccc/__init__.py index bfaaca89..f0aa29da 100644 --- a/ccc/__init__.py +++ b/ccc/__init__.py @@ -6,4 +6,4 @@ from ccc.data import * from ccc.calculator import * -__version__ = "1.4.0" +__version__ = "1.4.1" diff --git a/docs/book/content/intro.md b/docs/book/content/intro.md index 67f1be6c..6fd25005 100644 --- a/docs/book/content/intro.md +++ b/docs/book/content/intro.md @@ -22,4 +22,4 @@ Results will change as the underlying models improve. A fundamental reason for a ## Citing the Cost-of-Capital-Calculator Model -Cost-of-Capital-Calculator (Version 1.4.0)[Source code], https://github.com/PSLmodels/Cost-of-Capital-Calculator \ No newline at end of file +Cost-of-Capital-Calculator (Version 1.4.1)[Source code], https://github.com/PSLmodels/Cost-of-Capital-Calculator \ No newline at end of file diff --git a/setup.py b/setup.py index 6875845c..3a7a4eb2 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ with open("README.md") as f: longdesc = f.read() -version = "1.4.0" +version = "1.4.1" config = { "description": "CCC: A Cost of Capital Calculator", From dc1ab85d1ef7bde405f0758ed0cbfc3b2893d8ec Mon Sep 17 00:00:00 2001 From: jdebacker Date: Mon, 10 Jun 2024 14:08:38 -0400 Subject: [PATCH 14/16] update for taxcalc 4.0 --- ccc/tests/test_get_taxcalc_rates.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ccc/tests/test_get_taxcalc_rates.py b/ccc/tests/test_get_taxcalc_rates.py index 011fa3ac..8019ea98 100644 --- a/ccc/tests/test_get_taxcalc_rates.py +++ b/ccc/tests/test_get_taxcalc_rates.py @@ -7,7 +7,7 @@ @pytest.mark.parametrize( "reform", - [(None), ({"FICA_ss_trt": {2018: 0.125}})], + [(None), ({"FICA_ss_trt_employee": {2018: 0.0625}})], ids=["baseline", "reform"], ) def test_get_calculator_cps(reform): @@ -16,14 +16,14 @@ def test_get_calculator_cps(reform): """ calc1 = tc.get_calculator( 2019, - baseline_policy={"FICA_ss_trt": {2018: 0.15}}, + baseline_policy={"FICA_ss_trt_employee": {2018: 0.075}}, reform=reform, ) assert calc1.current_year == 2019 if reform is None: - assert calc1.policy_param("FICA_ss_trt") == 0.15 + assert calc1.policy_param("FICA_ss_trt_employee") == 0.075 else: - assert calc1.policy_param("FICA_ss_trt") == 0.125 + assert calc1.policy_param("FICA_ss_trt_employee") == 0.0625 @pytest.mark.needs_puf @@ -38,8 +38,8 @@ def test_get_calculator_puf(data): """ calc1 = tc.get_calculator( 2019, - baseline_policy={"FICA_ss_trt": {2018: 0.15}}, - reform={"FICA_ss_trt": {2018: 0.125}}, + baseline_policy={"FICA_ss_trt_employee": {2018: 0.075}}, + reform={"FICA_ss_trt_employee": {2018: 0.0625}}, data=data, ) assert calc1.current_year == 2019 @@ -57,8 +57,8 @@ def test_get_calculator_tmd(data): """ calc1 = tc.get_calculator( 2021, - baseline_policy={"FICA_ss_trt": {2021: 0.15}}, - reform={"FICA_ss_trt": {2022: 0.125}}, + baseline_policy={"FICA_ss_trt_employee": {2021: 0.075}}, + reform={"FICA_ss_trt_employee": {2022: 0.0625}}, data=data, ) assert calc1.current_year == 2021 From 4ab83b4334d3b6672324c9c602ae70b1a817d877 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Mon, 10 Jun 2024 14:32:20 -0400 Subject: [PATCH 15/16] cs update for tc 4.0 --- cs-config/cs_config/tests/test_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cs-config/cs_config/tests/test_functions.py b/cs-config/cs_config/tests/test_functions.py index 39be1638..63d3d786 100644 --- a/cs-config/cs_config/tests/test_functions.py +++ b/cs-config/cs_config/tests/test_functions.py @@ -51,7 +51,7 @@ class TestFunctions1(CoreTestFunctions): "CIT_rate": [{"year": DEFAULT_START_YEAR, "value": 0.25}] }, "Individual and Payroll Tax Parameters": { - "FICA_ss_trt": [{"year": DEFAULT_START_YEAR, "value": 0.14}] + "FICA_ss_trt_employee": [{"year": DEFAULT_START_YEAR, "value": 0.07}] }, } bad_adjustment = { From e3d4d90b7a111c5a70993856a5dee4ed5ae08eb8 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Mon, 10 Jun 2024 14:37:14 -0400 Subject: [PATCH 16/16] format --- cs-config/cs_config/tests/test_functions.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cs-config/cs_config/tests/test_functions.py b/cs-config/cs_config/tests/test_functions.py index 63d3d786..ca67e2a3 100644 --- a/cs-config/cs_config/tests/test_functions.py +++ b/cs-config/cs_config/tests/test_functions.py @@ -51,7 +51,9 @@ class TestFunctions1(CoreTestFunctions): "CIT_rate": [{"year": DEFAULT_START_YEAR, "value": 0.25}] }, "Individual and Payroll Tax Parameters": { - "FICA_ss_trt_employee": [{"year": DEFAULT_START_YEAR, "value": 0.07}] + "FICA_ss_trt_employee": [ + {"year": DEFAULT_START_YEAR, "value": 0.07} + ] }, } bad_adjustment = {