def test_Limit(): e = Limit(sin(x)/x, x, 0) assert mcode(e) == "Hold[Limit[Sin[x]/x, x -> 0, Direction -> -1]]" e = Limit(sin(x)/x, x, 0, "-") assert mcode(e) == "Hold[Limit[Sin[x]/x, x -> 0, Direction -> 1]]" e = Limit(sin(x)/x, x, 0, "real") assert mcode(e) == "Hold[Limit[Sin[x]/x, x -> 0, Direction -> Reals]]"
def test_diofant_parser(): x = Symbol('x') inputs = { '2*x': 2 * x, '3.00': Float(3), '22/7': Rational(22, 7), '2+3j': 2 + 3 * I, 'exp(x)': exp(x), '-(2)': -Integer(2), '[-1, -2, 3]': [Integer(-1), Integer(-2), Integer(3)], 'Symbol("x").free_symbols': x.free_symbols, 'Float(Integer(3).evalf(3))': 3.00, 'factorint(12, visual=True)': Mul(Pow(2, 2, evaluate=False), Pow(3, 1, evaluate=False), evaluate=False), 'Limit(sin(x), x, 0, dir="-")': Limit(sin(x), x, 0, dir='-'), } for text, result in inputs.items(): assert parse_expr(text) == result