diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 93e1507..76c1602 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -53,7 +53,7 @@ jobs: shell: bash -l {0} working-directory: ./ run: | - pytest --cov=./ --cov-report=xml + pytest -m 'not requires_pufcsv and not requires_tmdcsv' --cov=./ --cov-report=xml - name: Upload coverage to Codecov if: matrix.os == 'ubuntu-latest' && contains(github.repository, 'PSLmodels/Tax-Brain') uses: codecov/codecov-action@v4 diff --git a/RELEASES.md b/RELEASES.md index eb3d947..49ea54f 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,5 +1,15 @@ # Tax-Brain Release History + +## 2024-06-10 Release 2.7.0 + +Last Merged Pull Request: [#202](https://github.com/PSLmodels/Tax-Brain/pull/196) + +Changes in this release: + +* Use of the [Tax Micro Data (TMD)](https://github.com/PSLmodels/tax-microdata-benchmarking) file: [#202](https://github.com/PSLmodels/Tax-Brain/pull/202) + + ## 2024-04-25 Release 2.7.0 Last Merged Pull Request: [#196](https://github.com/PSLmodels/Tax-Brain/pull/196) diff --git a/cs-config/cs_config/functions.py b/cs-config/cs_config/functions.py index 20d5bb1..65d3c77 100644 --- a/cs-config/cs_config/functions.py +++ b/cs-config/cs_config/functions.py @@ -12,6 +12,7 @@ postprocess, nth_year_results, retrieve_puf, + retrieve_tmd, ) from .outputs import create_layout, aggregate_plot from taxbrain import TaxBrain, report @@ -25,6 +26,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/tmd.20210720.csv.gz" +) CUR_PATH = os.path.abspath(os.path.dirname(__file__)) @@ -108,7 +112,6 @@ def run_model(meta_params_dict, adjustment): behavior_mods = cs2tc.convert_behavior_adjustment(adjustment["behavior"]) user_mods = {"policy": policy_mods, "behavior": behavior_mods} start_year = int(meta_params.year) - use_cps = meta_params.data_source == "CPS" if meta_params.data_source == "PUF": puf_df = retrieve_puf( PUF_S3_FILE_LOCATION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY @@ -117,22 +120,45 @@ def run_model(meta_params_dict, adjustment): if not isinstance(puf_df, pd.DataFrame): raise TypeError("'puf_df' must be a Pandas DataFrame.") fuzz = True - use_cps = False sampling_frac = 0.05 sampling_seed = 2222 full_sample = puf_df + data_start_year = taxcalc.Records.PUFCSV_YEAR + weights = taxcalc.Records.PUF_WEIGHTS_FILENAME else: # Access keys are not available. Default to the CPS. print("Defaulting to the CPS") meta_params.adjust({"data_source": "CPS"}) - if meta_params.data_source == "CPS": + elif meta_params.data_source == "TMD": + tmd_df = retrieve_tmd( + TMD_S3_FILE_LOCATION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY + ) + if tmd_df is not None: + if not isinstance(tmd_df, pd.DataFrame): + raise TypeError("'tmd_df' must be a Pandas DataFrame.") + fuzz = True + sampling_frac = 0.05 + sampling_seed = 2222 + full_sample = tmd_df + data_start_year = taxcalc.Records.TMDCSV_YEAR + weights = taxcalc.Records.TMD_WEIGHTS_FILENAME + 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": fuzz = False - use_cps = True input_path = os.path.join(TCDIR, "cps.csv.gz") # full_sample = read_egg_csv(cpspath) # pragma: no cover sampling_frac = 0.03 sampling_seed = 180 full_sample = pd.read_csv(input_path) + data_start_year = taxcalc.Records.CPSCSV_YEAR + weights = taxcalc.Records.CPS_WEIGHTS_FILENAME + else: + raise ValueError( + f"Data source '{meta_params.data_source}' is not supported." + ) if meta_params.use_full_sample: sample = full_sample @@ -146,8 +172,12 @@ def run_model(meta_params_dict, adjustment): tb = TaxBrain( start_year, end_year, - microdata=sample, - use_cps=use_cps, + microdata={ + "data": sample, + "start_year": data_start_year, + "growfactors": None, + "weights": weights, + }, reform=policy_mods, behavior=behavior_mods, ) diff --git a/cs-config/cs_config/helpers.py b/cs-config/cs_config/helpers.py index 4ef7300..2be8769 100644 --- a/cs-config/cs_config/helpers.py +++ b/cs-config/cs_config/helpers.py @@ -58,6 +58,10 @@ "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/tmd.20210720.csv.gz" +) + def random_seed(user_mods, year): """ @@ -376,7 +380,7 @@ def retrieve_puf( aws_secret_access_key=AWS_SECRET_ACCESS_KEY, ): """ - Function for retrieving the PUF from the OSPC S3 bucket + Function for retrieving the PUF from the S3 bucket """ s3_reader_installed = S3FileSystem is not None has_credentials = ( @@ -405,3 +409,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 diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..7b2b2ee --- /dev/null +++ b/pytest.ini @@ -0,0 +1,7 @@ +[pytest] +testpaths = + taxbrain + cs-config/cs_config/tests +markers = + requires_pufcsv + requires_tmdcsv \ No newline at end of file diff --git a/setup.py b/setup.py index 852cf8e..4efa29e 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ with open("README.md", "r") as f: long_description = f.read() -version = "2.7.0" +version = "2.7.1" setuptools.setup( name="taxbrain", version=version, diff --git a/taxbrain/cli.py b/taxbrain/cli.py index 980a7d0..34f44f7 100644 --- a/taxbrain/cli.py +++ b/taxbrain/cli.py @@ -47,7 +47,6 @@ def cli_core( startyear, endyear, data, - usecps, reform, behavior, assump, @@ -91,12 +90,14 @@ def cli_core( start_year=startyear, end_year=endyear, microdata=data, - use_cps=usecps, reform=reform, behavior=behavior, assump=assump, base_policy=baseline, - verbose=True, + corp_revenue=None, + corp_incidence_assumptions=None, + verbose=False, + stacked=False, ) tb.run() @@ -156,15 +157,6 @@ def cli_main(): ), default=None, ) - parser.add_argument( - "--usecps", - help=( - "If this argument is present, the CPS file included in " - "Tax-Calculator will be used for the analysis." - ), - default=False, - action="store_true", - ), parser.add_argument( "--reform", help=("--reform should be a path to a JSON file."), diff --git a/taxbrain/taxbrain.py b/taxbrain/taxbrain.py index ceeec73..40b96fe 100644 --- a/taxbrain/taxbrain.py +++ b/taxbrain/taxbrain.py @@ -34,8 +34,7 @@ def __init__( self, start_year: int, end_year: int = LAST_BUDGET_YEAR, - microdata: Union[str, dict] = None, - use_cps: bool = False, + microdata: Union[str, dict] = "CPS", reform: Union[str, dict] = None, behavior: dict = None, assump=None, @@ -56,14 +55,12 @@ def __init__( end_year: int Last year in the analysis. Must be no later than the last year allowed in Tax-Calculator. - microdata: str or Pandas DataFrame - Either a path to a micro-data file or a Pandas DataFrame - containing micro-data. - use_cps: bool - A boolean value to indicate whether or not the analysis should - be run using the CPS file included in Tax-Calculator. - Note: use_cps cannot be True if a file was also specified with - the microdata parameter. + microdata: str or dict + A string in ["CPS", "PUF", "TMD"] or path to a micro-data + file or a Pandas DataFrame, containing micro-data, or a + dictionary containing a path to microdata, associated + weights, and grow factors. If a dict, must have keys: + "data", "start_year", "gfactors", "weights" reform: str or dict Individual income tax policy reform. Can be either a string pointing to a JSON reform file, or the contents of a JSON file, @@ -100,8 +97,6 @@ def __init__( ------- None """ - if not use_cps and microdata is None: - raise ValueError("Must specify microdata or set 'use_cps' to True") assert isinstance(start_year, int) & isinstance( end_year, int ), "Start and end years must be integers" @@ -122,7 +117,6 @@ def __init__( len(corp_revenue) == end_year - start_year + 1 ), f"Corporate revenue is not given for each budget year" self.microdata = microdata - self.use_cps = use_cps self.start_year = start_year self.end_year = end_year self.base_data = {yr: {} for yr in range(start_year, end_year + 1)} @@ -680,19 +674,50 @@ def _make_calculators(self): the `run()` method is called """ # Create two microsimulation calculators + # Baseline calculator gd_base = tc.GrowDiff() gf_base = tc.GrowFactors() # apply user specified growdiff if self.params["growdiff_baseline"]: gd_base.update_growdiff(self.params["growdiff_baseline"]) gd_base.apply_to(gf_base) - # Baseline calculator - if self.use_cps: - records = tc.Records.cps_constructor( - data=self.microdata, gfactors=gf_base + if self.microdata == "CPS": + records = tc.Records.cps_constructor(data=None, gfactors=gf_base) + elif self.microdata == "PUF": + records = tc.Records( + gfactors=gf_base, + weights=tc.Records.PUF_WEIGHTS_FILENAME, + ) + elif self.microdata == "TMD": + records = tc.Records.tmd_constructor( + "tmd.csv", + gfactors=gf_base, + ) + elif isinstance(self.microdata, dict): + if self.microdata["growfactors"] is None: + gd_base = tc.GrowDiff() + gf_base = tc.GrowFactors() + # apply user specified growdiff + if self.params["growdiff_baseline"]: + gd_base.update_growdiff(self.params["growdiff_baseline"]) + gd_base.apply_to(gf_base) + else: + gd_base = tc.GrowDiff() + gf_base = tc.GrowFactors(self.microdata["growfactors"]) + # apply user specified growdiff + if self.params["growdiff_baseline"]: + gd_base.update_growdiff(self.params["growdiff_baseline"]) + gd_base.apply_to(gf_base) + records = tc.Records( + self.microdata["data"], + start_year=self.microdata["start_year"], + gfactors=gf_base, + weights=self.microdata["weights"], ) else: - records = tc.Records(self.microdata, gfactors=gf_base) + raise ValueError( + "microdata must be 'CPS', 'PUF', 'TMD', or a dictionary" + ) policy = tc.Policy(gf_base) if self.params["base_policy"]: update_policy(policy, self.params["base_policy"]) @@ -701,18 +726,49 @@ def _make_calculators(self): ) # Reform calculator - # Initialize a policy object gd_reform = tc.GrowDiff() gf_reform = tc.GrowFactors() + # apply user specified growdiff if self.params["growdiff_response"]: gd_reform.update_growdiff(self.params["growdiff_response"]) gd_reform.apply_to(gf_reform) - if self.use_cps: - records = tc.Records.cps_constructor( - data=self.microdata, gfactors=gf_reform + if self.microdata == "CPS": + records = tc.Records.cps_constructor(data=None, gfactors=gf_reform) + elif self.microdata == "PUF": + records = tc.Records( + gfactors=gf_reform, + weights=tc.Records.PUF_WEIGHTS_FILENAME, + ) + elif self.microdata == "TMD": + records = tc.Records.tmd_constructor( + "tmd.csv", + gfactors=gf_reform, + ) + elif isinstance(self.microdata, dict): + if self.microdata["growfactors"] is None: + gd_reform = tc.GrowDiff() + gf_reform = tc.GrowFactors() + # apply user specified growdiff + if self.params["growdiff_response"]: + gd_reform.update_growdiff(self.params["growdiff_response"]) + gd_reform.apply_to(gf_reform) + else: + gd_reform = tc.GrowDiff() + gf_reform = tc.GrowFactors(self.microdata["growfactors"]) + # apply user specified growdiff + if self.params["growdiff_response"]: + gd_reform.update_growdiff(self.params["growdiff_response"]) + gd_reform.apply_to(gf_reform) + records = tc.Records( + self.microdata["data"], + start_year=self.microdata["start_year"], + gfactors=gf_reform, + weights=self.microdata["weights"], ) else: - records = tc.Records(self.microdata, gfactors=gf_reform) + raise ValueError( + "microdata must be 'CPS', 'PUF', 'TMD', or a dictionary" + ) policy = tc.Policy(gf_reform) if self.params["base_policy"]: update_policy(policy, self.params["base_policy"]) @@ -726,6 +782,8 @@ def _make_calculators(self): del gd_base, gd_reform, records, gf_base, gf_reform, policy return base_calc, reform_calc + # TODO: update these method to allow for different microdata as above + # but code becoming cumbersome, so should probably streamline in a single get calculator function def _make_stacked_objects(self): """ This method makes the base calculator and policy and records objects @@ -742,13 +800,44 @@ def _make_stacked_objects(self): if self.params["growdiff_baseline"]: gd_base.update_growdiff(self.params["growdiff_baseline"]) gd_base.apply_to(gf_base) - # Baseline calculator - if self.use_cps: - records = tc.Records.cps_constructor( - data=self.microdata, gfactors=gf_base + if self.microdata == "CPS": + records = tc.Records.cps_constructor(data=None, gfactors=gf_base) + elif self.microdata == "PUF": + records = tc.Records( + "puf.csv", + gfactors=gf_base, + weights=tc.Records.PUF_WEIGHTS_FILENAME, + ) + elif self.microdata == "TMD": + records = tc.Records.tmd_constructor( + "tmd.csv", + gfactors=gf_base, + ) + elif isinstance(self.microdata, dict): + if self.microdata["growfactors"] is None: + gd_base = tc.GrowDiff() + gf_base = tc.GrowFactors() + # apply user specified growdiff + if self.params["growdiff_baseline"]: + gd_base.update_growdiff(self.params["growdiff_baseline"]) + gd_base.apply_to(gf_base) + else: + gd_base = tc.GrowDiff() + gf_base = tc.GrowFactors(self.microdata["growfactors"]) + # apply user specified growdiff + if self.params["growdiff_baseline"]: + gd_base.update_growdiff(self.params["growdiff_baseline"]) + gd_base.apply_to(gf_base) + records = tc.Records( + self.microdata["data"], + start_year=self.microdata["start_year"], + gfactors=gf_base, + weights=self.microdata["weights"], ) else: - records = tc.Records(self.microdata, gfactors=gf_base) + raise ValueError( + "microdata must be 'CPS', 'PUF', 'TMD', or a dictionary" + ) policy = tc.Policy(gf_base) if self.params["base_policy"]: update_policy(policy, self.params["base_policy"]) @@ -757,17 +846,51 @@ def _make_stacked_objects(self): ) # Reform calculator - # Initialize a policy object gd_reform = tc.GrowDiff() gf_reform = tc.GrowFactors() + # apply user specified growdiff if self.params["growdiff_response"]: gd_reform.update_growdiff(self.params["growdiff_response"]) gd_reform.apply_to(gf_reform) - if self.use_cps: - records = tc.Records.cps_constructor( - data=self.microdata, gfactors=gf_reform + if self.microdata == "CPS": + reform_records = tc.Records.cps_constructor( + data=None, gfactors=gf_reform + ) + elif self.microdata == "PUF": + reform_records = tc.Records( + "puf.csv", + gfactors=gf_reform, + weights=tc.Records.PUF_WEIGHTS_FILENAME, + ) + elif self.microdata == "TMD": + records = tc.Records.tmd_constructor( + "tmd.csv", + gfactors=gf_reform, + ) + elif isinstance(self.microdata, dict): + if self.microdata["growfactors"] is None: + gd_reform = tc.GrowDiff() + gf_reform = tc.GrowFactors() + # apply user specified growdiff + if self.params["growdiff_response"]: + gd_reform.update_growdiff(self.params["growdiff_response"]) + gd_reform.apply_to(gf_reform) + else: + gd_reform = tc.GrowDiff() + gf_reform = tc.GrowFactors(self.microdata["growfactors"]) + # apply user specified growdiff + if self.params["growdiff_response"]: + gd_reform.update_growdiff(self.params["growdiff_response"]) + gd_reform.apply_to(gf_reform) + reform_records = tc.Records( + self.microdata["data"], + start_year=self.microdata["start_year"], + gfactors=gf_reform, + weights=self.microdata["weights"], ) else: - records = tc.Records(self.microdata, gfactors=gf_reform) - policy = tc.Policy(gf_reform) - return base_calc, policy, records + raise ValueError( + "microdata must be 'CPS', 'PUF', 'TMD', or a dictionary" + ) + reform_policy = tc.Policy(gf_reform) + return base_calc, reform_policy, reform_records diff --git a/taxbrain/tests/conftest.py b/taxbrain/tests/conftest.py index af6586f..50f0e0c 100644 --- a/taxbrain/tests/conftest.py +++ b/taxbrain/tests/conftest.py @@ -15,15 +15,15 @@ def reform_json_str(): "SS_thd50": {"2019": [50000, 100000, 50000, 50000, 50000]}, "SS_thd85": {"2019": [50000, 100000, 50000, 50000, 50000]}, "SS_Earnings_thd": {"2019": 400000}, - "FICA_ss_trt": {"2020": 0.125, - "2021": 0.126, - "2022": 0.127, - "2023": 0.128, - "2024": 0.129, - "2025": 0.130, - "2026": 0.131, - "2027": 0.132, - "2028": 0.133}, + "FICA_ss_trt_employee": {"2020": 0.0625, + "2021": 0.063, + "2022": 0.0635, + "2023": 0.064, + "2024": 0.0645, + "2025": 0.065, + "2026": 0.0605, + "2027": 0.061, + "2028": 0.0615}, "STD-indexed": {"2019": false} } } @@ -47,7 +47,7 @@ def assump_json_str(): scope="session", ) def tb_static(reform_json_str): - return TaxBrain(2018, 2019, use_cps=True, reform=reform_json_str) + return TaxBrain(2018, 2019, microdata="CPS", reform=reform_json_str) @pytest.fixture(scope="session") @@ -55,7 +55,7 @@ def tb_dynamic(reform_json_str): return TaxBrain( 2018, 2019, - use_cps=True, + microdata="CPS", reform=reform_json_str, behavior={"sub": 0.25}, ) @@ -72,17 +72,11 @@ def empty_mods(): } -@pytest.fixture(scope="session") -def puf_df(): - puf_path = os.path.join(CUR_PATH, "../../puf.csv") - return pd.read_csv(puf_path) - - @pytest.fixture(scope="session") def sample_input(): params = { "params": { - "policy": {"_FICA_ss_trt": {"2019": [0.15]}}, + "policy": {"_FICA_ss_trt_employee": {"2019": [0.075]}}, "behavior": {"sub": {"2019": [0.1]}}, }, "jsonstrs": "", diff --git a/taxbrain/tests/test_brain.py b/taxbrain/tests/test_brain.py index 2f70536..46c8fd0 100644 --- a/taxbrain/tests/test_brain.py +++ b/taxbrain/tests/test_brain.py @@ -6,18 +6,18 @@ def test_arg_validation(): - with pytest.raises(ValueError): - TaxBrain(2018, 2020) with pytest.raises(AssertionError): - TaxBrain("2018", "2020", use_cps=True) + TaxBrain("2018", "2020", microdata="CPS") with pytest.raises(AssertionError): TaxBrain( - TaxBrain.LAST_BUDGET_YEAR, TaxBrain.FIRST_BUDGET_YEAR, use_cps=True + TaxBrain.LAST_BUDGET_YEAR, + TaxBrain.FIRST_BUDGET_YEAR, + microdata="CPS", ) with pytest.raises(AssertionError): - TaxBrain(TaxBrain.FIRST_BUDGET_YEAR - 1, 2018, use_cps=True) + TaxBrain(TaxBrain.FIRST_BUDGET_YEAR - 1, 2018, microdata="CPS") with pytest.raises(AssertionError): - TaxBrain(2018, TaxBrain.LAST_BUDGET_YEAR + 1, use_cps=True) + TaxBrain(2018, TaxBrain.LAST_BUDGET_YEAR + 1, microdata="CPS") def test_static_run(tb_static): @@ -30,7 +30,25 @@ def test_baseline_policy(): base = {"II_em": {2019: 0}} reform = {"II_em": {2025: 2000}} - tb = TaxBrain(2018, 2019, use_cps=True, reform=reform, base_policy=base) + tb = TaxBrain(2018, 2019, microdata="CPS", reform=reform, base_policy=base) + tb.run() + + +@pytest.mark.requires_pufcsv +def test_baseline_policy_PUF(): + base = {"II_em": {2019: 0}} + reform = {"II_em": {2025: 2000}} + + tb = TaxBrain(2018, 2019, microdata="PUF", reform=reform, base_policy=base) + tb.run() + + +@pytest.mark.requires_tmdcsv +def test_baseline_policy_TMD(): + base = {"II_em": {2021: 0}} + reform = {"II_em": {2025: 2000}} + + tb = TaxBrain(2021, 2022, microdata="TMD", reform=reform, base_policy=base) tb.run() @@ -45,7 +63,7 @@ def test_run_corporate_distribution(): tb = TaxBrain( 2018, 2019, - use_cps=True, + microdata="CPS", reform=reform, base_policy=base, corp_revenue=corp_revenue, @@ -64,7 +82,7 @@ def test_dynamic_run_corporate_distribution(): tb = TaxBrain( 2018, 2019, - use_cps=True, + microdata="CPS", reform=reform, base_policy=base, behavior={"sub": 0.25}, @@ -88,7 +106,9 @@ def test_stacked_run(): "Payroll Threshold Increase": payroll_json, "Capital Gains Tax Changes": CG_rate_json, } - tb = TaxBrain(2021, 2022, reform=reform_dict, stacked=True, use_cps=True) + tb = TaxBrain( + 2021, 2022, reform=reform_dict, stacked=True, microdata="CPS" + ) tb.run() # check that there is a stacked table now assert isinstance(tb.stacked_table, pd.DataFrame) @@ -110,7 +130,7 @@ def test_stacked_run_corporate(): 2022, reform=reform_dict, stacked=True, - use_cps=True, + microdata="CPS", corp_revenue=[100_000_000, 100_000_000], ) tb.run() @@ -179,8 +199,8 @@ def test_distribution_table(tb_static): def test_user_input(reform_json_str, assump_json_str): valid_reform = {"II_rt7": {2019: 0.40}} # Test valid reform dictionary with No assumption - TaxBrain(2018, 2020, use_cps=True, reform=valid_reform) - TaxBrain(2018, 2020, use_cps=True, reform=reform_json_str) + TaxBrain(2018, 2020, microdata="CPS", reform=valid_reform) + TaxBrain(2018, 2020, microdata="CPS", reform=reform_json_str) invalid_assump = {"consumption": {}} # Test valid reform and assumptions dictionary valid_assump = { @@ -188,16 +208,16 @@ def test_user_input(reform_json_str, assump_json_str): "growdiff_baseline": {}, "growdiff_response": {}, } - TaxBrain(2018, 2019, use_cps=True, assump=valid_assump) + TaxBrain(2018, 2019, microdata="CPS", assump=valid_assump) TaxBrain( 2018, 2019, - use_cps=True, + microdata="CPS", reform=reform_json_str, assump=assump_json_str, ) tb = TaxBrain( - 2018, 2019, use_cps=True, reform=valid_reform, assump=valid_assump + 2018, 2019, microdata="CPS", reform=valid_reform, assump=valid_assump ) required_param_keys = { "policy", @@ -209,7 +229,7 @@ def test_user_input(reform_json_str, assump_json_str): } assert set(tb.params.keys()) == required_param_keys with pytest.raises(ValueError): - TaxBrain(2018, 2020, use_cps=True, assump=invalid_assump) + TaxBrain(2018, 2020, microdata="CPS", assump=invalid_assump) invalid_assump = { "consumption": {}, "growdiff_baseline": {}, @@ -217,8 +237,8 @@ def test_user_input(reform_json_str, assump_json_str): "invalid": {}, } with pytest.raises(ValueError): - TaxBrain(2018, 2020, use_cps=True, assump=invalid_assump) + TaxBrain(2018, 2020, microdata="CPS", assump=invalid_assump) with pytest.raises(TypeError): - TaxBrain(2018, 2020, use_cps=True, reform=True) + TaxBrain(2018, 2020, microdata="CPS", reform=True) with pytest.raises(TypeError): - TaxBrain(2018, 2020, use_cps=True, assump=True) + TaxBrain(2018, 2020, microdata="CPS", assump=True) diff --git a/taxbrain/tests/test_cli.py b/taxbrain/tests/test_cli.py index 6bd1ec9..1f9719d 100644 --- a/taxbrain/tests/test_cli.py +++ b/taxbrain/tests/test_cli.py @@ -9,8 +9,7 @@ def test_cli(): """ startyear = 2019 endyear = 2020 - data = None - usecps = True + data = "CPS" reform = None behavior = None assump = None @@ -23,7 +22,6 @@ def test_cli(): startyear, endyear, data, - usecps, reform, behavior, assump,