Commit 7fcda4a9 authored by Markus Holzer's avatar Markus Holzer
Browse files

Remove too many zeros

parent 19852424
Pipeline #36475 failed with stages
in 5 minutes and 16 seconds
......@@ -453,7 +453,7 @@ 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
return res.rstrip('0')
def _print_Equality(self, expr):
"""Equality operator is not printable in default printer"""
......@@ -525,6 +525,7 @@ class CustomSympyPrinter(CCodePrinter):
def _typed_number(self, number, dtype):
res = self._print(number)
res = res.rstrip('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