-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
solving type error and Coercion error in algebraicfield.py #18669
Conversation
✅ Hi, I am the SymPy bot (v151). 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:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.6. 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.
Update The release notes on the wiki have been updated. |
@@ -26,8 +26,10 @@ def __init__(self, dom, *ext): | |||
raise DomainError("ground domain must be a rational field") | |||
|
|||
from sympy.polys.numberfields import to_number_field | |||
|
|||
self.orig_ext = ext | |||
if len(ext) == 1 and type(ext[0]) is tuple: |
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.
if len(ext) == 1 and isinstance(ext[0], tuple)
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.
Sure updating it now.
thanks for pointing it out.
Codecov Report
@@ Coverage Diff @@
## master #18669 +/- ##
============================================
- Coverage 75.572% 71.3% -4.272%
============================================
Files 644 644
Lines 167515 167831 +316
Branches 39485 39566 +81
============================================
- Hits 126595 119665 -6930
- Misses 35395 42519 +7124
- Partials 5525 5647 +122 |
I think it is ready @jksuom |
@@ -124,3 +126,8 @@ def numer(self, a): | |||
def denom(self, a): | |||
"""Returns denominator of ``a``. """ | |||
return self.one | |||
|
|||
def from_AlgebraicField(K1, a, K0): | |||
"""Convert a polynomial to ``dtype``. """ |
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.
Technically, a
is represented by a polynomial but it is less confusing to say that it is an algebraic field element. So this should say something about converting an element a
from one algebraic field to another.
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.
Convert AlgebraicField element 'a' to another AlgebraicField element
Does it seems ok?
def from_AlgebraicField(K1, a, K0): | ||
"""Convert a polynomial to ``dtype``. """ | ||
a = K0.to_sympy(a) | ||
return K1.from_sympy(a) |
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.
It is not necessary to save K0.to_sympy(a)
temporarily to a local variable, K1.from_sympy(K0.to_sympy(a))
should suffice.
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.
Yes I agree I will update it.
There are a couple of comments, otherwise this looks good. |
What about the intersection of two circles in #13230? It would be good to have a test. |
Sure that should be checked too I will add it now. |
The test for this should be added in |
Both of these issues run solvers but, actually, they are related to algebraic fields. Perhaps they should be added to test_numberfields.py. |
I just noticed this:
|
There seems to be only one (real) point in the intersection. Can you check that by computing the distance between the center points? (That should be the sum or difference of the radii.) |
the distance between their center is around ~458. |
The answer (o/p in current branch) is giving two points so I think that The reason I find it absurd because the answer seems too unsimplified and long to mee but now I think that answer can be unsimplified and long because of the ugly circles equation we have used here. |
The distance I get is 380.55 which is less than 231 + 174 = 405. So there should be two points. |
Yes distance between centre is 380.55 I had just by mistake took the points |
So the answer seems right I will add the test. |
def test_issue_13230(): | ||
c1 = Circle(Point2D(3, sqrt(5)), 5) | ||
c2 = Circle(Point2D(4, sqrt(7)), 6) | ||
assert intersection(c1, c2) == [Point2D(-1 + (-sqrt(7) + sqrt(5))*(-2*sqrt(7)/29 + 9*sqrt(5)/29 + sqrt(196*sqrt(35) + 1941)/29), -2*sqrt(7)/29 + 9*sqrt(5)/29 + sqrt(196*sqrt(35) + 1941)/29), Point2D(-1 + (-sqrt(7) + sqrt(5))*(-sqrt(196*sqrt(35) + 1941)/29 - 2*sqrt(7)/29 + 9*sqrt(5)/29), -sqrt(196*sqrt(35) + 1941)/29 - 2*sqrt(7)/29 + 9*sqrt(5)/29)] |
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 should be split onto several lines of length at most 72
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.
sure I will update it.
I have done the changes please see if seems ok to you. |
Thanks, looks good. |
Thanks :) |
Hello @mohitacecode , I just want to know. How are you testing the test files? are you using coverage python or what? thanks. |
You can see how to run all type of test here: |
Thank you so much! 😄 |
References to other Issues or PRs
Fixes #18248
Fixes #13230
Brief description of what is fixed or changed
It solves the type error by:
ext
inAlgebraicField.__init__
.It also solves the Coercion error by:
AlgebraicField.from_AlgebraicField(K1, a, K0)
method.Other comments
Release Notes
orig_ext
and addedfrom_AlgebraicField()
toAlgebraicField
.