예제 #1
0
def test_creation_with_aging(rawinputfile, reformfile0):
    """
    Test TaxCalcIO instantiation with/without no policy reform and with aging.
    """
    taxyear = 2021
    tcio = TaxCalcIO(input_data=rawinputfile.name,
                     tax_year=taxyear,
                     reform=reformfile0.name,
                     assump=None)
    assert len(tcio.errmsg) == 0
    tcio.init(input_data=rawinputfile.name,
              tax_year=taxyear,
              reform=reformfile0.name,
              assump=None,
              growdiff_response=Growdiff(),
              aging_input_data=True,
              exact_calculations=False)
    assert len(tcio.errmsg) == 0
    assert tcio.tax_year() == taxyear
    taxyear = 2016
    tcio = TaxCalcIO(input_data=rawinputfile.name,
                     tax_year=taxyear,
                     reform=None,
                     assump=None)
    assert len(tcio.errmsg) == 0
    tcio.init(input_data=rawinputfile.name,
              tax_year=taxyear,
              reform=None,
              assump=None,
              growdiff_response=None,
              aging_input_data=True,
              exact_calculations=False)
    assert len(tcio.errmsg) == 0
    assert tcio.tax_year() == taxyear
예제 #2
0
def test_ctor_init_with_cps_files():
    """
    Test use of CPS input files.
    """
    # specify valid tax_year for cps.csv input data
    txyr = 2020
    tcio = TaxCalcIO('cps.csv', txyr, None, None, None)
    tcio.init('cps.csv',
              txyr,
              None,
              None,
              None,
              growdiff_response=None,
              aging_input_data=True,
              exact_calculations=False)
    assert not tcio.errmsg
    assert tcio.tax_year() == txyr
    # specify invalid tax_year for cps.csv input data
    txyr = 2013
    tcio = TaxCalcIO('cps.csv', txyr, None, None, None)
    tcio.init('cps.csv',
              txyr,
              None,
              None,
              None,
              growdiff_response=None,
              aging_input_data=True,
              exact_calculations=False)
    assert tcio.errmsg
예제 #3
0
def test_creation_with_aging(reformfile0):
    """
    Test TaxCalcIO instantiation with/without no policy reform and with aging.
    """
    taxyear = 2021
    tcio = TaxCalcIO(input_data=pd.read_csv(StringIO(RAWINPUT)),
                     tax_year=taxyear,
                     baseline=None,
                     reform=reformfile0.name,
                     assump=None)
    assert not tcio.errmsg
    tcio.init(input_data=pd.read_csv(StringIO(RAWINPUT)),
              tax_year=taxyear,
              baseline=None,
              reform=reformfile0.name,
              assump=None,
              aging_input_data=True,
              exact_calculations=False)
    assert not tcio.errmsg
    assert tcio.tax_year() == taxyear
    taxyear = 2016
    tcio = TaxCalcIO(input_data=pd.read_csv(StringIO(RAWINPUT)),
                     tax_year=taxyear,
                     baseline=None,
                     reform=None,
                     assump=None)
    assert not tcio.errmsg
    tcio.init(input_data=pd.read_csv(StringIO(RAWINPUT)),
              tax_year=taxyear,
              baseline=None,
              reform=None,
              assump=None,
              aging_input_data=True,
              exact_calculations=False)
    assert not tcio.errmsg
    assert tcio.tax_year() == taxyear
def test_creation_with_aging(reformfile0):
    """
    Test TaxCalcIO instantiation with/without no policy reform and with aging.
    """
    taxyear = 2021
    tcio = TaxCalcIO(input_data=pd.read_csv(StringIO(RAWINPUT)),
                     tax_year=taxyear,
                     baseline=None,
                     reform=reformfile0.name,
                     assump=None)
    assert not tcio.errmsg
    tcio.init(input_data=pd.read_csv(StringIO(RAWINPUT)),
              tax_year=taxyear,
              baseline=None,
              reform=reformfile0.name,
              assump=None,
              aging_input_data=True,
              exact_calculations=False)
    assert not tcio.errmsg
    assert tcio.tax_year() == taxyear
    taxyear = 2016
    tcio = TaxCalcIO(input_data=pd.read_csv(StringIO(RAWINPUT)),
                     tax_year=taxyear,
                     baseline=None,
                     reform=None,
                     assump=None)
    assert not tcio.errmsg
    tcio.init(input_data=pd.read_csv(StringIO(RAWINPUT)),
              tax_year=taxyear,
              baseline=None,
              reform=None,
              assump=None,
              aging_input_data=True,
              exact_calculations=False)
    assert not tcio.errmsg
    assert tcio.tax_year() == taxyear
예제 #5
0
def test_ceeu_output(lumpsumreformfile):
    """
    Test TaxCalcIO calculate method with no output writing using ceeu option.
    """
    taxyear = 2020
    recdict = {'RECID': 1, 'MARS': 1, 'e00300': 100000, 's006': 1e8}
    recdf = pd.DataFrame(data=recdict, index=[0])
    tcio = TaxCalcIO(input_data=recdf,
                     tax_year=taxyear,
                     reform=lumpsumreformfile.name,
                     assump=None,
                     growdiff_response=None,
                     aging_input_data=False,
                     exact_calculations=False)
    tcio.static_analysis(writing_output_file=False, output_ceeu=True)
    assert tcio.tax_year() == taxyear
def test_ctor_init_with_cps_files():
    """
    Test use of CPS input files.
    """
    # specify valid tax_year for cps.csv input data
    txyr = 2020
    tcio = TaxCalcIO('cps.csv', txyr, None, None, None)
    tcio.init('cps.csv', txyr, None, None, None,
              aging_input_data=True,
              exact_calculations=False)
    assert not tcio.errmsg
    assert tcio.tax_year() == txyr
    # specify invalid tax_year for cps.csv input data
    txyr = 2013
    tcio = TaxCalcIO('cps.csv', txyr, None, None, None)
    tcio.init('cps.csv', txyr, None, None, None,
              aging_input_data=True,
              exact_calculations=False)
    assert tcio.errmsg
예제 #7
0
def test_analyze_warnings_print(warnreformfile):
    """
    Test TaxCalcIO.analyze method when there is a reform warning.
    """
    taxyear = 2020
    recdict = {'RECID': 1, 'MARS': 1, 'e00300': 100000, 's006': 1e8}
    recdf = pd.DataFrame(data=recdict, index=[0])
    tcio = TaxCalcIO(input_data=recdf,
                     tax_year=taxyear,
                     reform=warnreformfile.name,
                     assump=None)
    assert len(tcio.errmsg) == 0
    tcio.init(input_data=recdf,
              tax_year=taxyear,
              reform=warnreformfile.name,
              assump=None,
              growdiff_response=None,
              aging_input_data=False,
              exact_calculations=False)
    assert len(tcio.errmsg) == 0
    tcio.analyze(writing_output_file=False, output_ceeu=False)
    assert tcio.tax_year() == taxyear
예제 #8
0
def test_ceeu_with_behavior(lumpsumreformfile, assumpfile2):
    """
    Test TaxCalcIO.analyze method when assuming behavior & doing ceeu calcs.
    """
    taxyear = 2020
    recdict = {'RECID': 1, 'MARS': 1, 'e00300': 100000, 's006': 1e8}
    recdf = pd.DataFrame(data=recdict, index=[0])
    tcio = TaxCalcIO(input_data=recdf,
                     tax_year=taxyear,
                     reform=lumpsumreformfile.name,
                     assump=assumpfile2.name)
    assert len(tcio.errmsg) == 0
    tcio.init(input_data=recdf,
              tax_year=taxyear,
              reform=lumpsumreformfile.name,
              assump=assumpfile2.name,
              growdiff_response=None,
              aging_input_data=False,
              exact_calculations=False)
    assert len(tcio.errmsg) == 0
    tcio.analyze(writing_output_file=False, output_ceeu=True)
    assert tcio.tax_year() == taxyear
def test_analyze_warnings_print(warnreformfile):
    """
    Test TaxCalcIO.analyze method when there is a reform warning.
    """
    taxyear = 2020
    recdict = {'RECID': 1, 'MARS': 1, 'e00300': 100000, 's006': 1e8}
    recdf = pd.DataFrame(data=recdict, index=[0])
    tcio = TaxCalcIO(input_data=recdf,
                     tax_year=taxyear,
                     baseline=None,
                     reform=warnreformfile.name,
                     assump=None)
    assert not tcio.errmsg
    tcio.init(input_data=recdf,
              tax_year=taxyear,
              baseline=None,
              reform=warnreformfile.name,
              assump=None,
              aging_input_data=False,
              exact_calculations=False)
    assert not tcio.errmsg
    tcio.analyze(writing_output_file=False)
    assert tcio.tax_year() == taxyear
예제 #10
0
def test_ceeu_output2():
    """
    Test TaxCalcIO calculate method with no output writing using ceeu option.
    """
    taxyear = 2020
    recdict = {'RECID': 1, 'MARS': 1, 'e00300': 100000, 's006': 1e8}
    recdf = pd.DataFrame(data=recdict, index=[0])
    tcio = TaxCalcIO(input_data=recdf,
                     tax_year=taxyear,
                     baseline=None,
                     reform=None,
                     assump=None)
    assert not tcio.errmsg
    tcio.init(input_data=recdf,
              tax_year=taxyear,
              baseline=None,
              reform=None,
              assump=None,
              growdiff_response=None,
              aging_input_data=False,
              exact_calculations=False)
    assert not tcio.errmsg
    tcio.analyze(writing_output_file=False, output_ceeu=True)
    assert tcio.tax_year() == taxyear