Skip to content

Commit af3b475

Browse files
ZoeLeibowitzmloubout
authored andcommitted
compiler: Fix printer for unevaluation Mul for issue 2577
1 parent 77f8725 commit af3b475

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

devito/ir/cgen/printer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def _print_Mod(self, expr):
223223
return '%'.join(args)
224224

225225
def _print_Mul(self, expr):
226-
args = [a for a in expr.args if a != -1]
226+
args = [a for a in expr.args if (a != -1. or a != -1)]
227227
neg = (len(expr.args) - len(args)) % 2
228228

229229
if len(args) > 1:

tests/test_symbolics.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
INT, FieldFromComposite, IntDiv, Namespace, Rvalue,
1616
ReservedWord, ListInitializer, uxreplace, pow_to_mul,
1717
retrieve_derivatives, BaseCast)
18+
from devito.symbolics.unevaluation import Mul
1819
from devito.tools import as_tuple
1920
from devito.types import (Array, Bundle, FIndexed, LocalObject, Object,
2021
ComponentAccess, StencilDimension, Symbol as dSymbol)
@@ -874,3 +875,12 @@ def test_assumptions(self, op, expr, assumptions, expected):
874875
assumptions = eval(assumptions)
875876
expected = eval(expected)
876877
assert evalrel(op, eqn, assumptions) == expected
878+
879+
880+
def test_issue_2577():
881+
882+
u = TimeFunction(name='u', grid=Grid((2,)))
883+
eq = Eq(u.forward, Mul(-1, -1., u))
884+
op = Operator(eq)
885+
886+
assert '--' not in str(op.ccode)

0 commit comments

Comments
 (0)