Skip to content

dsl: Make unevaluated.Mul return Zero if any args are zero - #3060

Open
EdCaunt wants to merge 1 commit into
mainfrom
unevalmul
Open

EdCaunt wants to merge 1 commit into
mainfrom
unevalmul

Conversation

@EdCaunt

@EdCaunt EdCaunt commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread devito/symbolics/unevaluation.py Outdated
__new__ = UnevaluableMixin.__new__
def __new__(cls, *args, evaluate=None, **kwargs):
# A Mul will always be zero if any of its arguments are zero
if any(arg == 0 for arg in args):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sympify(arg).is_zero is likely safer ==0 sometimes doesn't work

Comment thread devito/symbolics/unevaluation.py Outdated
if any(arg == 0 for arg in args):
return sympy.S.Zero

return cls.__base__.__new__(cls, *args, evaluate=False, **kwargs)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not just super?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Quick copy-paste job and didn't spot it...

@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.22%. Comparing base (2707ac9) to head (4eeb9ed).

Files with missing lines Patch % Lines
devito/symbolics/unevaluation.py 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3060      +/-   ##
==========================================
- Coverage   84.23%   84.22%   -0.01%     
==========================================
  Files         258      258              
  Lines       57070    57074       +4     
  Branches     4874     4875       +1     
==========================================
  Hits        48072    48072              
- Misses       8170     8173       +3     
- Partials      828      829       +1     
Flag Coverage Δ
pytest-gpu-aomp-amdgpuX 68.51% <60.00%> (-0.01%) ⬇️
pytest-gpu-gcc- 79.01% <60.00%> (+<0.01%) ⬆️
pytest-gpu-icx- 78.92% <60.00%> (-0.01%) ⬇️
pytest-gpu-nvc-nvidiaX 69.07% <60.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants