Ejemplo n.º 1
0
def test_exppoly_integrate_quadratic_dependency_check(t1, t2):
    with pytest.raises(RuntimeError):
        ExpPoly(t1)._integrate("t1")
    with pytest.raises(RuntimeError):
        ExpPoly(t1**3)._integrate("t1")

    with pytest.raises(RuntimeError):
        ExpPoly(t1)._integrate_half1("t1")
    with pytest.raises(RuntimeError):
        ExpPoly(t1**3)._integrate_half1("t1")

    with pytest.raises(RuntimeError):
        ExpPoly(t1 + t2**2)._integrate_half2("t1", "t2")
    with pytest.raises(RuntimeError):
        ExpPoly(t1**3 + t2**2)._integrate_half2("t1", "t2")
    with pytest.raises(RuntimeError):
        ExpPoly(t1**2 + t2)._integrate_half2("t1", "t2")
    with pytest.raises(RuntimeError):
        ExpPoly(t1**2 + t2**3)._integrate_half2("t1", "t2")
Ejemplo n.º 2
0
def ep2(t1, t2, t3):
    return ExpPoly(4 - t1**2 - 2 * t2**2 - 0.5 * t1 * t2 - 2 * t1 * t3 + 3 * t2)
Ejemplo n.º 3
0
def ep1(t1):
    return ExpPoly(4 - t1**2 - 0.5 * t1)
Ejemplo n.º 4
0
def test_exppoly_multiplication(t1, t2):
    assert ExpPoly(2, t1) * ExpPoly(3, t2) == ExpPoly(6, t1 + t2)
    assert ExpPoly(2, t1) * 2 == ExpPoly(4, t1)
    assert 2 * ExpPoly(2, t1) == ExpPoly(4, t1)
    assert -ExpPoly(2, t1) == ExpPoly(-2, t1)
Ejemplo n.º 5
0
def test_exppoly_integrate_quadratic_coefficient_check(t1, t2):
    with pytest.raises(RuntimeError):
        ExpPoly(t2 * t1**2).integrate("t1")
Ejemplo n.º 6
0
def test_exppoly_equality(t1, t2, t3):
    assert ExpPoly(2, t1) == ExpPoly(2, t1)
    assert ExpPoly(2, t1) != ExpPoly(2, t2)
    assert ExpPoly(1, t1) != ExpPoly(2, t1)
Ejemplo n.º 7
0
def test_exppoly_str(t1, t2):
    ep = ExpPoly(2, t1 + t2)
    assert str(ep) in {"2 * exp(1 * t1^1 + 1 * t2^1)", "2 * exp(1 * t2^1 + 1 * t1^1)"}
    assert str(ep) == repr(ep)
Ejemplo n.º 8
0
def test_exppoly_eval(t1, t2):
    assert ExpPoly(2, -((t1 - t2) ** 3)).eval(t1=2, t2=4) == 2 * np.exp(-((-2) ** 3))
Ejemplo n.º 9
0
def test_exppoly_substitute(t1, t2, t3):
    assert ExpPoly(2, -(t3**2)).substitute("t3", t1 - t2) == ExpPoly(
        2, -(t1**2) + 2 * t1 * t2 - t2**2
    )
Ejemplo n.º 10
0
def test_exppoly_constructor(t1):
    assert ExpPoly(t1) == ExpPoly(1, t1)