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 some issues of initializing Poly from domain element #19659

Merged
merged 3 commits into from Jun 29, 2020

Conversation

sylee957
Copy link
Member

References to other Issues or PRs

Brief description of what is fixed or changed

This resolves two issues with Poly initialized with arguments of DomainElement.

One problem is that the constructor assumes PolyElement as an iterable and initializes with unpacked form even if the PolyElement has different generators.

>>> from sympy import *
>>> x, y = symbols('x y')
>>> dom = ZZ.poly_ring(x)
>>> Poly(dom(x+2), y, domain=dom)
# Should be Poly(x + 2, y, domain='ZZ[x]') 
# but it gives Poly(y + 2, y, domain='ZZ[x]')

The other problem is that FracFieldElement is not working because of sympify error.

>>> from sympy import *
>>> x, y = symbols('x y')
>>> dom = ZZ.frac_field(x)
>>> Poly(dom(x+2), y, domain=dom)
# Should be Poly(x + 2, y, domain='ZZ(x)')

Other comments

Release Notes

  • polys
    • Fixed Poly initialized with PolyElement mutating the generator of the coefficient in the form of polynomial.
      (e.g. Poly(ZZ[x](x+1), y, domain=ZZ[x]) becomes Poly(y+1, y, domain=ZZ[x]))
    • Fixed Poly initialized with FracElement raising SympifyError.
      (e.g. dom = ZZ.frac_field(x); Poly(dom(x+2), y, domain=dom))

@sylee957 sylee957 added the polys label Jun 28, 2020
@sympy-bot
Copy link

sympy-bot commented Jun 28, 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 Poly initialized with PolyElement mutating the generator of the coefficient in the form of polynomial.
      (e.g. Poly(ZZ[x](x+1), y, domain=ZZ[x]) becomes Poly(y+1, y, domain=ZZ[x])) (#19659 by @sylee957)

    • Fixed Poly initialized with FracElement raising SympifyError.
      (e.g. dom = ZZ.frac_field(x); Poly(dom(x+2), y, domain=dom)) (#19659 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. -->


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

This resolves two issues with Poly initialized with arguments of DomainElement.

One problem is that the constructor assumes `PolyElement` as an iterable and initializes with unpacked form even if the `PolyElement` has different generators.
```
>>> from sympy import *
>>> x, y = symbols('x y')
>>> dom = ZZ.poly_ring(x)
>>> Poly(dom(x+2), y, domain=dom)
# Should be Poly(x + 2, y, domain='ZZ[x]') 
# but it gives Poly(y + 2, y, domain='ZZ[x]')
```

The other problem is that FracFieldElement is not working because of sympify error.
```
>>> from sympy import *
>>> x, y = symbols('x y')
>>> dom = ZZ.frac_field(x)
>>> Poly(dom(x+2), y, domain=dom)
# Should be Poly(x + 2, y, domain='ZZ(x)')
```

#### 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 `Poly` initialized with `PolyElement` mutating the generator of the coefficient in the form of polynomial. 
  (e.g. `Poly(ZZ[x](x+1), y, domain=ZZ[x])` becomes `Poly(y+1, y, domain=ZZ[x])`)
  - Fixed `Poly` initialized with `FracElement` raising `SympifyError`.
  (e.g. `dom = ZZ.frac_field(x); Poly(dom(x+2), y, domain=dom)`)
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@codecov
Copy link

codecov bot commented Jun 28, 2020

Codecov Report

Merging #19659 into master will increase coverage by 0.007%.
The diff coverage is 100.000%.

@@              Coverage Diff              @@
##            master    #19659       +/-   ##
=============================================
+ Coverage   75.660%   75.667%   +0.007%     
=============================================
  Files          658       658               
  Lines       171211    171259       +48     
  Branches     40412     40423       +11     
=============================================
+ Hits        129539    129588       +49     
+ Misses       35999     35997        -2     
- Partials      5673      5674        +1     

@smichr
Copy link
Member

smichr commented Jun 29, 2020

OK, this appears to be a step in the right direction.

@smichr smichr merged commit 961d340 into sympy:master Jun 29, 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.

None yet

3 participants