Skip to content

Commit

Permalink
Merge pull request #2321 from devitocodes/hotfix-max
Browse files Browse the repository at this point in the history
compiler: Hotfix unevaluation.Pow(1, ...)
  • Loading branch information
FabioLuporini authored Feb 26, 2024
2 parents ccfb823 + 774606b commit edd6a2e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion devito/symbolics/unevaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@ class Mul(sympy.Mul, UnevaluableMixin):


class Pow(sympy.Pow, UnevaluableMixin):
__new__ = UnevaluableMixin.__new__

def __new__(cls, base, exp, evaluate=None, **kwargs):
if base == 1:
# Otherwise we might get trapped within vicious recursion inside
# SymPy each time it tries to perform a simplification via
# `as_numer_denom`, since the `denom` turns into a Pow itself
# such as `1**c`
return sympy.S.One
else:
return cls.__base__.__new__(cls, base, exp, evaluate=False, **kwargs)

0 comments on commit edd6a2e

Please sign in to comment.