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

api: Fix custom coefficients inlining #2524

Merged
merged 3 commits into from
Jan 23, 2025
Merged

api: Fix custom coefficients inlining #2524

merged 3 commits into from
Jan 23, 2025

Conversation

FabioLuporini
Copy link
Contributor

@FabioLuporini FabioLuporini commented Jan 23, 2025

this is only an issue for the legacy custom coefficients API

@FabioLuporini FabioLuporini added the bug-C bug in the generated code label Jan 23, 2025
Copy link

codecov bot commented Jan 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.31%. Comparing base (8cec681) to head (0698917).
Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2524      +/-   ##
==========================================
- Coverage   87.32%   87.31%   -0.01%     
==========================================
  Files         238      238              
  Lines       45829    45847      +18     
  Branches     4060     4060              
==========================================
+ Hits        40020    40033      +13     
- Misses       5125     5129       +4     
- Partials      684      685       +1     

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

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@@ -98,7 +98,7 @@ def _apply_coeffs(cls, expr, coefficients):
if not mapper:
return expr

return expr.xreplace(mapper)
return expr.subs(mapper)
Copy link
Contributor

Choose a reason for hiding this comment

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

@FabioLuporini this was the issue. If you had something like Eq(u, u.dx2 + 2 * u.laplace, substitutions=...) then xreplace only replaces the firs appearance so it was using custom coeffs for some and standard coeffs for other. Code looks much better (less. weights and derivatives) with the fix.

@@ -83,7 +83,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Eq(-u(t, x, y)/dt + u(t + dt, x, y)/dt + (0.1*u(t, x, y) - 0.6*u(t, x - h_x, y) + 0.6*u(t, x + h_x, y))/h_x, 0)\n"
"Eq(-u(t, x, y)/dt + u(t + dt, x, y)/dt + 0.1*u(t, x, y)/h_x - 0.6*u(t, x - h_x, y)/h_x + 0.6*u(t, x + h_x, y)/h_x, 0)\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

so we lose the flop reduction here?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is only the symbolic equation, not the operator.

@mloubout mloubout merged commit f71764a into master Jan 23, 2025
31 checks passed
@mloubout mloubout deleted the fix-derivs-7865 branch January 23, 2025 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-C bug in the generated code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants