本文整理汇总了Python中taxcalc.Policy.indexing_rates_for_update方法的典型用法代码示例。如果您正苦于以下问题:Python Policy.indexing_rates_for_update方法的具体用法?Python Policy.indexing_rates_for_update怎么用?Python Policy.indexing_rates_for_update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类taxcalc.Policy
的用法示例。
在下文中一共展示了Policy.indexing_rates_for_update方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_convert
# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import indexing_rates_for_update [as 别名]
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
示例2: propagate_user_list
# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import indexing_rates_for_update [as 别名]
def propagate_user_list(x, defaults, cpi, first_budget_year):
"""
Dispatch to either expand_1D or expand2D depending on the dimension of x
Parameters:
-----------
x : list from user to propagate forward in time. The first value is for
year 'first_budget_year'. The value at index i is the value for
budget year first_budget_year + i.
defaults: list of default values; our result must be at least this long
cpi: Bool
first_budget_year: int
Returns:
--------
list of length 'num_years'. if 'cpi'==True, the values will be inflated
based on the last value the user specified
"""
# x can't be empty
assert x
num_years = max(len(defaults), len(x))
is_rate = any([ i < 1.0 for i in x])
pp = Policy(start_year=2013)
pp.set_year(first_budget_year)
# irates are rates for 2015, 2016, and 2017
if cpi:
irates = pp.indexing_rates_for_update(param_name='II_brk2',
calyear=first_budget_year,
num_years_to_expand=num_years)
else:
irates = [0.0] * num_years
last_val = x[-1]
ans = [None] * num_years
for i in range(num_years):
if i < len(x):
if x[i] == '*':
ans[i] = defaults[i]
else:
ans[i] = x[i]
else:
newval = ans[i-1] * (1.0 + irates[i-1])
ans[i] = newval if is_rate else int(newval)
return ans
示例3: test_convert_multiple_items
# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import indexing_rates_for_update [as 别名]
def test_convert_multiple_items(self):
values = {"II_brk2_0": [36000., 38000., 40000., 41000],
"II_brk2_1": [72250., 74000.],
"II_brk2_2": [36500.]
}
values['II_em'] = [4000]
ans = package_up_vars(values, first_budget_year=FBY)
defaults = taxcalc.policy.Policy.default_data(start_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=4)
# 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]))
f1_2018 = int(f1_2017 * (1.0 + irates[2]))
f2_2018 = int(f2_2017 * (1.0 + irates[2]))
exp = [[36000, 72250, 36500, 50200, 74900, 37450],
[38000, 74000, f2_2016, 50400, 75300, 37650],
[40000, f1_2017, f2_2017, None, None, None],
[41000, f1_2018, f2_2018, None, None, None]]
assert ans['_II_brk2'] == exp
# For scalar parameter values, we still have that all user
# choices propagate up through whatever is specified as
# a default. We know that _II_em is specified up to 2016, so
# package up vars needs to overwrite those default and return
# 2015 and 2016 values
exp_em = [4000, int(4000 *(1 + irates[0]))]
assert ans['_II_em'] == exp_em
assert len(ans) == 2
示例4: propagate_user_list
# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import indexing_rates_for_update [as 别名]
def propagate_user_list(x, num_years, cpi, first_budget_year):
"""
Dispatch to either expand_1D or expand2D depending on the dimension of x
Parameters:
-----------
x : list from user to progagate forward in time. The first value is for
year 'first_budget_year'. The value at index i is the value for
budget year first_budget_year + i.
num_years: int
Number of budget years to expand
cpi: Bool
first_budget_year: int
Returns:
--------
list of length 'num_years'. if 'cpi'==True, the values will be inflated
based on the last value the user specified
"""
# x can't be empty
assert x
pp = Policy(start_year=2013)
pp.set_year(first_budget_year)
# irates are rates for 2015, 2016, and 2017
if cpi:
irates = pp.indexing_rates_for_update(param_name='II_brk2',
calyear=first_budget_year,
num_years_to_expand=num_years)
else:
irates = [0.0] * num_years
last_val = x[-1]
ans = [None] * num_years
for i in range(num_years):
if i < len(x):
ans[i] = x[i]
else:
ans[i] = int(ans[i-1] * (1.0 + irates[i-1]))
return ans
示例5: test_convert_non_cpi_inflated
# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import indexing_rates_for_update [as 别名]
def test_convert_non_cpi_inflated(self):
values = {"FEI_ec_c": [100000.]}
ans = package_up_vars(values, first_budget_year=FBY)
defaults = taxcalc.policy.Policy.default_data(start_year=2015)
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='FEI_ec_c', calyear=FBY,
num_years_to_expand=2)
# User choices propagate through to all future years
# The user has specified the parameter just for 2015, but
# the defaults JSON file has values up to 2016. We should
# give back values up to 2016, with user choice propagating
f2_2016 = 100000
exp = [100000, f2_2016]
assert ans['_FEI_ec_c'] == exp
示例6: propagate_user_list
# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import indexing_rates_for_update [as 别名]
def propagate_user_list(x, name, defaults, cpi, first_budget_year,
multi_param_idx=-1):
"""
Dispatch to either expand_1D or expand2D depending on the dimension of x
Parameters:
-----------
x : list from user to propagate forward in time. The first value is for
year 'first_budget_year'. The value at index i is the value for
budget year first_budget_year + i.
defaults: list of default values; our result must be at least this long
name: the parameter name for looking up the indexing rate
cpi: Bool
first_budget_year: int
multi_param_idx: int, optional. If this parameter is multi-valued, this
is the index for which the values for 'x' apply. So, for exampe, if
multi_param_idx=0, the values for x are typically for the 'single'
filer status. -1 indidcates that this is not a multi-valued
parameter
Returns:
--------
list of length 'num_years'. if 'cpi'==True, the values will be inflated
based on the last value the user specified
"""
# x must have a real first value
assert len(x) > 0
assert x[0] not in ("", None)
num_years = max(len(defaults), len(x))
is_rate = any([ i < 1.0 for i in x])
pp = Policy(start_year=2013)
pp.set_year(first_budget_year)
# irates are rates for 2015, 2016, and 2017
if cpi:
irates = pp.indexing_rates_for_update(param_name=name,
calyear=first_budget_year,
num_years_to_expand=num_years)
else:
irates = [0.0] * num_years
last_val = x[-1]
ans = [None] * num_years
for i in range(num_years):
if i < len(x):
if is_wildcard(x[i]):
if multi_param_idx > -1:
ans[i] = defaults[i][multi_param_idx]
else:
ans[i] = defaults[i]
else:
ans[i] = x[i]
if ans[i] is not None:
continue
else:
newval = ans[i-1] * (1.0 + irates[i-1])
ans[i] = newval if is_rate else int(newval)
return ans