<s> from sympy . parsing . maxima import parse_maxima <EOL> from sympy import Rational , Abs , Symbol , sin , cos , E , oo , log , factorial <EOL> from sympy . abc import x <EOL> n = Symbol ( '<STR_LIT:n>' , integer = True ) <EOL> def test_parser ( ) : <EOL> assert Abs ( parse_maxima ( '<STR_LIT>' ) - <NUM_LIT> ) < <NUM_LIT:10> ** ( - <NUM_LIT:5> ) <EOL> assert parse_maxima ( '<STR_LIT>' ) == <NUM_LIT> <EOL> assert parse_maxima ( '<STR_LIT>' ) == Rational ( <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> assert parse_maxima ( '<STR_LIT>' ) == <NUM_LIT:1> <EOL> def test_injection ( ) : <EOL> parse_maxima ( '<STR_LIT>' , globals = globals ( ) ) <EOL> assert c == x + <NUM_LIT:1> <EOL> parse_maxima ( '<STR_LIT>' , globals = globals ( ) ) <EOL> assert g == <NUM_LIT:9> <EOL> def test_maxima_functions ( ) : <EOL> assert parse_maxima ( '<STR_LIT>' ) == x ** <NUM_LIT:2> + <NUM_LIT:2> * x + <NUM_LIT:1> <EOL> assert parse_maxima ( '<STR_LIT>' ) == ( x + <NUM_LIT:1> ) ** <NUM_LIT:2> <EOL> assert parse_maxima ( '<STR_LIT>' ) == <NUM_LIT:2> * cos ( x ) ** <NUM_LIT:2> + sin ( x ) ** <NUM_LIT:2> <EOL> assert parse_maxima ( '<STR_LIT>' ) == - <NUM_LIT:1> + <NUM_LIT:2> * cos ( x ) ** <NUM_LIT:2> + <NUM_LIT:2> * cos ( x ) * sin ( x ) <EOL> assert parse_maxima ( '<STR_LIT>' ) == [ - <NUM_LIT:2> , <NUM_LIT:2> ] <EOL> assert parse_maxima ( '<STR_LIT>' ) == E <EOL> assert parse_maxima ( '<STR_LIT>' ) == - oo <EOL> assert parse_maxima ( '<STR_LIT>' ) == x ** x * ( <NUM_LIT:1> + log ( x ) ) <EOL> assert parse_maxima ( '<STR_LIT>' , name_dict = dict ( <EOL> n = Symbol ( '<STR_LIT:n>' , integer = True ) , <EOL> k = Symbol ( '<STR_LIT:k>' , integer = True ) <EOL> ) ) == ( n ** <NUM_LIT:2> + n ) / <NUM_LIT:2> <EOL> assert parse_maxima ( '<STR_LIT>' , name_dict = dict ( <EOL> n = Symbol ( '<STR_LIT:n>' , integer = True ) , <EOL> k = Symbol ( '<STR_LIT:k>' , integer = True ) <EOL> ) ) == factorial ( n ) <EOL> assert parse_maxima ( '<STR_LIT>' ) == x - <NUM_LIT:1> <EOL> assert Abs ( parse_maxima ( <EOL> '<STR_LIT>' ) - <NUM_LIT> ) < <NUM_LIT:10> ** ( - <NUM_LIT:5> ) </s>
