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