本文整理汇总了Python中taxcalc.Policy.expand_2D方法的典型用法代码示例。如果您正苦于以下问题:Python Policy.expand_2D方法的具体用法?Python Policy.expand_2D怎么用?Python Policy.expand_2D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类taxcalc.Policy
的用法示例。
在下文中一共展示了Policy.expand_2D方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_expand_2D_already_filled
# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import expand_2D [as 别名]
def test_expand_2D_already_filled():
_II_brk2 = [[36000, 72250, 36500, 48600, 72500, 36250],
[38000, 74000, 36900, 49400, 73800, 36900],
[40000, 74900, 37450, 50200, 74900, 37450]]
res = Policy.expand_2D(_II_brk2, inflate=True, inflation_rates=[0.02] * 5,
num_years=3)
npt.assert_array_equal(res, np.array(_II_brk2))
示例2: test_expand_2D_short_array
# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import expand_2D [as 别名]
def test_expand_2D_short_array():
x = np.array([[1, 2, 3]], dtype=np.float64)
val = np.array([1, 2, 3], dtype=np.float64)
exp2 = np.array([val * math.pow(1.02, i) for i in range(1, 5)])
exp1 = np.array([1, 2, 3], dtype=np.float64)
exp = np.zeros((5, 3))
exp[:1] = exp1
exp[1:] = exp2
res = Policy.expand_2D(x, inflate=True, inflation_rates=[0.02] * 5, num_years=5)
npt.assert_allclose(exp, res)
示例3: test_expand_2D_variable_rates
# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import expand_2D [as 别名]
def test_expand_2D_variable_rates():
x = np.array([[1, 2, 3]], dtype=np.float64)
cur = np.array([1, 2, 3], dtype=np.float64)
irates = [0.02, 0.02, 0.02, 0.03, 0.035]
exp2 = []
for i in range(0, 4):
idx = i + len(x) - 1
cur = np.array(cur * (1.0 + irates[idx]))
print("cur is ", cur)
exp2.append(cur)
exp1 = np.array([1, 2, 3], dtype=np.float64)
exp = np.zeros((5, 3), dtype=np.float64)
exp[:1] = exp1
exp[1:] = exp2
res = Policy.expand_2D(x, inflate=True, inflation_rates=irates, num_years=5)
npt.assert_allclose(exp, res)
示例4: test_expand_2D_variable_rates
# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import expand_2D [as 别名]
def test_expand_2D_variable_rates():
x = np.array([[1, 2, 3]], dtype='f8')
cur = np.array([1, 2, 3], dtype='f8')
irates = [0.02, 0.02, 0.02, 0.03, 0.035]
exp2 = []
for i in range(0, 4):
idx = i + len(x) - 1
cur = np.array(cur * (1.0 + irates[idx]))
print("cur is ", cur)
exp2.append(cur)
# exp2 = np.array([val * math.pow(1.02, i) for i in range(1, 5)])
exp1 = np.array([1, 2, 3], dtype='f8')
exp = np.zeros((5, 3))
exp[:1] = exp1
exp[1:] = exp2
res = Policy.expand_2D(x, inflate=True, inflation_rates=irates,
num_years=5)
npt.assert_array_equal(res, np.array(exp).astype('f8', casting='unsafe'))
assert np.allclose(exp, res)
示例5: test_expand_2D_partial_expand
# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import expand_2D [as 别名]
def test_expand_2D_partial_expand():
_II_brk2 = [[36000, 72250, 36500, 48600, 72500, 36250],
[38000, 74000, 36900, 49400, 73800, 36900],
[40000, 74900, 37450, 50200, 74900, 37450]]
# We have three years worth of data, need 4 years worth,
# but we only need the inflation rate for year 3 to go
# from year 3 -> year 4
inf_rates = [0.02, 0.02, 0.03]
exp1 = 40000 * 1.03
exp2 = 74900 * 1.03
exp3 = 37450 * 1.03
exp4 = 50200 * 1.03
exp5 = 74900 * 1.03
exp6 = 37450 * 1.03
exp = [[36000, 72250, 36500, 48600, 72500, 36250],
[38000, 74000, 36900, 49400, 73800, 36900],
[40000, 74900, 37450, 50200, 74900, 37450],
[exp1, exp2, exp3, exp4, exp5, exp6]]
res = Policy.expand_2D(_II_brk2, inflate=True, inflation_rates=inf_rates,
num_years=4)
npt.assert_array_equal(res, exp)