Exemplo n.º 1
0
def test_factors():
    k = EQ() * Linear()
    yield eq, k.num_factors, 2
    yield eq, str(k.factor(0)), 'EQ()'
    yield eq, str(k.factor(1)), 'Linear()'
    yield raises, IndexError, lambda: k.factor(2)

    k = (EQ() + EQ()) * Delta() * (RQ(1) + Linear())
    yield eq, k.num_factors, 4
    yield eq, str(k.factor(0)), '2'
    yield eq, str(k.factor(1)), 'EQ()'
    yield eq, str(k.factor(2)), 'Delta()'
    yield eq, str(k.factor(3)), 'RQ(1) + Linear()'
    yield raises, IndexError, lambda: k.factor(4)
    yield raises, IndexError, lambda: EQ().factor(1)
Exemplo n.º 2
0
def test_factors():
    k = EQ() * Linear()
    assert k.num_factors == 2
    assert str(k.factor(0)) == 'EQ()'
    assert str(k.factor(1)) == 'Linear()'
    with pytest.raises(IndexError):
        k.factor(2)

    k = (EQ() + EQ()) * Delta() * (RQ(1) + Linear())
    assert k.num_factors == 4
    assert str(k.factor(0)) == '2'
    assert str(k.factor(1)) == 'EQ()'
    assert str(k.factor(2)) == 'Delta()'
    assert str(k.factor(3)) == 'RQ(1) + Linear()'
    with pytest.raises(IndexError):
        k.factor(4)
    with pytest.raises(IndexError):
        EQ().factor(1)