Example #1
0
def test_expr_fns():
    from sympy.strategies.rl import rebuild
    from sympy import Add
    x, y = map(Symbol, 'xy')
    expr = x + y**3
    e = bottom_up(lambda x: x + 1, expr_fns)(expr)
    b = bottom_up(lambda x: Basic.__new__(Add, x, 1), basic_fns)(expr)

    assert rebuild(b) == e
Example #2
0
def test_expr_fns():
    from sympy.strategies.rl import rebuild
    from sympy import Add
    x, y = map(Symbol, 'xy')
    expr = x + y**3
    e = bottom_up(lambda x: x + 1, expr_fns)(expr)
    b = bottom_up(lambda x: Basic.__new__(Add, x, 1), basic_fns)(expr)

    assert rebuild(b) == e
Example #3
0
def test_expr_fns():
    from sympy.strategies.rl import rebuild
    x, y = map(Symbol, 'xy')
    expr = x + y**3
    e = bottom_up(lambda x: x+1, expr_fns)(expr)
    b = bottom_up(lambda x: x+1, basic_fns)(expr)

    assert b!=e
    assert rebuild(b) == e
Example #4
0
def test_expr_fns():
    from sympy.strategies.rl import rebuild
    x, y = map(Symbol, 'xy')
    expr = x + y**3
    e = bottom_up(lambda x: x + 1, expr_fns)(expr)
    b = bottom_up(lambda x: x + 1, basic_fns)(expr)

    assert b != e
    assert rebuild(b) == e
Example #5
0
def test_condition_simple():
    rl = rewriterule(x, x + 1, [x], lambda x: x < 10)
    assert not list(rl(S(15)))
    assert rebuild(next(rl(S(5)))) == 6
def test_rebuild():
    from sympy import Add
    expr = Basic.__new__(Add, 1, 2)
    assert rebuild(expr) == 3
Example #7
0
def test_condition_simple():
    rl = rewriterule(x, x+1, [x], lambda x: x < 10)
    assert not list(rl(S(15)))
    assert rebuild(next(rl(S(5)))) == 6
Example #8
0
def test_rebuild():
    from sympy import Add
    expr = Basic.__new__(Add, 1, 2)
    assert rebuild(expr) == 3
Example #9
0
def test_expr_fns():
    expr = x + y**3
    e = bottom_up(lambda v: v + 1, expr_fns)(expr)
    b = bottom_up(lambda v: Basic.__new__(Add, v, S(1)), basic_fns)(expr)

    assert rebuild(b) == e
Example #10
0
def test_rebuild():
    from sympy.core.add import Add
    expr = Basic.__new__(Add, S(1), S(2))
    assert rebuild(expr) == 3