Beispiel #1
0
def test_calc_add_life():
    calc = Calc()
    result = calc.add_life(age=30, qx=get_qx())
    assert result == "x1"
    assert "x1" in calc.columns
    assert "q(x1)" in calc.columns
    assert calc["x1"].iloc[0] == 30
import pytest
from actymath import Calc
from actymath.tables import A1967_70_Exams

# A1967-70 table - Actuarial Green tables for testing
table = A1967_70_Exams()
q0 = table.qx(0, select=True)

# Create calc
calc = Calc()
calc.add_life(0, q0)
calc.add_i(rate=0.04)  # Will use 4% tables

# Set the l(x) with the right base for the tables
calc.populate("l(x1)")


def test_a_due_x1():
    calc.populate("a_due(x1)")
    assert calc["a_due(x1)"].iloc[0] == pytest.approx(24.240, abs=0.001)
    assert calc["a_due(x1)"].iloc[54] == pytest.approx(14.672, abs=0.001)


def test_a_x1():
    calc.populate("a(x1)")
    assert calc["a(x1)"].iloc[53] == pytest.approx(14.672 * 3840.1664 /
                                                   4020.9326,
                                                   abs=0.001)


def test_A_x1():
Beispiel #3
0
import pandas as pd
import pytest
from actymath import Calc
from actymath.tables import A1967_70_Exams

# A1967-70 table - Actuarial Green tables for testing
table = A1967_70_Exams()
q45 = table.qx(45, select=True)

# Create calc
calc = Calc()
calc.add_life(45, q45)
calc.add_i(rate=0.04)  # Will use 4% tables


def test_t():
    calc.populate("t")
    assert calc["t"].iloc[0] == 0
    assert calc["t"].iloc[25] == 25


def test_n():
    calc.add_term(n=10)
    calc.add_term(n=20)
    assert calc["n1"].iloc[0] == 10
    assert calc["n1"].iloc[10] == 0
    assert pd.isnull(calc["n1"].iloc[11])
    assert calc["n2"].iloc[0] == 20
    assert calc["n2"].iloc[10] == 10
Beispiel #4
0
def test_calc_is_dataframe():
    calc = Calc()
    assert isinstance(calc, pd.DataFrame)
import pytest
from actymath import Calc, ActyMathError
from actymath.tables import A1967_70_Exams

# A1967-70 table - Actuarial Green tables for testing
table = A1967_70_Exams()
q0 = table.qx(0, select=True)

# Create calc
calc = Calc()
calc.add_life(0, q0)
calc.add_i(rate=0.04)  # Will use 4% tables


def test_qx1():
    assert calc["q(x1)"].iloc[0] == pytest.approx(0.00058, abs=0.00001)
    assert calc["q(x1)"].iloc[4] == pytest.approx(0.00053, abs=0.00001)


def test_px1():
    calc.populate("p(x1)")
    assert calc["p(x1)"].iloc[0] == pytest.approx(1 - 0.0005800)
    assert calc["p(x1)"].iloc[4] == pytest.approx(1 - 0.00053000)


def test_lx1():
    calc.populate("l(x1)")
    assert calc["l(x1)"].iloc[0] == pytest.approx(34481.408)
    assert calc["l(x1)"].iloc[4] == pytest.approx(34398.727)
    assert calc["l(x1)"].iloc[54] == pytest.approx(31926.430)
Beispiel #6
0
import pandas as pd
import pytest
from actymath import Calc
from actymath.tables import A1967_70_Exams

# A1967-70 table - Actuarial Green tables for testing
table = A1967_70_Exams()
q45 = table.qx(45, select=True)  # Select
q54 = table.qx(54, select=False)  # Ultimate

# Create calc
calc = Calc()
calc.add_life(45, q45)
calc.add_i(rate=0.04)  # Will use 4% tables
calc.add_term(n=10)  # Will use the x+n = 55 tables in Green tables for tests

# Set the l(x) with the right base for the tables
calc.populate("l(x1)")

calc54 = Calc()  # 54 year old
calc54.add_life(54, q54)
calc54.add_i(rate=0.04)  # Will use 4% tables
calc54.add_term(n=10)
calc54.populate("l(x1)")


def test_a_due_x1_n1():
    calc.populate("a_due(x1)[n1]")
    assert calc["a_due(x1)[n1]"].iloc[0] == pytest.approx(8.317,
                                                          abs=0.001)  # Select
    assert calc["a_due(x1)[n1]"].iloc[5] == pytest.approx(