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

Fix GeneratorsError for creating FractionField element with domain of PolynomialRing or FractionField #19713

Merged
merged 3 commits into from
Jul 22, 2020

Conversation

sylee957
Copy link
Member

@sylee957 sylee957 commented Jul 5, 2020

References to other Issues or PRs

Fixes #19581

Brief description of what is fixed or changed

Fraction field can have domain of fraction field or polynomial ring
and sometimes the coefficient itself can be the element from its domain.

This fixes two issues for constructing
ZZ.frac_field(a, b).frac_field(x)(a+b)
ZZ.poly_ring(a, b).frac_field(x)(a+b)

Other comments

Release Notes

  • polys
    • Fixed GeneratorsError for creating some elements of FractionField when its ground domain is FractionField or PolynomialRing.

@sympy-bot
Copy link

sympy-bot commented Jul 5, 2020

Hi, I am the SymPy bot (v160). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

  • polys
    • Fixed GeneratorsError for creating some elements of FractionField when its ground domain is FractionField or PolynomialRing. (#19713 by @sylee957)

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.7.

Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it.

Click here to see the pull request description that was parsed.

<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234" (see
https://tinyurl.com/auto-closing for more information). Also, please
write a comment on that issue linking back to this pull request once it is
open. -->

Fixes #19581

#### Brief description of what is fixed or changed

Fraction field can have domain of fraction field or polynomial ring 
and sometimes the coefficient itself can be the element from its domain.

This fixes two issues for constructing
`ZZ.frac_field(a, b).frac_field(x)(a+b)`
`ZZ.poly_ring(a, b).frac_field(x)(a+b)`

#### Other comments


#### Release Notes

<!-- Write the release notes for this release below. See
https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more information
on how to write release notes. The bot will check your release notes
automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
- polys
  - Fixed `GeneratorsError` for creating some elements of `FractionField` when its ground domain is `FractionField` or `PolynomialRing`.

<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@sylee957 sylee957 changed the title Fix parsing of nested fraction field Fix GeneratorsError for creating FractionField element with domain of PolynomialRing or FractionField Jul 5, 2020
@sylee957 sylee957 added the polys label Jul 5, 2020
@codecov
Copy link

codecov bot commented Jul 5, 2020

Codecov Report

Merging #19713 into master will decrease coverage by 0.001%.
The diff coverage is 92.561%.

@@              Coverage Diff              @@
##            master    #19713       +/-   ##
=============================================
- Coverage   75.693%   75.692%   -0.002%     
=============================================
  Files          658       664        +6     
  Lines       171307    172382     +1075     
  Branches     40441     40657      +216     
=============================================
+ Hits        129669    130480      +811     
- Misses       35973     36191      +218     
- Partials      5665      5711       +46     

@oscarbenjamin
Copy link
Collaborator

Looks good to me

F1 = ZZ.frac_field(a, b)
F2 = F1.frac_field(x)
numer = F2(a + b).numer
numer == F1.poly_ring(x)(a + b)
Copy link
Member

Choose a reason for hiding this comment

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

Should there be asserts?

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, I'll fix them

if isinstance(self.domain, PolynomialRing) and \
numer.ring == self.domain.ring:
numer = self.ring.ground_new(numer)
else:
Copy link
Member

Choose a reason for hiding this comment

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

What could be done if self.domain is a FractionField?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've fixed them

…olyElement or self.domain is PolynomialRing and element is given as FracElement
@jksuom
Copy link
Member

jksuom commented Jul 22, 2020

Thanks, looks good.

@jksuom jksuom merged commit 3d6b5a4 into sympy:master Jul 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GeneratorsError raised when creating element of fraction field of polynomial ring
4 participants