コード例 #1
0
ファイル: test_utils.py プロジェクト: ahunter1/taxcalc_ghost
def test_expand_1D_scalar():
    x = 10.0
    exp = np.array([10.0 * math.pow(1.02, i) for i in range(0, 10)])
    res = Policy.expand_1D(x,
                           inflate=True,
                           inflation_rates=[0.02] * 10,
                           num_years=10)
    npt.assert_allclose(exp, res)
コード例 #2
0
def test_expand_1D_variable_rates():
    x = np.array([4, 5, 9], dtype="f4")
    irates = [0.02, 0.02, 0.03, 0.035]
    exp2 = []
    cur = 9.0
    exp = np.array([4, 5, 9, 9 * 1.03, 9 * 1.03 * 1.035])
    res = Policy.expand_1D(x, inflate=True, inflation_rates=irates, num_years=5)
    npt.assert_allclose(exp.astype("f4", casting="unsafe"), res)
コード例 #3
0
ファイル: test_utils.py プロジェクト: chun1211/Tax-Calculator
def test_expand_1D_variable_rates():
    x = np.array([4, 5, 9], dtype='f4')
    irates = [0.02, 0.02, 0.03, 0.035]
    exp2 = []
    cur = 9.0
    exp = np.array([4, 5, 9, 9 * 1.03, 9 * 1.03 * 1.035])
    res = Policy.expand_1D(x, inflate=True, inflation_rates=irates,
                           num_years=5)
    assert np.allclose(exp.astype('f4', casting='unsafe'), res)
コード例 #4
0
def test_expand_1D_short_array():
    x = np.array([4, 5, 9], dtype="i4")
    exp2 = np.array([9.0 * math.pow(1.02, i) for i in range(1, 8)])
    exp1 = np.array([4, 5, 9])
    exp = np.zeros(10)
    exp[:3] = exp1
    exp[3:] = exp2
    res = Policy.expand_1D(x, inflate=True, inflation_rates=[0.02] * 10, num_years=10)
    npt.assert_allclose(exp, res, atol=0.0, rtol=1.0e-7)
コード例 #5
0
ファイル: test_utils.py プロジェクト: chun1211/Tax-Calculator
def test_expand_1D_short_array():
    x = np.array([4, 5, 9], dtype='i4')
    exp2 = np.array([9.0 * math.pow(1.02, i) for i in range(1, 8)])
    exp1 = np.array([4, 5, 9])
    exp = np.zeros(10)
    exp[:3] = exp1
    exp[3:] = exp2
    res = Policy.expand_1D(x, inflate=True, inflation_rates=[0.02] * 10,
                           num_years=10)
    assert np.allclose(exp.astype(x.dtype, casting='unsafe'), res)
コード例 #6
0
ファイル: test_utils.py プロジェクト: ahunter1/taxcalc_ghost
def test_expand_1D_short_array():
    x = np.array([4, 5, 9], dtype='i4')
    exp2 = np.array([9.0 * math.pow(1.02, i) for i in range(1, 8)])
    exp1 = np.array([4, 5, 9])
    exp = np.zeros(10)
    exp[:3] = exp1
    exp[3:] = exp2
    res = Policy.expand_1D(x,
                           inflate=True,
                           inflation_rates=[0.02] * 10,
                           num_years=10)
    npt.assert_allclose(exp, res, atol=0.0, rtol=1.0E-7)
コード例 #7
0
ファイル: test_utils.py プロジェクト: chun1211/Tax-Calculator
def test_expand_1D_scalar():
    x = 10.0
    exp = np.array([10.0 * math.pow(1.02, i) for i in range(0, 10)])
    res = Policy.expand_1D(x, inflate=True, inflation_rates=[0.02] * 10,
                           num_years=10)
    assert np.allclose(exp, res)