• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python taxcalc.Policy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_reform_pkey_year

def test_reform_pkey_year():
    with pytest.raises(ValueError):
        rdict = Policy._reform_pkey_year({4567: {2013: [40000]}})
    with pytest.raises(ValueError):
        rdict = Policy._reform_pkey_year({'_II_em': 40000})
    with pytest.raises(ValueError):
        rdict = Policy._reform_pkey_year({'_II_em': {'2013': [40000]}})
开发者ID:akshaya-trivedi,项目名称:Tax-Calculator,代码行数:7,代码来源:test_policy.py


示例2: test_make_Calculator_with_reform_after_start_year

def test_make_Calculator_with_reform_after_start_year():
    # create Policy object using custom indexing rates
    irates = {2013: 0.01, 2014: 0.01, 2015: 0.02, 2016: 0.01, 2017: 0.03}
    parm = Policy(start_year=2013, num_years=len(irates),
                  inflation_rates=irates)
    # specify reform in 2015, which is two years after Policy start_year
    reform = {2015: {}, 2016: {}}
    reform[2015]['_STD_Aged'] = [[1600, 1300, 1600, 1300, 1600, 1300]]
    reform[2015]['_II_em'] = [5000]
    reform[2016]['_II_em'] = [6000]
    reform[2016]['_II_em_cpi'] = False
    parm.implement_reform(reform)
    recs = Records(data=TAX_DTA, weights=WEIGHTS, start_year=2009)
    calc = Calculator(policy=parm, records=recs)
    # compare actual and expected parameter values over all years
    exp_STD_Aged = np.array([[1500, 1200, 1200, 1500, 1500, 1200],
                             [1550, 1200, 1200, 1550, 1550, 1200],
                             [1600, 1300, 1600, 1300, 1600, 1300],
                             [1632, 1326, 1632, 1326, 1632, 1326],
                             [1648, 1339, 1648, 1339, 1648, 1339]])
    exp_II_em = np.array([3900, 3950, 5000, 6000, 6000])
    assert_array_equal(calc.policy._STD_Aged, exp_STD_Aged)
    assert_array_equal(calc.policy._II_em, exp_II_em)
    # compare actual and expected values for 2015
    calc.increment_year()
    calc.increment_year()
    assert calc.current_year == 2015
    exp_2015_II_em = 5000
    assert_array_equal(calc.policy.II_em, exp_2015_II_em)
    exp_2015_STD_Aged = np.array([1600, 1300, 1600, 1300, 1600, 1300])
    assert_array_equal(calc.policy.STD_Aged, exp_2015_STD_Aged)
开发者ID:bjl3,项目名称:Tax-Calculator,代码行数:31,代码来源:test_calculate.py


示例3: test_strip_Nones

def test_strip_Nones():
    x = [None, None]
    assert Policy.strip_Nones(x) == []
    x = [1, 2, None]
    assert Policy.strip_Nones(x) == [1, 2]
    x = [[1, 2, 3], [4, None, None]]
    assert Policy.strip_Nones(x) == [[1, 2, 3], [4, -1, -1]]
开发者ID:chun1211,项目名称:Tax-Calculator,代码行数:7,代码来源:test_utils.py


示例4: test_Policy_reform_makes_no_changes_before_year

def test_Policy_reform_makes_no_changes_before_year():
    ppo = Policy(start_year=2013)
    reform = {2015: {'_II_em': [4400], '_II_em_cpi': True}}
    ppo.implement_reform(reform)
    ppo.set_year(2015)
    assert_array_equal(ppo._II_em[:3], np.array([3900, 3950, 4400]))
    assert ppo.II_em == 4400
开发者ID:kathleenszabo,项目名称:Tax-Calculator,代码行数:7,代码来源:test_policy.py


示例5: test_Policy_reform_after_start_year

def test_Policy_reform_after_start_year():
    ppo = Policy(start_year=2013)
    reform = {2015: {'_STD_Aged': [[1400, 1100, 1100, 1400, 1400, 1199]]}}
    ppo.implement_reform(reform)
    ppo.set_year(2015)
    assert_array_equal(ppo.STD_Aged,
                       np.array([1400, 1100, 1100, 1400, 1400, 1199]))
开发者ID:kathleenszabo,项目名称:Tax-Calculator,代码行数:7,代码来源:test_policy.py


示例6: test_make_Calculator_increment_years_first

def test_make_Calculator_increment_years_first():
    # create Policy object with custom indexing rates and policy reform
    irates = {2013: 0.01, 2014: 0.01, 2015: 0.02, 2016: 0.01, 2017: 0.03}
    policy = Policy(start_year=2013, inflation_rates=irates,
                    num_years=len(irates))
    reform = {2015: {}, 2016: {}}
    reform[2015]['_STD_Aged'] = [[1600, 1300, 1600, 1300, 1600, 1300]]
    reform[2015]['_II_em'] = [5000]
    reform[2016]['_II_em'] = [6000]
    reform[2016]['_II_em_cpi'] = False
    policy.implement_reform(reform)
    # create Records object by reading 1991 data and saying it is 2009 data
    tax_dta = pd.read_csv(TAX_DTA_PATH, compression='gzip')
    puf = Records(tax_dta, weights=WEIGHTS, start_year=2009)
    # create Calculator object with Policy object as modified by reform
    calc = Calculator(policy=policy, records=puf)
    # compare expected policy parameter values with those embedded in calc
    exp_STD_Aged = np.array([[1500, 1200, 1200, 1500, 1500, 1200],
                             [1550, 1200, 1200, 1550, 1550, 1200],
                             [1600, 1300, 1600, 1300, 1600, 1300],
                             [1632, 1326, 1632, 1326, 1632, 1326],
                             [1648, 1339, 1648, 1339, 1648, 1339]])
    exp_II_em = np.array([3900, 3950, 5000, 6000, 6000])
    assert_array_equal(calc.policy._STD_Aged, exp_STD_Aged)
    assert_array_equal(calc.policy._II_em, exp_II_em)
开发者ID:MattHJensen,项目名称:taxcalc,代码行数:25,代码来源:test_calculate.py


示例7: test_make_Calculator_with_reform_after_start_year

def test_make_Calculator_with_reform_after_start_year(records_2009):
    # create Policy object using custom indexing rates
    irates = {2013: 0.01, 2014: 0.01, 2015: 0.02, 2016: 0.01, 2017: 0.03}
    parm = Policy(start_year=2013, num_years=len(irates),
                  inflation_rates=irates)
    # specify reform in 2015, which is two years after Policy start_year
    reform = {2015: {}, 2016: {}}
    reform[2015]['_STD_Aged'] = [[1600, 1300, 1600, 1300, 1600, 1300]]
    reform[2015]['_II_em'] = [5000]
    reform[2016]['_II_em'] = [6000]
    reform[2016]['_II_em_cpi'] = False
    parm.implement_reform(reform)
    calc = Calculator(policy=parm, records=records_2009)
    # compare actual and expected parameter values over all years
    assert np.allclose(calc.policy._STD_Aged,
                       np.array([[1500, 1200, 1200, 1500, 1500, 1200],
                                 [1550, 1200, 1200, 1550, 1550, 1200],
                                 [1600, 1300, 1600, 1300, 1600, 1300],
                                 [1632, 1326, 1632, 1326, 1632, 1326],
                                 [1648, 1339, 1648, 1339, 1648, 1339]]),
                       atol=0.5, rtol=0.0)  # handles rounding to dollars
    assert np.allclose(calc.policy._II_em,
                       np.array([3900, 3950, 5000, 6000, 6000]))
    # compare actual and expected values for 2015
    calc.increment_year()
    calc.increment_year()
    assert calc.current_year == 2015
    assert np.allclose(calc.policy.II_em, 5000)
    assert np.allclose(calc.policy.STD_Aged,
                       np.array([1600, 1300, 1600, 1300, 1600, 1300]))
开发者ID:kerkphil,项目名称:Tax-Calculator,代码行数:30,代码来源:test_calculate.py


示例8: test_calculator_using_nonstd_input

def test_calculator_using_nonstd_input(rawinputfile):
    """
    Test Calculator using non-standard input records.
    """
    # check Calculator handling of raw, non-standard input data with no aging
    pol = Policy()
    pol.set_year(RAWINPUTFILE_YEAR)  # set policy params to input data year
    nonstd = Records(data=rawinputfile.name,
                     gfactors=None,  # keeps raw data unchanged
                     weights=None,
                     start_year=RAWINPUTFILE_YEAR)  # set raw input data year
    assert nonstd.array_length == RAWINPUTFILE_FUNITS
    calc = Calculator(policy=pol, records=nonstd,
                      sync_years=False)  # keeps raw data unchanged
    assert calc.current_year == RAWINPUTFILE_YEAR
    calc.calc_all()
    assert calc.weighted_total('e00200') == 0
    assert calc.total_weight() == 0
    varlist = ['RECID', 'MARS']
    dframe = calc.dataframe(varlist)
    assert isinstance(dframe, pd.DataFrame)
    assert dframe.shape == (RAWINPUTFILE_FUNITS, len(varlist))
    mars = calc.array('MARS')
    assert isinstance(mars, np.ndarray)
    assert mars.shape == (RAWINPUTFILE_FUNITS,)
    exp_iitax = np.zeros((nonstd.array_length,))
    assert np.allclose(calc.array('iitax'), exp_iitax)
    mtr_ptax, _, _ = calc.mtr(wrt_full_compensation=False)
    exp_mtr_ptax = np.zeros((nonstd.array_length,))
    exp_mtr_ptax.fill(0.153)
    assert np.allclose(mtr_ptax, exp_mtr_ptax)
开发者ID:codykallen,项目名称:Tax-Calculator,代码行数:31,代码来源:test_calculator.py


示例9: taxcalc_results

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,代码行数:33,代码来源:reforms.py


示例10: test_make_calculator_with_policy_reform

def test_make_calculator_with_policy_reform(cps_subsample):
    """
    Test Calculator class ctor with policy reform.
    """
    rec = Records.cps_constructor(data=cps_subsample)
    year = rec.current_year
    # create a Policy object and apply a policy reform
    pol = Policy()
    reform = {2013: {'_II_em': [4000], '_II_em_cpi': False,
                     '_STD_Aged': [[1600, 1300, 1300, 1600, 1600]],
                     '_STD_Aged_cpi': False}}
    pol.implement_reform(reform)
    # create a Calculator object using this policy reform
    calc = Calculator(policy=pol, records=rec)
    # check that Policy object embedded in Calculator object is correct
    assert calc.current_year == year
    assert calc.policy_param('II_em') == 4000
    assert np.allclose(calc.policy_param('_II_em'),
                       np.array([4000] * Policy.DEFAULT_NUM_YEARS))
    exp_STD_Aged = [[1600, 1300, 1300,
                     1600, 1600]] * Policy.DEFAULT_NUM_YEARS
    assert np.allclose(calc.policy_param('_STD_Aged'),
                       np.array(exp_STD_Aged))
    assert np.allclose(calc.policy_param('STD_Aged'),
                       np.array([1600, 1300, 1300, 1600, 1600]))
开发者ID:codykallen,项目名称:Tax-Calculator,代码行数:25,代码来源:test_calculator.py


示例11: test_make_calculator_increment_years_first

def test_make_calculator_increment_years_first(cps_subsample):
    """
    Test Calculator inflation indexing of policy parameters.
    """
    # pylint: disable=too-many-locals
    # create Policy object with policy reform
    pol = Policy()
    reform = {2015: {}, 2016: {}}
    std5 = 2000
    reform[2015]['_STD_Aged'] = [[std5, std5, std5, std5, std5]]
    reform[2015]['_II_em'] = [5000]
    reform[2016]['_II_em'] = [6000]
    reform[2016]['_II_em_cpi'] = False
    pol.implement_reform(reform)
    # create Calculator object with Policy object as modified by reform
    rec = Records.cps_constructor(data=cps_subsample)
    calc = Calculator(policy=pol, records=rec)
    # compare expected policy parameter values with those embedded in calc
    irates = pol.inflation_rates()
    syr = Policy.JSON_START_YEAR
    irate2015 = irates[2015 - syr]
    irate2016 = irates[2016 - syr]
    std6 = std5 * (1.0 + irate2015)
    std7 = std6 * (1.0 + irate2016)
    exp_STD_Aged = np.array([[1500, 1200, 1200, 1500, 1500],
                             [1550, 1200, 1200, 1550, 1550],
                             [std5, std5, std5, std5, std5],
                             [std6, std6, std6, std6, std6],
                             [std7, std7, std7, std7, std7]])
    act_STD_Aged = calc.policy_param('_STD_Aged')
    assert np.allclose(act_STD_Aged[:5], exp_STD_Aged)
    exp_II_em = np.array([3900, 3950, 5000, 6000, 6000])
    act_II_em = calc.policy_param('_II_em')
    assert np.allclose(act_II_em[:5], exp_II_em)
开发者ID:codykallen,项目名称:Tax-Calculator,代码行数:34,代码来源:test_calculator.py


示例12: test_dec_graph_plots

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,代码行数:31,代码来源:test_utils.py


示例13: test_calculator_mtr_when_PT_rates_differ

def test_calculator_mtr_when_PT_rates_differ():
    """
    Test Calculator mtr method in special case.
    """
    reform = {2013: {'_II_rt1': [0.40],
                     '_II_rt2': [0.40],
                     '_II_rt3': [0.40],
                     '_II_rt4': [0.40],
                     '_II_rt5': [0.40],
                     '_II_rt6': [0.40],
                     '_II_rt7': [0.40],
                     '_PT_rt1': [0.30],
                     '_PT_rt2': [0.30],
                     '_PT_rt3': [0.30],
                     '_PT_rt4': [0.30],
                     '_PT_rt5': [0.30],
                     '_PT_rt6': [0.30],
                     '_PT_rt7': [0.30]}}
    funit = (
        u'RECID,MARS,FLPDYR,e00200,e00200p,e00900,e00900p,extraneous\n'
        u'1,    1,   2009,  200000,200000, 100000,100000, 9999999999\n'
    )
    rec = Records(pd.read_csv(StringIO(funit)))
    pol = Policy()
    calc1 = Calculator(policy=pol, records=rec)
    (_, mtr1, _) = calc1.mtr(variable_str='p23250')
    pol.implement_reform(reform)
    calc2 = Calculator(policy=pol, records=rec)
    (_, mtr2, _) = calc2.mtr(variable_str='p23250')
    assert np.allclose(mtr1, mtr2, rtol=0.0, atol=1e-06)
开发者ID:codykallen,项目名称:Tax-Calculator,代码行数:30,代码来源:test_calculator.py


示例14: test_make_calculator_with_multiyear_reform

def test_make_calculator_with_multiyear_reform(cps_subsample):
    """
    Test Calculator class ctor with multi-year policy reform.
    """
    rec = Records.cps_constructor(data=cps_subsample)
    year = rec.current_year
    # create a Policy object and apply a policy reform
    pol = Policy()
    reform = {2015: {}, 2016: {}}
    reform[2015]['_II_em'] = [5000, 6000]  # reform values for 2015 and 2016
    reform[2015]['_II_em_cpi'] = False
    reform[2016]['_STD_Aged'] = [[1600, 1300, 1600, 1300, 1600]]
    pol.implement_reform(reform)
    # create a Calculator object using this policy-reform
    calc = Calculator(policy=pol, records=rec)
    # check that Policy object embedded in Calculator object is correct
    assert pol.num_years == Policy.DEFAULT_NUM_YEARS
    assert calc.current_year == year
    assert calc.policy_param('II_em') == 3950
    exp_II_em = [3900, 3950, 5000] + [6000] * (Policy.DEFAULT_NUM_YEARS - 3)
    assert np.allclose(calc.policy_param('_II_em'),
                       np.array(exp_II_em))
    calc.increment_year()
    calc.increment_year()
    assert calc.current_year == 2016
    assert np.allclose(calc.policy_param('STD_Aged'),
                       np.array([1600, 1300, 1600, 1300, 1600]))
开发者ID:codykallen,项目名称:Tax-Calculator,代码行数:27,代码来源:test_calculator.py


示例15: test_distribution_tables

def test_distribution_tables(cps_subsample):
    """
    Test distribution_tables method.
    """
    pol = Policy()
    recs = Records.cps_constructor(data=cps_subsample)
    calc1 = Calculator(policy=pol, records=recs)
    assert calc1.current_year == 2014
    calc1.calc_all()
    dt1, dt2 = calc1.distribution_tables(None, 'weighted_deciles')
    assert isinstance(dt1, pd.DataFrame)
    assert dt2 is None
    dt1, dt2 = calc1.distribution_tables(calc1, 'weighted_deciles')
    assert isinstance(dt1, pd.DataFrame)
    assert isinstance(dt2, pd.DataFrame)
    reform = {2014: {'_UBI_u18': [1000],
                     '_UBI_1820': [1000],
                     '_UBI_21': [1000]}}
    pol.implement_reform(reform)
    assert not pol.parameter_errors
    calc2 = Calculator(policy=pol, records=recs)
    calc2.calc_all()
    dt1, dt2 = calc1.distribution_tables(calc2, 'weighted_deciles')
    assert isinstance(dt1, pd.DataFrame)
    assert isinstance(dt2, pd.DataFrame)
开发者ID:codykallen,项目名称:Tax-Calculator,代码行数:25,代码来源:test_calculator.py


示例16: test_read_json_param_with_suffixes_and_errors

def test_read_json_param_with_suffixes_and_errors():
    """
    Test interaction of policy parameter suffixes and reform errors
    (fails without 0.10.2 bug fix as reported by Hank Doupe in PB PR#641)
    """
    reform = {
        u'policy': {
            u'_II_brk4_separate': {u'2017': [5000.0]},
            u'_STD_separate': {u'2017': [8000.0]},
            u'_STD_single': {u'2018': [1000.0]},
            u'_II_brk2_headhousehold': {u'2017': [1000.0]},
            u'_II_brk4_single': {u'2017': [500.0]},
            u'_STD_joint': {u'2017': [10000.0], u'2020': [150.0]},
            u'_II_brk2_separate': {u'2017': [1000.0]},
            u'_II_brk2_single': {u'2017': [1000.0]},
            u'_II_brk2_joint': {u'2017': [1000.0]},
            u'_FICA_ss_trt': {u'2017': [-1.0], u'2019': [0.1]},
            u'_II_brk4_headhousehold': {u'2017': [500.0]},
            u'_STD_headhousehold': {u'2017': [10000.0], u'2020': [150.0]},
            u'_ID_Medical_frt': {u'2019': [0.06]},
            u'_II_brk4_joint': {u'2017': [500.0]},
            u'_ID_BenefitSurtax_Switch_medical': {u'2017': [True]}
        }
    }
    json_reform = json.dumps(reform)
    params = Calculator.read_json_param_objects(json_reform, None)
    assert isinstance(params, dict)
    pol = Policy()
    pol.ignore_reform_errors()
    pol.implement_reform(params['policy'],
                         print_warnings=False, raise_errors=False)
    assert pol.parameter_errors
    assert pol.parameter_warnings
开发者ID:codykallen,项目名称:Tax-Calculator,代码行数:33,代码来源:test_calculator.py


示例17: diff_in_revenue

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,代码行数:27,代码来源:data.py


示例18: test_create_parameters_from_file

def test_create_parameters_from_file(policyfile):
    with open(policyfile.name) as pfile:
        policy = json.load(pfile)
    ppo = Policy(parameter_dict=policy)
    irates = Policy.default_inflation_rates()
    inf_rates = [irates[ppo.start_year + i] for i in range(0, ppo.num_years)]
    assert_allclose(ppo._almdep,
                    Policy.expand_array(np.array([7150, 7250, 7400]),
                                        inflate=True,
                                        inflation_rates=inf_rates,
                                        num_years=ppo.num_years),
                    atol=0.01, rtol=0.0)
    assert_allclose(ppo._almsep,
                    Policy.expand_array(np.array([40400, 41050]),
                                        inflate=True,
                                        inflation_rates=inf_rates,
                                        num_years=ppo.num_years),
                    atol=0.01, rtol=0.0)
    assert_allclose(ppo._rt5,
                    Policy.expand_array(np.array([0.33]),
                                        inflate=False,
                                        inflation_rates=inf_rates,
                                        num_years=ppo.num_years),
                    atol=0.01, rtol=0.0)
    assert_allclose(ppo._rt7,
                    Policy.expand_array(np.array([0.396]),
                                        inflate=False,
                                        inflation_rates=inf_rates,
                                        num_years=ppo.num_years),
                    atol=0.01, rtol=0.0)
开发者ID:chrisrytting,项目名称:Tax-Calculator,代码行数:30,代码来源:test_policy.py


示例19: test_read_json_reform_file_and_implement_reform_a

def test_read_json_reform_file_and_implement_reform_a(reform_file):
    """
    Test reading and translation of reform file into a reform dictionary
    that is then used to call implement_reform method.
    NOTE: implement_reform called when policy.current_year == policy.start_year
    """
    reform = Policy.read_json_reform_file(reform_file.name)
    policy = Policy()
    policy.implement_reform(reform)
    syr = policy.start_year
    amt_tthd = policy._AMT_tthd
    assert amt_tthd[2015 - syr] == 200000
    assert amt_tthd[2016 - syr] > 200000
    assert amt_tthd[2017 - syr] == 300000
    assert amt_tthd[2018 - syr] > 300000
    ii_em = policy._II_em
    assert ii_em[2016 - syr] == 6000
    assert ii_em[2017 - syr] == 6000
    assert ii_em[2018 - syr] == 7500
    assert ii_em[2019 - syr] > 7500
    assert ii_em[2020 - syr] == 9000
    assert ii_em[2021 - syr] > 9000
    amt_em = policy._AMT_em
    assert amt_em[2016 - syr, 0] > amt_em[2015 - syr, 0]
    assert amt_em[2017 - syr, 0] > amt_em[2016 - syr, 0]
    assert amt_em[2018 - syr, 0] == amt_em[2017 - syr, 0]
    assert amt_em[2019 - syr, 0] == amt_em[2017 - syr, 0]
    assert amt_em[2020 - syr, 0] == amt_em[2017 - syr, 0]
    assert amt_em[2021 - syr, 0] > amt_em[2020 - syr, 0]
    assert amt_em[2022 - syr, 0] > amt_em[2021 - syr, 0]
开发者ID:chrisrytting,项目名称:Tax-Calculator,代码行数:30,代码来源:test_policy.py


示例20: test_convert

    def test_convert(self):

        values = {"II_brk2_0": [36000., 38000., 40000.],
                    "II_brk2_1": [72250., 74000.],
                    "II_brk2_2": [36500.]
                    }

        ans = package_up_vars(values, first_budget_year=FBY)
        pp = Policy(start_year=2013)
        pp.set_year(FBY)
        # irates are rates for 2015, 2016, and 2017
        irates = pp.indexing_rates_for_update(param_name='II_brk2', calyear=FBY,
                                            num_years_to_expand=3)

        # User choices propagate through to all future years
        # The user has specified part of the parameter up to 2017.
        # So, we choose to fill in the propagated value, which is
        # either inflated or not.

        f2_2016 = int(36500 * (1.0 + irates[0]))
        f3_2016 = int(50200 * (1.0 + irates[0]))
        f4_2016 = int(74900 * (1.0 + irates[0]))
        f5_2016 = int(37450 * (1.0 + irates[0]))

        f1_2017 = int(74000 * (1.0 + irates[1]))
        f2_2017 = int(f2_2016 * (1.0 + irates[1]))
    
        exp =  [[36000, 72250, 36500, 50200, 74900, 37450],
                [38000, 74000, f2_2016, 50400, 75300, 37650],
                [40000, f1_2017, f2_2017, None, None, None]]

        assert ans['_II_brk2'] == exp
        assert len(ans) == 1
开发者ID:Kalaiselvy,项目名称:webapp-public,代码行数:33,代码来源:test_all.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python taxcalc.Records类代码示例发布时间:2022-05-27
下一篇:
Python taxcalc.IncomeTaxIO类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap