From a1c374cc00a3b01b017645f2eafdbb690273048c Mon Sep 17 00:00:00 2001
From: Stephan Seitz <stephan.seitz@fau.de>
Date: Thu, 28 Nov 2019 16:46:53 +0100
Subject: [PATCH] Add own implementation for printing an unknown function

Using the SymPy implementation for printing a `sympy.Function` has some issues:

 - you cannot use `cast_func` as an argument -> SymPy prints
 `cast_func(2,float)
 - typed numbers are not typed any more -> e.g. pow(x, 0.25) instead of
 pow(x, 0.25f)
---
 pystencils/backends/cbackend.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pystencils/backends/cbackend.py b/pystencils/backends/cbackend.py
index 5160fafd4..59d9011d4 100644
--- a/pystencils/backends/cbackend.py
+++ b/pystencils/backends/cbackend.py
@@ -385,7 +385,8 @@ class CustomSympyPrinter(CCodePrinter):
         elif expr.func == int_div:
             return "((%s) / (%s))" % (self._print(expr.args[0]), self._print(expr.args[1]))
         else:
-            return super(CustomSympyPrinter, self)._print_Function(expr)
+            arg_str = ', '.join(self._print(a) for a in expr.args)
+            return f'{expr.name}({arg_str})'
 
     def _typed_number(self, number, dtype):
         res = self._print(number)
-- 
GitLab