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

Added enhancement for power series that allows access to the coefficients of specific terms #39480

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

Noel-Roemmele
Copy link
Contributor

Fixes #39314. Adds an enhancement to power series that when given a tuple of values corresponding to the powers of the term gives you the coefficient for said term. Functionality is similar to how coefficients are retrieved for multivariable polynomials. Also added a test for the enhancement.

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

@DaveWitteMorris
Copy link
Member

Thanks for the enhancement. I will set to positive review on Wednesday if there are no other comments and make ptestlong (or CI testing) does not uncover any problems.

However, I think the initial docstring can be clarified. Perhaps something like:

Return the coefficient of the monomial ``x1^e1 * x2^e2 * ... * xk^ek`` 
if ``n = (e_1, e2, ..., ek)`` is a tuple whose length is the number of variables 
``x1,x2,...,xk`` in the power series ring. 

Return the sum of the monomials of degree ``n`` if ``n`` is an integer.

Copy link

Documentation preview for this PR (built with commit 97cb9fb; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@DaveWitteMorris
Copy link
Member

Sorry, I thought I already told you this, but it's not in my comment above, so apparently not: you need to change :trac" to :issue: in line 698.

@@ -690,9 +694,29 @@ def __getitem__(self, n):
...
IndexError: Cannot return terms of total degree greater than or
equal to precision of self.
"""

Ensure that the enhancment detailed in :issue:`39314` works as intended::
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Ensure that the enhancment detailed in :issue:`39314` works as intended::
Ensure that the enhancement detailed in :issue:`39314` works as intended::

if type(n) is tuple:
if sum(n) >= self.prec():
raise IndexError("Cannot return the coefficients of terms of " +
"total degree greater than or equal to precision of self.")
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't that be indented further? please check!

@mantepse
Copy link
Contributor

I'm a bit split on this solution, because it makes power series behave differently from everything else. Did you think about the possibility of a more generic solution?

It would be good to at least try to unify the interface for polynomials, power series and lazy power series.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to extract a particular coefficient of a multivariate power series
3 participants