-
-
Notifications
You must be signed in to change notification settings - Fork 516
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
Refactor subs() of multivariate polynomials for readability and efficiency #35210
Refactor subs() of multivariate polynomials for readability and efficiency #35210
Conversation
66827bf
to
1c436bd
Compare
Codecov ReportBase: 88.57% // Head: 88.59% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## develop #35210 +/- ##
===========================================
+ Coverage 88.57% 88.59% +0.02%
===========================================
Files 2140 2140
Lines 397273 397273
===========================================
+ Hits 351891 351971 +80
+ Misses 45382 45302 -80
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
|
||
g[mi-1] = v | ||
res_parent = coercion_model.common_parent(parent._base, *[v for _, v in items]) | ||
|
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.
This appears to be more general than the old code that tries to coerce every v
into parent._base
.
Is this just incidental, or is there a use case for this greater generality?
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.
Perhaps there is no difference in this respect. Both first try to coerce every v
into parent._base
. If fails, the old code finds the common parent in return self(*g)
(the last line) via the constructor __init__
while the new code does the same in the place. However, for some paths (substitutions with constant values), the new code does not make a duplicate call to singular_polynomial_call
by avoiding going through the constructor. (if I remember correctly...)
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.
Perhaps it is the substitution with constant values that results in zero that makes the duplicate call.
Documentation preview for this PR is ready! 🎉 |
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.
LGTM
Merge conflict |
Fixed merge conflict with #33373 |
@kwankyu, sorry to dig up this old PR. I want to fix #19130, that is, make parents properly depend on the arguments. Trying to figure out how things work I noticed something I do not understand: In the first line of the snippet, Do you remember the intention? |
No. So I read the lines again. Line 3536 ( The main intention of introducing
|
Well, there must have been some intention, because all of this code is new, and was done in an attempt to simplify the code. Could it be that (I am trying to figure out what the parent of the result of |
The value of
Yes. This is tricky. In most of the cases, the parent should not change. But there are exceptional cases where the parent should change. Like the zero polynomial above. Perhaps you should generalize this obvious case. |
📚 Description
Fixes #34591
📝 Checklist
⌛ Dependencies