Commit a27c182a authored by Markus Holzer's avatar Markus Holzer
Browse files

Small fix

parent 7fcda4a9
Pipeline #36482 passed with stages
in 21 minutes and 34 seconds
......@@ -453,7 +453,11 @@ class CustomSympyPrinter(CCodePrinter):
def _print_Rational(self, expr):
"""Evaluate all rationals i.e. print 0.25 instead of 1.0/4.0"""
res = str(expr.evalf(17))
return res.rstrip('0')
if "." in res:
res = res.rstrip('0')
if res[-1] == ".":
res += '0'
return res
def _print_Equality(self, expr):
"""Equality operator is not printable in default printer"""
......@@ -525,7 +529,10 @@ class CustomSympyPrinter(CCodePrinter):
def _typed_number(self, number, dtype):
res = self._print(number)
res = res.rstrip('0')
if "." in res:
res = res.rstrip('0')
if res[-1] == ".":
res += '0'
if dtype.numpy_dtype == np.float32:
return res + '.0f' if '.' not in res else res + 'f'
elif dtype.numpy_dtype == np.float64:
......
Markdown is supported
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