def test_expand_xd_errors(): """ One of several _expand_?D tests. """ dct = dict() with pytest.raises(ValueError): Parameters._expand_1d(dct, inflate=False, inflation_rates=[], num_years=10) with pytest.raises(ValueError): Parameters._expand_2d(dct, inflate=False, inflation_rates=[], num_years=10)
def test_expand_1d_scalar(): """ One of several _expand_?D tests. """ yrs = 12 val = 10.0 exp = np.array([val * math.pow(1.02, i) for i in range(0, yrs)]) res = Parameters._expand_1d(np.array([val]), inflate=True, inflation_rates=[0.02] * yrs, num_years=yrs) assert np.allclose(exp, res, atol=0.01, rtol=0.0) res = Parameters._expand_1d(np.array([val]), inflate=True, inflation_rates=[0.02] * yrs, num_years=1) assert np.allclose(np.array([val]), res, atol=0.01, rtol=0.0)