Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Stephan Seitz
pystencils
Commits
7b060744
Commit
7b060744
authored
Jun 17, 2020
by
Markus Holzer
Browse files
Fix identification of interger type in abs functions
parent
09de00cf
Changes
2
Show whitespace changes
Inline
Side-by-side
pystencils/backends/cbackend.py
View file @
7b060744
...
...
@@ -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
]))
...
...
pystencils_tests/test_abs.py
0 → 100644
View file @
7b060744
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
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