-
Notifications
You must be signed in to change notification settings - Fork 517
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
QuadraticRepnVisitor: Improve nonlinear expression expansion #2997
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #2997 +/- ##
==========================================
+ Coverage 87.85% 88.08% +0.22%
==========================================
Files 769 769
Lines 89497 89496 -1
==========================================
+ Hits 78632 78835 +203
+ Misses 10865 10661 -204
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
@@ -294,6 +293,9 @@ def _handle_product_nonlinear(visitor, node, arg1, arg2): | |||
(_QUADRATIC, _GENERAL): _handle_product_nonlinear, | |||
# Replace handler from the linear walker | |||
(_LINEAR, _LINEAR): _handle_product_linear_linear, | |||
(_GENERAL, _GENERAL): _handle_product_nonlinear, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just so I understand - _GENERAL
implies nonlinear
, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...I used "GENERAL" as a shorthand for "General nonlinear", because just using "NONLINEAR" would have been confusing with QUADRATIC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Unrelated - what is the default for expand_nonlinear_products
?
@michaelbynum: The default is currently |
I like that proposal. The expansion is very powerful, and I don't think we should "hide" that functionality (I realize it is not really hidden, but, hopefully, you get my point). |
Fixes #2275 .
Summary/Motivation:
This resolves some issues in the
QuadraticRepnVisitor
nonlinear term expansion logic. In particular, it needed specialized handlers for LINEAR * GENERAL and GENERAL * GENERAL so that nonlinear terms are correctly expanded whenexpand_nonlinear_products
is True.Changes proposed in this PR:
0*
" terms in expanded productsLegal Acknowledgement
By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution: