本文整理汇总了Python中taxcalc.Policy.inflation_rates方法的典型用法代码示例。如果您正苦于以下问题:Python Policy.inflation_rates方法的具体用法?Python Policy.inflation_rates怎么用?Python Policy.inflation_rates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类taxcalc.Policy
的用法示例。
在下文中一共展示了Policy.inflation_rates方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_make_calculator_increment_years_first
# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import inflation_rates [as 别名]
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)
示例2: test_variable_inflation_rate_with_reform
# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import inflation_rates [as 别名]
def test_variable_inflation_rate_with_reform():
"""
Test indexing of policy parameters involved in a reform.
"""
pol = Policy()
syr = Policy.JSON_START_YEAR
assert pol._II_em[2013 - syr] == 3900
# implement reform in 2020 which is two years before the last year, 2022
reform = {
'II_em': {2018: 1000, # to avoid divide-by-zero under TCJA
2020: 20000}
}
pol.implement_reform(reform)
pol.set_year(2020)
assert pol.current_year == 2020
# extract price inflation rates
pirates = pol.inflation_rates()
irate2018 = pirates[2018 - syr]
irate2020 = pirates[2020 - syr]
irate2021 = pirates[2021 - syr]
# check implied inflation rate between 2018 and 2019 (before the reform)
grate = float(pol._II_em[2019 - syr]) / float(pol._II_em[2018 - syr])
assert round(grate - 1.0, 5) == round(irate2018, 5)
# check implied inflation rate between 2020 and 2021 (after the reform)
grate = float(pol._II_em[2021 - syr]) / float(pol._II_em[2020 - syr])
assert round(grate - 1.0, 5) == round(irate2020, 5)
# check implied inflation rate between 2021 and 2022 (after the reform)
grate = float(pol._II_em[2022 - syr]) / float(pol._II_em[2021 - syr])
assert round(grate - 1.0, 5) == round(irate2021, 5)
示例3: test_constant_inflation_rate_with_reform
# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import inflation_rates [as 别名]
def test_constant_inflation_rate_with_reform():
"""
Test indexing of policy parameters involved in a reform.
"""
pol = Policy()
# implement reform in year before final year
fyr = Policy.LAST_BUDGET_YEAR
ryr = fyr - 1
reform = {
'II_em': {(ryr - 3): 1000, # to avoid divide-by-zero under TCJA
ryr: 20000}
}
pol.implement_reform(reform)
# extract price inflation rates
pirates = pol.inflation_rates()
syr = Policy.JSON_START_YEAR
irate_b = pirates[ryr - 2 - syr]
irate_a = pirates[ryr - syr]
# check implied inflation rate just before reform
grate = float(pol._II_em[ryr - 1 - syr]) / float(pol._II_em[ryr - 2 - syr])
assert round(grate - 1.0, 4) == round(irate_b, 4)
# check implied inflation rate just after reform
grate = float(pol._II_em[ryr + 1 - syr]) / float(pol._II_em[ryr - syr])
assert round(grate - 1.0, 6) == round(irate_a, 6)
示例4: test_multi_year_reform
# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import inflation_rates [as 别名]
def test_multi_year_reform():
"""
Test multi-year reform involving 1D and 2D parameters.
"""
# specify dimensions of policy Policy object
syr = Policy.JSON_START_YEAR
nyrs = Policy.DEFAULT_NUM_YEARS
pol = Policy()
iratelist = pol.inflation_rates()
ifactor = {}
for i in range(0, nyrs):
ifactor[syr + i] = 1.0 + iratelist[i]
wratelist = pol.wage_growth_rates()
wfactor = {}
for i in range(0, nyrs):
wfactor[syr + i] = 1.0 + wratelist[i]
# confirm that parameters have current-law values
assert np.allclose(getattr(pol, '_EITC_c'),
Policy._expand_array(
np.array([[487, 3250, 5372, 6044],
[496, 3305, 5460, 6143],
[503, 3359, 5548, 6242],
[506, 3373, 5572, 6269],
[510, 3400, 5616, 6318],
[519, 3461, 5716, 6431]],
dtype=np.float64),
'real',
inflate=True,
inflation_rates=iratelist,
num_years=nyrs),
atol=0.01, rtol=0.0)
assert np.allclose(getattr(pol, '_STD_Dep'),
Policy._expand_array(
np.array([1000, 1000, 1050, 1050, 1050, 1050],
dtype=np.float64),
'real',
inflate=True,
inflation_rates=iratelist,
num_years=nyrs),
atol=0.01, rtol=0.0)
assert np.allclose(getattr(pol, '_CTC_c'),
Policy._expand_array(
np.array([1000] * 5 + [2000] * 8 + [1000],
dtype=np.float64),
'real',
inflate=False,
inflation_rates=iratelist,
num_years=nyrs),
atol=0.01, rtol=0.0)
# this parameter uses a different indexing rate
assert np.allclose(getattr(pol, '_SS_Earnings_c'),
Policy._expand_array(
np.array([113700, 117000, 118500, 118500, 127200,
128400],
dtype=np.float64),
'real',
inflate=True,
inflation_rates=wratelist,
num_years=nyrs),
atol=0.01, rtol=0.0)
# specify multi-year reform using a param:year:value-fomatted dictionary
reform = {
'SS_Earnings_c': {2016: 300000,
2017: 500000,
2019: 700000},
'SS_Earnings_c-indexed': {2017: False,
2019: True},
'CTC_c': {2015: 2000},
'EITC_c': {2016: [900, 5000, 8000, 9000],
2019: [1200, 7000, 10000, 12000]},
'II_em': {2016: 7000,
2019: 9000}
}
# implement multi-year reform
pol.implement_reform(reform)
assert pol.current_year == syr
# move policy Policy object forward in time so current_year is syr+2
# Note: this would be typical usage because the first budget year
# is typically greater than Policy start_year.
pol.set_year(pol.start_year + 2)
assert pol.current_year == syr + 2
# confirm that actual parameters have expected post-reform values
check_eitc_c(pol, reform, ifactor)
check_ii_em(pol, reform, ifactor)
check_ss_earnings_c(pol, reform, wfactor)
check_ctc_c(pol, reform)
示例5: print
# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import inflation_rates [as 别名]
if pname not in skip_list:
reverting_params.append(pname)
print('number_of_reverting_parameters= {}'.format(len(reverting_params)))
# write ppp.old containing existing values for reverting policy parameters
old = open('ppp.old', 'w')
for pname in reverting_params:
old.write('*** {} ***\n'.format(pname))
# write parameter values for each year in [pyear,fyear] range
for year in range(pyear, fyear + 1):
value = pdata[pname]['value'][year - syear]
old.write('{}: {}\n'.format(year, value))
old.close()
# get TCJA parameter inflation rates for each year
irate = clp.inflation_rates()
# construct final-year inflation factor from prior year
# < NOTE: pvalue[t+1] = pvalue[t] * ( 1 + irate[t] ) >
final_ifactor = 1.0
for year in range(pyear, fyear):
final_ifactor *= 1 + irate[year - syear]
# construct intermediate-year inflation factors from base year
# < NOTE: pvalue[t+1] = pvalue[t] * ( 1 + irate[t] ) >
ifactor = dict()
factor = 1.0
for year in range(byear, fyear):
ifactor[year] = factor
factor *= 1 + irate[year - syear]