pyccel.ast.sympy_helper module#
Module containing functions which allow us to treat expressions expressed as Pyccel nodes with SymPy, by providing translations between the SymPy representation and the Pyccel nodes
- pyccel.ast.sympy_helper.pyccel_to_sympy(expr, symbol_map, used_names)[source]#
Convert a Pyccel expression to a SymPy expression.
Convert a Pyccel expression to a SymPy expression saving any Pyccel objects converted to SymPy symbols in a dictionary to allow the reverse conversion to be carried out later.
- Parameters:
expr (TypedAstNode) – The Pyccel node to be translated.
symbol_map (dict) – Dictionary containing any Pyccel objects converted to SymPy symbols.
used_names (Set) – A set of all the names which already exist and therefore cannot be used to create new symbols.
- Returns:
The SymPy equivalent of the expr argument.
- Return type:
SymPy Object
- pyccel.ast.sympy_helper.sympy_to_pyccel(expr, symbol_map)[source]#
Convert a SymPy expression to a Pyccel expression.
Convert a SymPy expression to a Pyccel expression replacing SymPy symbols with Pyccel expressions provided in a symbol_map
- Parameters:
expr (SymPy object) – The SymPy expression to be translated.
symbol_map (dict) – Dictionary mapping SymPy symbols to Pyccel objects.
- Returns:
The Pyccel equivalent of the SymPy object expr.
- Return type: