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
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
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
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
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_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
def test_rebuild(): from sympy.core.add import Add expr = Basic.__new__(Add, S(1), S(2)) assert rebuild(expr) == 3