Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jan Hönig
pystencils
Commits
b91e6990
Commit
b91e6990
authored
Mar 18, 2019
by
Martin Bauer
Browse files
Correct automatic typing (double/bool) also for staggered kernels
parent
4cdd0ad7
Changes
2
Hide whitespace changes
Inline
Side-by-side
kernelcreation.py
View file @
b91e6990
...
...
@@ -216,8 +216,9 @@ def create_staggered_kernel(staggered_field, expressions, subexpressions=(), tar
for
d
in
dimensions
])
sp_assignments
=
[
SympyAssignment
(
a
.
lhs
,
a
.
rhs
)
for
a
in
a_coll
.
all_assignments
]
if
as_else_block
and
last_conditional
:
last_conditional
.
false_block
=
Conditional
(
condition
,
Block
(
sp_assignments
))
last_conditional
=
last_conditional
.
false_block
new_cond
=
Conditional
(
condition
,
Block
(
sp_assignments
))
last_conditional
.
false_block
=
Block
([
new_cond
])
last_conditional
=
new_cond
else
:
last_conditional
=
Conditional
(
condition
,
Block
(
sp_assignments
))
final_assignments
.
append
(
last_conditional
)
...
...
transformations.py
View file @
b91e6990
...
...
@@ -923,12 +923,17 @@ def typing_from_sympy_inspection(eqs, default_type="double"):
"""
result
=
defaultdict
(
lambda
:
default_type
)
for
eq
in
eqs
:
if
isinstance
(
eq
,
ast
.
Node
):
if
isinstance
(
eq
,
ast
.
Conditional
):
result
.
update
(
typing_from_sympy_inspection
(
eq
.
true_block
.
args
))
if
eq
.
false_block
:
result
.
update
(
typing_from_sympy_inspection
(
eq
.
false_block
.
args
))
elif
isinstance
(
eq
,
ast
.
Node
)
and
not
isinstance
(
eq
,
ast
.
SympyAssignment
):
continue
# problematic case here is when rhs is a symbol: then it is impossible to decide here without
# further information what type the left hand side is - default fallback is the dict value then
if
isinstance
(
eq
.
rhs
,
Boolean
)
and
not
isinstance
(
eq
.
rhs
,
sp
.
Symbol
):
result
[
eq
.
lhs
.
name
]
=
"bool"
else
:
# problematic case here is when rhs is a symbol: then it is impossible to decide here without
# further information what type the left hand side is - default fallback is the dict value then
if
isinstance
(
eq
.
rhs
,
Boolean
)
and
not
isinstance
(
eq
.
rhs
,
sp
.
Symbol
):
result
[
eq
.
lhs
.
name
]
=
"bool"
return
result
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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