Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiler: Hotfix unevaluation.Pow(1, ...) #2321

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you not want to pass the kwarg evaluate through here? It's currently not getting used

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we want to force not to evaluate we do it in a bunch of place and it's easier like that to separate it from the kwargs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mathias is correct

Loading