def test_ax(): i = 2 g = 1 m = 1 method = 'udd' cf_grf95 = commutation_table.CommutationFunctions(i=i, g=g, mt=soa_GRF95.table_qx) cf_tv7377 = commutation_table.CommutationFunctions(i=i, g=g, mt=soa_TV7377.table_qx) ages = range(0, max(mt_TV7377.w, mt_GRF95.w) + 10) a_grf = [ annuities.ax(mt=mt_GRF95, x=x, i=i, g=g, m=m, method=method) for x in ages ] a_tv = [ annuities.ax(mt=mt_TV7377, x=x, i=i, g=g, m=m, method=method) for x in ages ] a_grf_2 = [cf_grf95.ax(x=x, m=m) for x in ages] a_tv_2 = [cf_tv7377.ax(x=x, m=m) for x in ages] assert a_grf == pytest.approx(a_grf_2, rel=1e-16) assert a_tv == pytest.approx(a_tv_2, rel=1e-16)
def test_ax(): i = 2 g = 1 m = 1 x = 45 method = 'udd' cf_grf95 = commutation_table.CommutationFunctions(i=i, g=g, mt=soa_GRF95.table_qx) cf_tv7377 = commutation_table.CommutationFunctions(i=i, g=g, mt=soa_TV7377.table_qx) a_grf = annuities.ax(mt=mt_GRF95, x=x, i=i, g=g, m=m, method=method) a_tv = annuities.ax(mt=mt_TV7377, x=x, i=i, g=g, m=m, method=method) assert a_grf == pytest.approx(cf_grf95.ax(x=x, m=m), rel=1e-16) assert a_tv == pytest.approx(cf_tv7377.ax(x=x, m=m), rel=1e-16)
__author__ = "PedroCR" from essential_life import mortality_table as mt, annuities from soa_tables import read_soa_table_xml as rst soa_TV7377 = rst.SoaTable('../soa_tables/TV7377.xml') soa_GRF95 = rst.SoaTable('../soa_tables/GRF95.xml') mt_GRF95 = mt.MortalityTable(mt=soa_GRF95.table_qx) mt_TV7377 = mt.MortalityTable(mt=soa_TV7377.table_qx) a1 = annuities.ax(mt=mt_GRF95, x=45, i=2, g=0, m=1) a2 = annuities.aax(mt=mt_GRF95, x=45, i=2, g=0, m=1) print(a1) print(a2)