(expression)
| 114 | |
| 115 | |
| 116 | def replace_min_max_functions(expression): |
| 117 | # Parse the expression into an AST |
| 118 | parsed_expression = ast.parse(expression, mode="eval") |
| 119 | |
| 120 | # Transform the AST |
| 121 | transformer = MaxTransformer() |
| 122 | transformed_ast = transformer.visit(parsed_expression) |
| 123 | |
| 124 | # Fix the missing locations in the AST |
| 125 | transformed_ast = ast.fix_missing_locations(transformed_ast) |
| 126 | |
| 127 | # Compile the transformed AST |
| 128 | compiled_code = compile(transformed_ast, "<string>", "eval") |
| 129 | |
| 130 | # Evaluate the compiled code |
| 131 | result = eval(compiled_code) |
| 132 | return str(result) |
| 133 | |
| 134 | |
| 135 | class LLMMathChain(Chain): |
no test coverage detected