本文整理汇总了Python中taxcalc.Policy._expand_array方法的典型用法代码示例。如果您正苦于以下问题:Python Policy._expand_array方法的具体用法?Python Policy._expand_array怎么用?Python Policy._expand_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类taxcalc.Policy
的用法示例。
在下文中一共展示了Policy._expand_array方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_multi_year_reform
# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import _expand_array [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)