diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 15e5429b..87111db7 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -56,7 +56,7 @@ jobs: shell: bash -l {0} working-directory: ./ run: | - python -m pytest -m "not local" --cov=./ --cov-report=xml + python -m pytest -m "not local and 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/OG-USA') uses: codecov/codecov-action@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e071dbf..6a84450a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.1.9] - 2024-06-07 12:00:00 + +### Added + +- Updates the `get_micro_data.py` and `calibration.py` modules to allow for the user to use the CPS, PUF, and TMD files with Tax-Calculator or to provide their own custom datafile, with associated grow factors and weights. + ## [0.1.8] - 2024-05-20 12:00:00 @@ -105,6 +111,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 +[0.1.9]: https://github.com/PSLmodels/OG-USA/compare/v0.1.8...v0.1.9 [0.1.8]: https://github.com/PSLmodels/OG-USA/compare/v0.1.7...v0.1.8 [0.1.7]: https://github.com/PSLmodels/OG-USA/compare/v0.1.6...v0.1.7 [0.1.6]: https://github.com/PSLmodels/OG-USA/compare/v0.1.5...v0.1.6 diff --git a/cs-config/cs_config/functions.py b/cs-config/cs_config/functions.py index 4e41fb48..064fa946 100644 --- a/cs-config/cs_config/functions.py +++ b/cs-config/cs_config/functions.py @@ -14,11 +14,12 @@ import pickle import json import inspect +import pandas as pd import paramtools from distributed import Client -from taxcalc import Policy +from taxcalc import Policy, Records, GrowFactors from collections import OrderedDict -from .helpers import retrieve_puf +from .helpers import retrieve_puf, retrieve_tmd from cs2tc import convert_policy_adjustment AWS_ACCESS_KEY_ID = os.environ.get("AWS_ACCESS_KEY_ID", "") @@ -26,6 +27,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" +) CUR_DIR = os.path.dirname(os.path.realpath(__file__)) # Get Tax-Calculator default parameters @@ -78,7 +82,7 @@ class MetaParams(paramtools.Parameters): def get_version(): - return "0.1.2" + return "0.1.9" def get_inputs(meta_param_dict): @@ -188,16 +192,46 @@ def run_model(meta_param_dict, adjustment): meta_params = MetaParams() meta_params.adjust(meta_param_dict) + # Get data chosen by user if meta_params.data_source == "PUF": data = retrieve_puf( PUF_S3_FILE_LOCATION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY ) + weights = Records.PUF_WEIGHTS_FILENAME + records_start_year = Records.PUFCSV_YEAR # set name of cached baseline file in case use below cached_pickle = "TxFuncEst_baseline_PUF.pkl" - else: + 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 + records_start_year = Records.CPSCSV_YEAR # set name of cached baseline file in case use below cached_pickle = "TxFuncEst_baseline_CPS.pkl" + else: + raise ValueError( + f"Data source '{meta_params.data_source}' is not supported." + ) + # Get TC params adjustments iit_mods = convert_policy_adjustment( adjustment["Tax-Calculator Parameters"] @@ -211,7 +245,7 @@ def run_model(meta_param_dict, adjustment): # Dask parmeters num_workers = 2 - memory_limit = "10GiB" + memory_per_worker = "10GiB" client = Client( n_workers=num_workers, threads_per_worker=1, @@ -222,8 +256,7 @@ def run_model(meta_param_dict, adjustment): # num_workers_txf = 5 # num_workers_mod = 6 - # whether to estimate tax functions from microdata - run_micro = True + # Read in whether user chose to solve for transition path time_path = meta_param_dict["time_path"][0]["value"] # filter out OG-USA params that will not change between baseline and @@ -363,6 +396,9 @@ def run_model(meta_param_dict, adjustment): iit_reform=iit_mods, estimate_tax_functions=True, data=data, + gfactors=GrowFactors.FILE_NAME, + weights=weights, + records_start_year=records_start_year, client=client, ) # update tax function parameters in Specifications Object diff --git a/cs-config/cs_config/helpers.py b/cs-config/cs_config/helpers.py index e6986c50..699f7d5f 100644 --- a/cs-config/cs_config/helpers.py +++ b/cs-config/cs_config/helpers.py @@ -24,6 +24,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" +) TC_LAST_YEAR = Policy.LAST_BUDGET_YEAR POLICY_SCHEMA = { @@ -120,3 +123,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/docs/book/content/api/get_micro_data.rst b/docs/book/content/api/get_micro_data.rst index fe073e1e..cba87e48 100644 --- a/docs/book/content/api/get_micro_data.rst +++ b/docs/book/content/api/get_micro_data.rst @@ -9,4 +9,4 @@ ogusa.get_micro_data ------------------------------------------ .. automodule:: ogusa.get_micro_data - :members: get_calculator, get_data, taxcalc_advance, cap_inc_mtr + :members: get_calculator, get_data, taxcalc_advance, cap_inc_mtr, update_policy, is_paramtools_format diff --git a/ogusa/calibrate.py b/ogusa/calibrate.py index 8c80c9d9..98e52491 100644 --- a/ogusa/calibrate.py +++ b/ogusa/calibrate.py @@ -3,6 +3,7 @@ from ogusa import get_micro_data import os import numpy as np +from taxcalc import Records from ogcore import txfunc, demographics from ogcore.utils import safe_read_pickle, mkdirs import pkg_resources @@ -23,6 +24,9 @@ def __init__( iit_reform={}, guid="", data="cps", + gfactors=None, + weights=None, + records_start_year=Records.CPSCSV_YEAR, client=None, num_workers=1, demographic_data_path=None, @@ -33,7 +37,7 @@ def __init__( parameter values for the OG-USA model. Args: - p (OGUSA Parameters object): parameters object + p (OG-USA Parameters object): parameters object estimate_tax_functions (bool): whether to estimate tax functions estimate_beta (bool): whether to estimate beta estimate_chi_n (bool): whether to estimate chi_n @@ -42,7 +46,13 @@ def __init__( iit_baseline (dict): baseline policy to use iit_reform (dict): reform tax parameters guid (str): id for tax function parameters - data (str): data source for microsimulation model + data (str or Pandas DataFrame): path or DataFrame with + data for Tax-Calculator model + gfactors (str or Pandas DataFrame ): path or DataFrame with + growth factors for Tax-Calculator model + weights (str or Pandas DataFrame): path or DataFrame with + weights for Tax-Calculator model + records_start_year (int): year micro data begins client (Dask client object): client num_workers (int): number of workers for Dask client output_path (str): path to save output to @@ -69,6 +79,9 @@ def __init__( iit_reform, guid, data, + gfactors, + weights, + records_start_year, client, num_workers, run_micro=run_micro, @@ -143,6 +156,9 @@ def get_tax_function_parameters( iit_reform={}, guid="", data="", + gfactors=None, + weights=None, + records_start_year=Records.CPSCSV_YEAR, client=None, num_workers=1, run_micro=False, @@ -157,7 +173,13 @@ def get_tax_function_parameters( iit_baseline (dict): baseline policy to use iit_reform (dict): reform tax parameters guid (string): id for tax function parameters - data (string): data source for microsimulation model + data (str or Pandas DataFrame): path or DataFrame with + data for Tax-Calculator model + gfactors (str or Pandas DataFrame ): path or DataFrame with + growth factors for Tax-Calculator model + weights (str or Pandas DataFrame): path or DataFrame with + weights for Tax-Calculator model + records_start_year (int): year micro data begins client (Dask client object): client num_workers (int): number of workers for Dask client run_micro (bool): whether to estimate parameters from diff --git a/ogusa/constants.py b/ogusa/constants.py index e1a2e32b..1b34cdb4 100644 --- a/ogusa/constants.py +++ b/ogusa/constants.py @@ -12,9 +12,6 @@ DEFAULT_START_YEAR = 2021 # Tax-Calculator start year TC_LAST_YEAR = taxcalc.Policy.LAST_BUDGET_YEAR -# Years of the PUF and CPS files -PUF_START_YEAR = taxcalc.Records.PUFCSV_YEAR -CPS_START_YEAR = taxcalc.Records.CPSCSV_YEAR VAR_LABELS = { "Y": "GDP ($Y_t$)", diff --git a/ogusa/get_micro_data.py b/ogusa/get_micro_data.py index bd0d1906..1ef246c2 100644 --- a/ogusa/get_micro_data.py +++ b/ogusa/get_micro_data.py @@ -14,27 +14,25 @@ import pickle import pkg_resources from ogcore import utils -from ogusa.constants import DEFAULT_START_YEAR, TC_LAST_YEAR, PUF_START_YEAR +from ogusa.constants import DEFAULT_START_YEAR, TC_LAST_YEAR CUR_PATH = os.path.split(os.path.abspath(__file__))[0] def get_calculator( - baseline, calculator_start_year, iit_baseline=None, iit_reform=None, data=None, gfactors=None, weights=None, - records_start_year=PUF_START_YEAR, + records_start_year=Records.PUFCSV_YEAR, ): """ This function creates the tax calculator object with the policy specified in reform and the data specified with the data kwarg. Args: - baseline (boolean): True if baseline tax policy calculator_start_year (int): first year of budget window reform (dictionary): IIT policy reform parameters, None if baseline @@ -55,6 +53,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 @@ -62,7 +61,16 @@ 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("tmd.csv.gz") 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, @@ -70,27 +78,16 @@ def get_calculator( start_year=records_start_year, ) # pragma: no cover else: # pragma: no cover - records1 = Records() # pragma: no cover + raise ValueError("Please provide data or use CPS, PUF, or TMD.") - if baseline: - if iit_baseline is None: - print("Running current law policy baseline") - else: - print("Baseline policy is: ", iit_baseline) - policy1.implement_reform(iit_baseline) - else: - if not iit_reform: - print("Running with current law as reform") - else: - print("Reform policy is: ", iit_reform) - if ( - iit_baseline is not None - ): # if alt baseline, stack reform on that - policy1.implement_reform(iit_baseline) - policy1.implement_reform(iit_reform) + if iit_baseline: # if something other than current law policy baseline + update_policy(policy1, iit_baseline) + if iit_reform: # if there is a reform + update_policy(policy1, iit_reform) # the default set up increments year to 2013 calc1 = Calculator(records=records1, policy=policy1) + print("Calculator initial year = ", calc1.current_year) # Check that start_year is appropriate if calculator_start_year > TC_LAST_YEAR: @@ -105,6 +102,9 @@ def get_data( iit_baseline=None, iit_reform={}, data=None, + gfactors=None, + weights=None, + records_start_year=Records.CPSCSV_YEAR, path=CUR_PATH, client=None, num_workers=1, @@ -121,8 +121,13 @@ def get_data( iit_baseline (dictionary): IIT policy parameters for baseline iit_reform (dictionary): IIT policy reform parameters, None if baseline - data (DataFrame or str): DataFrame or path to datafile for - Records object + data (str or Pandas DataFrame): path or DataFrame with + data for Tax-Calculator model + gfactors (str or Pandas DataFrame ): path or DataFrame with + growth factors for Tax-Calculator model + weights (str or Pandas DataFrame): path or DataFrame with + weights for Tax-Calculator model + records_start_year (int): year micro data begins path (str): path to save microdata files to client (Dask Client object): client for Dask multiprocessing num_workers (int): number of workers to use for Dask @@ -140,7 +145,14 @@ def get_data( for year in range(start_year, TC_LAST_YEAR + 1): lazy_values.append( delayed(taxcalc_advance)( - baseline, start_year, iit_baseline, iit_reform, data, year + start_year, + iit_baseline, + iit_reform, + data, + gfactors, + weights, + records_start_year, + year, ) ) if client: # pragma: no cover @@ -177,19 +189,30 @@ def get_data( def taxcalc_advance( - baseline, start_year, iit_baseline, iit_reform, data, year + start_year, + iit_baseline, + iit_reform, + data, + gfactors, + weights, + records_start_year, + year, ): """ This function advances the year used in Tax-Calculator, compute taxes and rates, and save the results to a dictionary. Args: - baseline (boolean): True if baseline tax policy start_year (int): first year of budget window iit_baseline (dict): IIT policy parameters for baseline iit_reform (dict): IIT policy reform parameters for reform - data (DataFrame or str): DataFrame or path to datafile for - Records object + data (str or Pandas DataFrame): path or DataFrame with + data for Tax-Calculator model + gfactors (str or Pandas DataFrame ): path or DataFrame with + growth factors for Tax-Calculator model + weights (str or Pandas DataFrame): path or DataFrame with + weights for Tax-Calculator model + records_start_year (int): year micro data begins year (int): year to advance to in Tax-Calculator Returns: @@ -197,11 +220,13 @@ def taxcalc_advance( rates and other information computed in TC """ calc1 = get_calculator( - baseline=baseline, calculator_start_year=start_year, iit_baseline=iit_baseline, iit_reform=iit_reform, data=data, + gfactors=gfactors, + weights=weights, + records_start_year=records_start_year, ) calc1.advance_to_year(year) calc1.calc_all() @@ -321,3 +346,50 @@ def cap_inc_mtr(calc1): # pragma: no cover total_cap_inc == 0 ] return mtr_combined_capinc + + +def update_policy(policy_obj, reform, **kwargs): + """ + Convenience method that updates the Policy object with the reform + dict using the appropriate method, given the reform format. + + Args: + policy_obj (Policy object): Tax-Calculator Policy object + reform (dict or str): JSON string or dictionary of reform + parameters + kwargs (dict): keyword arguments to pass to the adjust method + + Returns: + None (updates policy object) + + """ + if is_paramtools_format(reform): + policy_obj.adjust(reform, **kwargs) + else: + policy_obj.implement_reform(reform, **kwargs) + + +def is_paramtools_format(reform): + """ + Check first item in reform to determine if it is using the ParamTools + adjustment or the Tax-Calculator reform format. + If first item is a dict, then it is likely be a Tax-Calculator reform: + { + param: {2020: 1000} + } + Otherwise, it is likely to be a ParamTools format. + + Args: + reform (dict or str): JSON string or dictionary of reform + parameters + + Returns: + format (bool): True if reform is likely to be in PT format. + """ + for _, data in reform.items(): + if isinstance(data, dict): + return False # taxcalc reform + 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 diff --git a/pytest.ini b/pytest.ini index 43308517..580eb30b 100644 --- a/pytest.ini +++ b/pytest.ini @@ -5,3 +5,5 @@ testpaths = ./tests markers = local: marks tests that are run locally only and not on GH Actions + needs_puf: marks tests that require the PUF data to run + needs_tmd: marks tests that require the TMD data to run diff --git a/setup.py b/setup.py index e58d1e2c..3b96a49a 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="ogusa", - version="0.1.8", + version="0.1.9", author="Jason DeBacker and Richard W. Evans", license="CC0 1.0 Universal (CC0 1.0) Public Domain Dedication", description="USA calibration for OG-Core", diff --git a/tests/test_get_micro_data.py b/tests/test_get_micro_data.py index 59b6ca6b..a5f62f1a 100644 --- a/tests/test_get_micro_data.py +++ b/tests/test_get_micro_data.py @@ -4,15 +4,16 @@ from pandas.testing import assert_frame_equal import numpy as np import os -from ogusa.constants import CPS_START_YEAR, PUF_START_YEAR, TC_LAST_YEAR +from ogusa.constants import TC_LAST_YEAR from ogusa import get_micro_data from ogcore import utils -from taxcalc import GrowFactors +from taxcalc import GrowFactors, Records NUM_WORKERS = min(multiprocessing.cpu_count(), 7) # get path to puf if puf.csv in ogusa/ directory CUR_PATH = os.path.abspath(os.path.dirname(__file__)) PUF_PATH = os.path.join(CUR_PATH, "..", "puf.csv") +TMD_PATH = os.path.join(CUR_PATH, "..", "tmd.csv.gz") @pytest.fixture(scope="module") @@ -29,15 +30,13 @@ def test_cps(): """ Check that setting `data` to 'cps' uses cps data """ - baseline = False start_year = 2016 reform = {"II_em": {2017: 10000}} calc = get_micro_data.get_calculator( - baseline, start_year, iit_reform=reform, - records_start_year=CPS_START_YEAR, + records_start_year=Records.CPSCSV_YEAR, data="cps", ) # blind_head is only in the CPS file and e00700 is only in the PUF. @@ -52,7 +51,6 @@ def test_set_path(): Check that 'notapath.csv' is passed to taxcalc. An error containing 'notapath.csv' is sufficient proof for this """ - baseline = False start_year = 2016 reform = {"II_em": {2017: 10000}} @@ -62,26 +60,25 @@ def test_set_path(): # this could change. So I think it's best to catch both errors with pytest.raises((IOError, ValueError), match="notapath.csv"): get_micro_data.get_calculator( - baseline, start_year, iit_reform=reform, - records_start_year=CPS_START_YEAR, + records_start_year=Records.PUFCSV_YEAR, data="notapath.csv", ) +@pytest.mark.needs_puf def test_puf_path(): """ - Check that setting `data` to None uses the puf file + Check that setting `data` to "puf" uses the puf file """ - baseline = False start_year = 2016 reform = {"II_em": {2017: 10000}} # puf.csv in ogusa/ if os.path.exists(PUF_PATH): calc = get_micro_data.get_calculator( - baseline, start_year, iit_reform=reform, data=PUF_PATH + start_year, iit_reform=reform, data=PUF_PATH ) # blind_head is only in the CPS file and e00700 is only in the # PUF. See taxcalc/records_variables.json @@ -91,14 +88,41 @@ def test_puf_path(): # make sure TC is looking for puf.csv with pytest.raises((IOError, ValueError), match="puf.csv"): get_micro_data.get_calculator( - baseline, start_year, iit_reform=reform, - records_start_year=CPS_START_YEAR, + records_start_year=Records.PUFCSV_YEAR, data=None, ) +@pytest.mark.needs_tmd +def test_tmd_path(): + """ + Check that setting `data` to "tmd" uses the tmd file + """ + start_year = 2016 + reform = {"II_em": {2017: 10000}} + + # puf.csv in ogusa/ + if os.path.exists(TMD_PATH): + calc = get_micro_data.get_calculator( + start_year, iit_reform=reform, data=TMD_PATH + ) + # blind_head is only in the CPS file and e00700 is only in the + # PUF. See taxcalc/records_variables.json + assert calc.array("e00700").sum() > 0 + # we do not have puf.csv + else: + # make sure TC is looking for puf.csv + with pytest.raises((IOError, ValueError), match="tmd.csv.gz"): + get_micro_data.get_calculator( + start_year, + iit_reform=reform, + records_start_year=Records.TMDCSV_YEAR, + data=TMD_PATH, + ) + + iit_reform_1 = { "II_rt1": {2017: 0.09}, "II_rt2": {2017: 0.135}, @@ -122,14 +146,13 @@ def test_puf_path(): ) def test_get_calculator_cps(baseline, iit_reform): calc = get_micro_data.get_calculator( - baseline=baseline, calculator_start_year=2017, iit_reform=iit_reform, data="cps", gfactors=GrowFactors(), - records_start_year=CPS_START_YEAR, + records_start_year=Records.CPSCSV_YEAR, ) - assert calc.current_year == CPS_START_YEAR + assert calc.current_year == Records.CPSCSV_YEAR def test_get_calculator_exception(): @@ -144,12 +167,11 @@ def test_get_calculator_exception(): } with pytest.raises(Exception): assert get_micro_data.get_calculator( - baseline=False, calculator_start_year=TC_LAST_YEAR + 1, iit_reform=iit_reform, data="cps", gfactors=GrowFactors(), - records_start_year=CPS_START_YEAR, + records_start_year=Records.CPSCSV_YEAR, ) @@ -165,11 +187,10 @@ def test_get_calculator_puf(): "II_rt7": {2017: 0.3564}, } calc = get_micro_data.get_calculator( - baseline=False, calculator_start_year=2017, iit_reform=iit_reform, data=PUF_PATH, - records_start_year=PUF_START_YEAR, + records_start_year=Records.PUFCSV_YEAR, ) assert calc.current_year == 2013 @@ -186,11 +207,10 @@ def test_get_calculator_puf_from_file(): "II_rt7": {2017: 0.3564}, } calc = get_micro_data.get_calculator( - baseline=False, calculator_start_year=2017, iit_reform=iit_reform, data=PUF_PATH, - records_start_year=PUF_START_YEAR, + records_start_year=Records.PUFCSV_YEAR, ) assert calc.current_year == 2013 @@ -232,7 +252,9 @@ def test_taxcalc_advance(): expected_dict = utils.safe_read_pickle( os.path.join(CUR_PATH, "test_io_data", "tax_dict_for_tests.pkl") ) - test_dict = get_micro_data.taxcalc_advance(True, 2028, {}, {}, "cps", 2028) + test_dict = get_micro_data.taxcalc_advance( + 2028, {}, {}, "cps", None, None, 2014, 2028 + ) for k, v in test_dict.items(): assert np.allclose(expected_dict[k], v, equal_nan=True) @@ -245,7 +267,7 @@ def test_cap_inc_mtr(): Note that this test may fail if the Tax-Calculator is not v 3.2.1 """ calc1 = get_micro_data.get_calculator( - baseline=True, calculator_start_year=2028, iit_reform={}, data="cps" + calculator_start_year=2028, iit_reform={}, data="cps" ) calc1.advance_to_year(2028) expected = np.genfromtxt(