-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
Allow powers of SignGroup elements to live in other parents #38958
base: develop
Are you sure you want to change the base?
Conversation
…ents_of_generating_function
Documentation preview for this PR (built with commit c431e2c; changes) is ready! 🎉 |
P = self.parent() | ||
return P.element_class(P, self._element_ ** exponent) | ||
try: | ||
result = P.element_class(P, self._element_ ** exponent) |
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.
why recompute the power ? and maybe use "return" in the try ?
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.
You are absolutely right, I changed the code in haste and missed replacing the argument. Fixed via c431e2c.
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.
ok, looks good enough, although maybe not very kosher in term of the coercion model
A
SignGroup
is used as an auxiliary construct in the context of asymptotic expansions to split the growth of terms like(-2)^n * n^42
into, essentially,2^n * n^42 * (-1)^n
that lives in a cartesian productQQ^n * n^QQ * Signs^n
.In the current implementation of
Sign.__pow__
, the power is computed using the raw data (essentially,int ** whatever
) and then an attempt is made to push the result back intoSignGroup
. This changes this behavior to still attempt the conversion -- but if it fails while the raw operation itself was successful, the result living in some other parent not coercing back toSignGroup
is returned.Simple example:
For asymptotic expansions, this fixes an issue preventing substitutions in expansions with terms that involve, e.g.,
(-1)^n
.📝 Checklist