コード例 #1
0
ファイル: test_rl.py プロジェクト: ananyaha93/sympy
def test_distribute_add_mul():
    from sympy import Add, Mul, symbols
    x, y = symbols('x, y')
    expr = Mul(2, Add(x, y), evaluate=False)
    expected = Add(Mul(2, x), Mul(2, y))
    distribute_mul = distribute(Mul, Add)
    assert distribute_mul(expr) == expected
コード例 #2
0
def test_distribute_add_mul():
    from sympy import Add, Mul, symbols
    x, y = symbols('x, y')
    expr = Mul(2, Add(x, y), evaluate=False)
    expected = Add(Mul(2, x), Mul(2, y))
    distribute_mul = distribute(Mul, Add)
    assert distribute_mul(expr) == expected
コード例 #3
0
ファイル: test_rl.py プロジェクト: ananyaha93/sympy
def test_distribute():
    class T1(Basic):        pass
    class T2(Basic):        pass

    distribute_t12 = distribute(T1, T2)
    assert distribute_t12(T1(1, 2, T2(3, 4), 5)) == \
            T2(T1(1, 2, 3, 5),
               T1(1, 2, 4, 5))
    assert distribute_t12(T1(1, 2, 3)) == T1(1, 2, 3)
コード例 #4
0
def test_distribute():
    class T1(Basic):
        pass

    class T2(Basic):
        pass

    distribute_t12 = distribute(T1, T2)
    assert distribute_t12(T1(1, 2, T2(3, 4), 5)) == \
            T2(T1(1, 2, 3, 5),
               T1(1, 2, 4, 5))
    assert distribute_t12(T1(1, 2, 3)) == T1(1, 2, 3)