Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Markus Holzer
pystencils
Commits
7fcda4a9
Commit
7fcda4a9
authored
Dec 21, 2021
by
Markus Holzer
Browse files
Remove too many zeros
parent
19852424
Pipeline
#36475
failed with stages
in 5 minutes and 16 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
pystencils/backends/cbackend.py
View file @
7fcda4a9
...
...
@@ -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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment