当前位置: 首页>>代码示例>>Python>>正文


Python Calculator.advance_to_year方法代码示例

本文整理汇总了Python中taxcalc.Calculator.advance_to_year方法的典型用法代码示例。如果您正苦于以下问题:Python Calculator.advance_to_year方法的具体用法?Python Calculator.advance_to_year怎么用?Python Calculator.advance_to_year使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在taxcalc.Calculator的用法示例。


在下文中一共展示了Calculator.advance_to_year方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_Calculator_advance_to_year

# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import advance_to_year [as 别名]
def test_Calculator_advance_to_year(records_2009):
    policy = Policy()
    calc = Calculator(policy=policy, records=records_2009)
    calc.advance_to_year(2016)
    assert calc.current_year == 2016
    with pytest.raises(ValueError):
        calc.advance_to_year(2015)
开发者ID:kerkphil,项目名称:Tax-Calculator,代码行数:9,代码来源:test_calculate.py

示例2: test_itax_compare

# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import advance_to_year [as 别名]
def test_itax_compare(tests_path, using_puf, puf_fullsample, cps_fullsample):
    """
    Conduct income tax comparisons using ITAX data.
    """
    using_puf_adjust_ratios = True
    # generate 2015 estimates by AGI category using Tax-Calculator
    if using_puf:
        if using_puf_adjust_ratios:
            recs = Records(data=puf_fullsample)
        else:
            recs = Records(data=puf_fullsample, adjust_ratios=None)
    else:
        recs = Records.cps_constructor(data=cps_fullsample)
    calc = Calculator(policy=Policy(), records=recs, verbose=False)
    calc.advance_to_year(2015)
    calc.calc_all()
    # open actual output file
    if using_puf:
        afilename = os.path.join(tests_path, 'cmpi_puf_actual.txt')
    else:
        afilename = os.path.join(tests_path, 'cmpi_cps_actual.txt')
    afile = open(afilename, 'w')
    # write compare results to afile
    for cname in sorted(ITAX.keys()):
        comparison(cname, calc, ITAX, afile)
    # close actual output file
    afile.close()
    # check for differences between actual and expect output files
    efilename = afilename.replace('actual', 'expect')
    differences(afilename, efilename)
开发者ID:andersonfrailey,项目名称:Tax-Calculator,代码行数:32,代码来源:test_compare.py

示例3: test_dec_graph_plots

# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import advance_to_year [as 别名]
def test_dec_graph_plots(cps_subsample):
    pol = Policy()
    rec = Records.cps_constructor(data=cps_subsample)
    calc1 = Calculator(policy=pol, records=rec)
    year = 2020
    calc1.advance_to_year(year)
    reform = {
        'SS_Earnings_c': {year: 9e99},  # OASDI FICA tax on all earnings
        'FICA_ss_trt': {year: 0.107484}  # lower rate to keep revenue unchanged
    }
    pol.implement_reform(reform)
    calc2 = Calculator(policy=pol, records=rec)
    calc2.advance_to_year(year)
    assert calc1.current_year == calc2.current_year
    calc1.calc_all()
    calc2.calc_all()
    fig = calc1.decile_graph(calc2)
    assert fig
    dt1, dt2 = calc1.distribution_tables(calc2, 'weighted_deciles')
    dta = dec_graph_data(dt1, dt2, year,
                         include_zero_incomes=True,
                         include_negative_incomes=False)
    assert isinstance(dta, dict)
    dta = dec_graph_data(dt1, dt2, year,
                         include_zero_incomes=False,
                         include_negative_incomes=True)
    assert isinstance(dta, dict)
    dta = dec_graph_data(dt1, dt2, year,
                         include_zero_incomes=False,
                         include_negative_incomes=False)
    assert isinstance(dta, dict)
开发者ID:andersonfrailey,项目名称:Tax-Calculator,代码行数:33,代码来源:test_utils.py

示例4: diff_in_revenue

# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import advance_to_year [as 别名]
def diff_in_revenue(reform_on_II, orig_reform):
    policy_func = Policy()
    puf = pd.read_csv("./puf.csv")
    records_func = Records(puf)
    calc_func = Calculator(policy = policy_func, records = records_func)
    policy_bench = Policy()
    records_bench = Records(puf)
    calc_bench = Calculator(policy = policy_bench, records = records_bench)
    reform = {
        CURRENT_YEAR:{
        "_II_rt1":[max(policy_bench._II_rt1[0] *(1 - reform_on_II),0.0)],
        "_II_rt2":[max(policy_bench._II_rt2[0] *(1 - reform_on_II),0.0)],
        "_II_rt3":[max(policy_bench._II_rt3[0] *(1 - reform_on_II),0.0)],
        "_II_rt4":[max(policy_bench._II_rt4[0] *(1 - reform_on_II),0.0)],
        "_II_rt5":[max(policy_bench._II_rt5[0] *(1 - reform_on_II),0.0)],
        "_II_rt6":[max(policy_bench._II_rt6[0] *(1 - reform_on_II),0.0)],
        "_II_rt7":[max(policy_bench._II_rt7[0] *(1 - reform_on_II),0.0)]}
    }
    policy_func.implement_reform(reform)
    policy_func.implement_reform(orig_reform)
    calc_func.advance_to_year(CURRENT_YEAR)
    calc_bench.advance_to_year(CURRENT_YEAR)
    calc_func.calc_all()
    calc_bench.calc_all()
    ans = ((calc_bench.records._combined*calc_bench.records.s006).sum()-(calc_func.records._combined*calc_func.records.s006).sum())
    print("diff in revenue is ", ans)
    return ans
开发者ID:MattHJensen,项目名称:plots,代码行数:29,代码来源:data.py

示例5: taxcalc_results

# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import advance_to_year [as 别名]
def taxcalc_results(start_year, reform_dict, itax_clp, ptax_clp):
    """
    Use taxcalc package on this computer to compute aggregate income tax and
    payroll tax revenue difference (between reform and current-law policy)
    for ten years beginning with the specified start_year using the specified
    reform_dict dictionary and the two specified current-law-policy results
    dictionaries.
    Return two aggregate tax revenue difference dictionaries indexed by
    calendar year.
    """
    pol = Policy()
    pol.implement_reform(reform_dict)
    calc = Calculator(policy=pol,
                      records=Records(data=PUF_PATH),
                      verbose=False)
    calc.advance_to_year(start_year)
    nyears = NUMBER_OF_YEARS
    adts = list()
    for iyr in range(-1, nyears - 1):
        calc.calc_all()
        adts.append(create_diagnostic_table(calc))
        if iyr < nyears:
            calc.increment_year()
    adt = pd.concat(adts, axis=1)
    # note that adt is Pandas DataFrame object
    itax_ref = adt.xs('Ind Income Tax ($b)').to_dict()
    ptax_ref = adt.xs('Payroll Taxes ($b)').to_dict()
    itax_diff = {}
    ptax_diff = {}
    for year in itax_ref:
        itax_diff[year] = round(itax_ref[year] - itax_clp[year], 1)
        ptax_diff[year] = round(ptax_ref[year] - ptax_clp[year], 1)
    return (itax_diff, ptax_diff)
开发者ID:salimfurth,项目名称:Tax-Calculator,代码行数:35,代码来源:reforms.py

示例6: test_Calculator_advance_to_year

# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import advance_to_year [as 别名]
def test_Calculator_advance_to_year():
    policy = Policy()
    puf = Records(data=TAXDATA, weights=WEIGHTS, start_year=2009)
    calc = Calculator(policy=policy, records=puf)
    calc.advance_to_year(2016)
    assert calc.current_year == 2016
    with pytest.raises(ValueError):
        calc.advance_to_year(2015)
开发者ID:AHYANBusinessSolution,项目名称:Tax-Calculator,代码行数:10,代码来源:test_calculate.py

示例7: test_calculator_advance_to_year

# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import advance_to_year [as 别名]
def test_calculator_advance_to_year(cps_subsample):
    """
    Test Calculator advance_to_year method.
    """
    rec = Records.cps_constructor(data=cps_subsample)
    pol = Policy()
    calc = Calculator(policy=pol, records=rec)
    calc.advance_to_year(2016)
    assert calc.current_year == 2016
    with pytest.raises(ValueError):
        calc.advance_to_year(2015)
开发者ID:codykallen,项目名称:Tax-Calculator,代码行数:13,代码来源:test_calculator.py

示例8: fixture_tc_objs

# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import advance_to_year [as 别名]
def fixture_tc_objs(request, reform_xx, puf_subsample, cps_subsample):
    """
    Fixture for creating Tax-Calculator objects that use the PUF and
    use the CPS (called only twice: once for PUF and once for CPS)
    """
    puftest = request.param
    p_xx = Policy()
    p_xx.implement_reform(reform_xx, raise_errors=False)
    if puftest:
        rec_xx = Records(data=puf_subsample)
    else:
        rec_xx = Records.cps_constructor(data=cps_subsample)
    c_xx = Calculator(policy=p_xx, records=rec_xx)
    c_xx.advance_to_year(TEST_YEAR)
    c_xx.calc_all()
    return rec_xx, c_xx, puftest
开发者ID:andersonfrailey,项目名称:Tax-Calculator,代码行数:18,代码来源:test_compatible_data.py

示例9: reform_results

# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import advance_to_year [as 别名]
def reform_results(rid, reform_dict, puf_data, reform_2017_law):
    """
    Return actual results of the reform specified by rid and reform_dict.
    """
    # pylint: disable=too-many-locals
    rec = Records(data=puf_data)
    # create baseline Calculator object, calc1
    pol = Policy()
    if reform_dict['baseline'] == '2017_law.json':
        pol.implement_reform(reform_2017_law)
    elif reform_dict['baseline'] == 'policy_current_law.json':
        pass
    else:
        msg = 'illegal baseline value {}'
        raise ValueError(msg.format(reform_dict['baseline']))
    calc1 = Calculator(policy=pol, records=rec, verbose=False)
    # create reform Calculator object, calc2
    start_year = reform_dict['start_year']
    reform = dict()
    for name, value in reform_dict['value'].items():
        reform[name] = {start_year: value}
    pol.implement_reform(reform)
    calc2 = Calculator(policy=pol, records=rec, verbose=False)
    # increment both Calculator objects to reform's start_year
    calc1.advance_to_year(start_year)
    calc2.advance_to_year(start_year)
    # calculate baseline and reform output for several years
    output_type = reform_dict['output_type']
    num_years = 4
    results = list()
    for _ in range(0, num_years):
        calc1.calc_all()
        baseline = calc1.array(output_type)
        calc2.calc_all()
        reform = calc2.array(output_type)
        diff = reform - baseline
        weighted_sum_diff = (diff * calc1.array('s006')).sum() * 1.0e-9
        results.append(weighted_sum_diff)
        calc1.increment_year()
        calc2.increment_year()
    # write actual results to actual_str
    actual_str = '{}'.format(rid)
    for iyr in range(0, num_years):
        actual_str += ',{:.1f}'.format(results[iyr])
    return actual_str
开发者ID:open-source-economics,项目名称:Tax-Calculator,代码行数:47,代码来源:test_reforms.py

示例10: test_mtr_graph_data

# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import advance_to_year [as 别名]
def test_mtr_graph_data(records_2009):
    calc = Calculator(policy=Policy(), records=records_2009)
    with pytest.raises(ValueError):
        gdata = mtr_graph_data(calc, calc, mars="bad", income_measure="agi", dollar_weighting=True)
    with pytest.raises(ValueError):
        gdata = mtr_graph_data(calc, calc, mars=0, income_measure="expanded_income", dollar_weighting=True)
    with pytest.raises(ValueError):
        gdata = mtr_graph_data(calc, calc, mars=list())
    with pytest.raises(ValueError):
        gdata = mtr_graph_data(calc, calc, mtr_measure="badtax")
    with pytest.raises(ValueError):
        gdata = mtr_graph_data(calc, calc, income_measure="badincome")
    with pytest.raises(ValueError):
        calcx = Calculator(policy=Policy(), records=records_2009)
        calcx.advance_to_year(2020)
        gdata = mtr_graph_data(calcx, calc)
    gdata = mtr_graph_data(calc, calc, mars=1, mtr_wrt_full_compen=True, income_measure="wages", dollar_weighting=True)
    assert type(gdata) == dict
开发者ID:codykallen,项目名称:Tax-Calculator,代码行数:20,代码来源:test_utils.py

示例11: test_atr_graph_data

# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import advance_to_year [as 别名]
def test_atr_graph_data(records_2009):
    calc = Calculator(policy=Policy(), records=records_2009)
    with pytest.raises(ValueError):
        gdata = atr_graph_data(calc, calc, mars="bad")
    with pytest.raises(ValueError):
        gdata = atr_graph_data(calc, calc, mars=0)
    with pytest.raises(ValueError):
        gdata = atr_graph_data(calc, calc, mars=list())
    with pytest.raises(ValueError):
        gdata = atr_graph_data(calc, calc, atr_measure="badtax")
    with pytest.raises(ValueError):
        calcx = Calculator(policy=Policy(), records=records_2009)
        calcx.advance_to_year(2020)
        gdata = atr_graph_data(calcx, calc)
    gdata = atr_graph_data(calc, calc, mars=1, atr_measure="combined")
    gdata = atr_graph_data(calc, calc, atr_measure="itax")
    gdata = atr_graph_data(calc, calc, atr_measure="ptax")
    assert type(gdata) == dict
开发者ID:codykallen,项目名称:Tax-Calculator,代码行数:20,代码来源:test_utils.py

示例12: test_mtr_pt_active

# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import advance_to_year [as 别名]
def test_mtr_pt_active(puf_subsample):
    """
    Test whether including wages in active income causes
    MTRs on e00900p and e26270 to be less than -1 (i.e., -100%)
    """
    # pylint: disable=too-many-locals
    rec = Records(data=puf_subsample)
    reform_year = 2018
    # create current-law Calculator object, calc1
    pol1 = Policy()
    calc1 = Calculator(policy=pol1, records=rec)
    calc1.advance_to_year(reform_year)
    calc1.calc_all()
    mtr1_e00900p = calc1.mtr('e00900p')[2]
    mtr1_e26270 = calc1.mtr('e26270')[2]
    assert min(mtr1_e00900p) > -1
    assert min(mtr1_e26270) > -1
    # change PT rates, calc2
    reform2 = {'PT_rt7': {reform_year: 0.35}}
    pol2 = Policy()
    pol2.implement_reform(reform2)
    calc2 = Calculator(policy=pol2, records=rec)
    calc2.advance_to_year(reform_year)
    calc2.calc_all()
    mtr2_e00900p = calc2.mtr('e00900p')[2]
    mtr2_e26270 = calc2.mtr('e26270')[2]
    assert min(mtr2_e00900p) > -1
    assert min(mtr2_e26270) > -1
    # change PT_wages_active_income
    reform3 = {'PT_wages_active_income': {reform_year: True}}
    pol3 = Policy()
    pol3.implement_reform(reform3)
    calc3 = Calculator(policy=pol3, records=rec)
    calc3.advance_to_year(reform_year)
    calc3.calc_all()
    mtr3_e00900p = calc3.mtr('e00900p')[2]
    mtr3_e26270 = calc3.mtr('e26270')[2]
    assert min(mtr3_e00900p) > -1
    assert min(mtr3_e26270) > -1
    # change PT rates and PT_wages_active_income
    reform4 = {
        'PT_wages_active_income': {reform_year: True},
        'PT_rt7': {reform_year: 0.35}
    }
    pol4 = Policy()
    pol4.implement_reform(reform4)
    calc4 = Calculator(policy=pol4, records=rec)
    calc4.advance_to_year(reform_year)
    calc4.calc_all()
    mtr4_e00900p = calc4.mtr('e00900p')[2]
    mtr4_e26270 = calc4.mtr('e26270')[2]
    assert min(mtr4_e00900p) > -1
    assert min(mtr4_e26270) > -1
开发者ID:andersonfrailey,项目名称:Tax-Calculator,代码行数:55,代码来源:test_pufcsv.py

示例13: test_ce_aftertax_income

# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import advance_to_year [as 别名]
def test_ce_aftertax_income(cps_subsample):
    # test certainty_equivalent() function with con>cmin
    con = 5000
    cmin = 1000
    assert con == round(certainty_equivalent(con, 0, cmin), 6)
    assert con > round(certainty_equivalent((math.log(con) - 0.1), 1, cmin), 6)
    # test certainty_equivalent() function with con<cmin
    con = 500
    cmin = 1000
    assert con == round(certainty_equivalent(con, 0, cmin), 6)
    # test with require_no_agg_tax_change equal to False
    rec = Records.cps_constructor(data=cps_subsample)
    cyr = 2020
    # specify calc1 and calc_all() for cyr
    pol = Policy()
    calc1 = Calculator(policy=pol, records=rec)
    calc1.advance_to_year(cyr)
    calc1.calc_all()
    # specify calc2 and calc_all() for cyr
    reform = {'II_em': {2019: 1000}}
    pol.implement_reform(reform)
    calc2 = Calculator(policy=pol, records=rec)
    calc2.advance_to_year(cyr)
    calc2.calc_all()
    df1 = calc1.dataframe(['s006', 'combined', 'expanded_income'])
    df2 = calc2.dataframe(['s006', 'combined', 'expanded_income'])
    cedict = ce_aftertax_expanded_income(df1, df2,
                                         require_no_agg_tax_change=False)
    assert isinstance(cedict, dict)
    np.allclose(cedict['ceeu1'], [55641, 27167, 5726, 2229, 1565],
                atol=0.5, rtol=0.0)
    np.allclose(cedict['ceeu2'], [54629, 26698, 5710, 2229, 1565],
                atol=0.5, rtol=0.0)
    # test with require_no_agg_tax_change equal to True
    with pytest.raises(ValueError):
        ce_aftertax_expanded_income(df1, df2, require_no_agg_tax_change=True)
    # test with require_no_agg_tax_change equal to False and custom_params
    params = {'crra_list': [0, 2], 'cmin_value': 2000}
    with pytest.raises(ValueError):
        ce_aftertax_expanded_income(df1, df2, require_no_agg_tax_change=True,
                                    custom_params=params)
开发者ID:open-source-economics,项目名称:Tax-Calculator,代码行数:43,代码来源:test_utils.py

示例14: test_credit_reforms

# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import advance_to_year [as 别名]
def test_credit_reforms(puf_subsample):
    """
    Test personal credit reforms using puf.csv subsample
    """
    rec = Records(data=puf_subsample)
    reform_year = 2017
    # create current-law Calculator object, calc1
    pol = Policy()
    calc1 = Calculator(policy=pol, records=rec)
    calc1.advance_to_year(reform_year)
    calc1.calc_all()
    itax1 = calc1.weighted_total('iitax')
    # create personal-refundable-credit-reform Calculator object, calc2
    reform = {'II_credit': {reform_year: [1000, 1000, 1000, 1000, 1000]}}
    pol.implement_reform(reform)
    calc2 = Calculator(policy=pol, records=rec)
    calc2.advance_to_year(reform_year)
    calc2.calc_all()
    itax2 = calc2.weighted_total('iitax')
    # create personal-nonrefundable-credit-reform Calculator object, calc3
    reform = {'II_credit_nr': {reform_year: [1000, 1000, 1000, 1000, 1000]}}
    pol = Policy()
    pol.implement_reform(reform)
    calc3 = Calculator(policy=pol, records=rec)
    calc3.advance_to_year(reform_year)
    calc3.calc_all()
    itax3 = calc3.weighted_total('iitax')
    # check income tax revenues generated by the three Calculator objects
    assert itax2 < itax1  # because refundable credits lower revenues
    assert itax3 > itax2  # because nonrefundable credits lower revenues less
    assert itax3 < itax1  # because nonrefundable credits lower revenues some
开发者ID:andersonfrailey,项目名称:Tax-Calculator,代码行数:33,代码来源:test_pufcsv.py

示例15: run_reform

# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import advance_to_year [as 别名]
def run_reform(name, reform, epsilon):

    puf = pd.read_csv("./puf.csv")
    policy_base = Policy(start_year=2013)
    records_base = Records(puf)
    policy_reform = Policy()
    records_reform = Records(puf)
    calcbase = Calculator(policy = policy_base, records = records_base)
    calcreform = Calculator(policy = policy_reform, records = records_reform)
    policy_reform.implement_reform(reform)
    calcbase.advance_to_year(CURRENT_YEAR)
    calcreform.advance_to_year(CURRENT_YEAR)
    calcbase.calc_all()
    calcreform.calc_all()
    diff_df = get_diff(calcbase, calcreform, name)
    data_df = print_data(calcbase, calcreform, weights = weighted, tab = 'c00100', name=name)
    equiv_tax_cut = reform_equiv(reform, epsilon)
    total_rev_raise = agg_diff(calcbase, calcreform)
    delta_num_filers = agg_num_delta(calcbase, calcreform)

    #diff_df['equiv_rate_cut'] = len(diff_df)*[equiv_tax_cut]
    return diff_df, data_df, equiv_tax_cut, total_rev_raise, delta_num_filers
开发者ID:MattHJensen,项目名称:plots,代码行数:24,代码来源:data.py


注:本文中的taxcalc.Calculator.advance_to_year方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。