Skip to content
Snippets Groups Projects
Commit 102f07f8 authored by Nils Kohl's avatar Nils Kohl :full_moon_with_face:
Browse files

Added NoEvaluationPiecewise.

This is a sympy.Piecewise wrapper that sets evaluate=False to avoid
expensive simplifications during the kernel generation.
parent f3432684
No related merge requests found
......@@ -263,6 +263,9 @@ class CustomSympyPrinter(CCodePrinter):
result = super(CustomSympyPrinter, self)._print_Piecewise(expr)
return result.replace("\n", "")
def _print_NoEvaluationPiecewise(self, expr):
return self._print_Piecewise(expr)
def _print_Function(self, expr):
infix_functions = {
bitwise_xor: '^',
......
......@@ -580,3 +580,10 @@ def sort_assignments_topologically(assignments: Sequence[Assignment]) -> List[As
class SymbolCreator:
def __getattribute__(self, name):
return sp.Symbol(name)
class NoEvaluationPiecewise(sp.Piecewise):
def __new__(cls, *args, **kwargs):
kwargs['evaluate'] = False
obj = super(NoEvaluationPiecewise, cls).__new__(cls, *args, **kwargs)
return obj
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment