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

Fix identification of interger type in abs functions

parent 09de00cf
......@@ -362,7 +362,7 @@ class CustomSympyPrinter(CCodePrinter):
return result.replace("\n", "")
def _print_Abs(self, expr):
if expr.is_integer:
if expr.args[0].is_integer:
return 'abs({0})'.format(self._print(expr.args[0]))
else:
return 'fabs({0})'.format(self._print(expr.args[0]))
......
import sympy
import pystencils
from pystencils.data_types import cast_func, create_type
def test_abs():
x, y, z = pystencils.fields('x, y, z: float64[2d]')
default_int_type = create_type('int64')
assignments = pystencils.AssignmentCollection({
x[0, 0]: sympy.Abs(cast_func(y[0, 0], default_int_type))
})
ast = pystencils.create_kernel(assignments, target="gpu")
code = pystencils.get_code_str(ast)
print(code)
assert 'fabs(' not in code
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