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


Python Policy.default_inflation_rates方法代码示例

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


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

示例1: test_parameters_get_default_start_year

# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import default_inflation_rates [as 别名]
def test_parameters_get_default_start_year():
    paramdata = Policy.default_data(metadata=True, start_year=2015)
    # 1D data, has 2015 values
    meta_II_em = paramdata['_II_em']
    assert meta_II_em['start_year'] == 2015
    assert meta_II_em['row_label'] == ['2015', '2016']
    assert meta_II_em['value'] == [4000, 4050]
    # 2D data, has 2015 values
    meta_std_aged = paramdata['_STD_Aged']
    assert meta_std_aged['start_year'] == 2015
    assert meta_std_aged['row_label'] == ['2015', '2016']
    assert meta_std_aged['value'] == [[1550, 1250, 1250, 1550, 1550, 1250],
                                      [1550, 1250, 1250, 1550, 1550, 1250]]
    # 1D data, doesn't have 2015 values, is CPI inflated
    meta_amt_thd_marrieds = paramdata['_AMT_thd_MarriedS']
    assert meta_amt_thd_marrieds['start_year'] == 2015
    assert meta_amt_thd_marrieds['row_label'] == ['2015']
    # Take the 2014 parameter value and multiply by inflation for that year
    should_be = 41050 * (1.0 + Policy.default_inflation_rates()[2014])
    meta_amt_thd_marrieds['value'] == should_be
    # 1D data, doesn't have 2015 values, is not CPI inflated
    meta_kt_c_age = paramdata['_KT_c_Age']
    assert meta_kt_c_age['start_year'] == 2015
    assert meta_kt_c_age['row_label'] == ['2015']
    assert meta_kt_c_age['value'] == [24]
开发者ID:chrisrytting,项目名称:Tax-Calculator,代码行数:27,代码来源:test_policy.py

示例2: test_expand_2D_accept_None

# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import default_inflation_rates [as 别名]
def test_expand_2D_accept_None():
    _II_brk2 = [[36000, 72250, 36500, 48600, 72500, 36250],
                [38000, 74000, 36900, 49400, 73800, 36900],
                [40000, 74900, 37450, 50200, 74900, 37450],
                [41000, None, None, None, None, None]]
    exp1 = 74900 * 1.02
    exp2 = 37450 * 1.02
    exp3 = 50200 * 1.02
    exp4 = 74900 * 1.02
    exp5 = 37450 * 1.02
    exp = [[36000, 72250, 36500, 48600, 72500, 36250],
           [38000, 74000, 36900, 49400, 73800, 36900],
           [40000, 74900, 37450, 50200, 74900, 37450],
           [41000, exp1, exp2, exp3, exp4, exp5]]
    exp = np.array(exp).astype('i4', casting='unsafe')
    res = Policy.expand_array(_II_brk2, inflate=True,
                              inflation_rates=[0.02] * 5,
                              num_years=4)
    npt.assert_array_equal(res, exp)

    user_mods = {2016: {u'_II_brk2': _II_brk2}}
    pol = Policy(start_year=2013)
    pol.implement_reform(user_mods)
    pol.set_year(2019)
    irates = Policy.default_inflation_rates()
    # The 2019 policy should be the combination of the user-defined
    # value and CPI-inflated values from 2018
    exp_2019 = [41000.] + [(1 + irates[2018]) * i for i in _II_brk2[2][1:]]
    exp_2019 = np.array(exp_2019)
    npt.assert_array_equal(pol.II_brk2, exp_2019)
开发者ID:GoFroggyRun,项目名称:Tax-Calculator,代码行数:32,代码来源:test_utils.py

示例3: test_create_parameters_from_file

# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import default_inflation_rates [as 别名]
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,代码行数:32,代码来源:test_policy.py

示例4: test_expand_2D_accept_None_additional_row

# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import default_inflation_rates [as 别名]
def test_expand_2D_accept_None_additional_row():
    _II_brk2 = [
        [36000, 72250, 36500, 48600, 72500, 36250],
        [38000, 74000, 36900, 49400, 73800, 36900],
        [40000, 74900, 37450, 50200, 74900, 37450],
        [41000, None, None, None, None, None],
        [43000, None, None, None, None, None],
    ]
    exp1 = 74900 * 1.02
    exp2 = 37450 * 1.02
    exp3 = 50200 * 1.02
    exp4 = 74900 * 1.02
    exp5 = 37450 * 1.02
    exp6 = exp1 * 1.03
    exp7 = exp2 * 1.03
    exp8 = exp3 * 1.03
    exp9 = exp4 * 1.03
    exp10 = exp5 * 1.03
    exp = [
        [36000, 72250, 36500, 48600, 72500, 36250],
        [38000, 74000, 36900, 49400, 73800, 36900],
        [40000, 74900, 37450, 50200, 74900, 37450],
        [41000, exp1, exp2, exp3, exp4, exp5],
        [43000, exp6, exp7, exp8, exp9, exp10],
    ]
    inflation_rates = [0.015, 0.02, 0.02, 0.03]
    res = Policy.expand_array(_II_brk2, inflate=True, inflation_rates=inflation_rates, num_years=5)
    npt.assert_array_equal(res, exp)

    user_mods = {2016: {u"_II_brk2": _II_brk2}}
    pol = Policy(start_year=2013)
    pol.implement_reform(user_mods)
    pol.set_year(2020)
    irates = Policy.default_inflation_rates()
    # The 2020 policy should be the combination of the user-defined
    # value and CPI-inflated values from 2018
    exp_2020 = [43000.0] + [(1 + irates[2019]) * (1 + irates[2018]) * i for i in _II_brk2[2][1:]]
    exp_2020 = np.array(exp_2020)
    npt.assert_allclose(pol.II_brk2, exp_2020)
开发者ID:codykallen,项目名称:Tax-Calculator,代码行数:41,代码来源:test_utils.py


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