Skip to content

Commit 033d95a

Browse files
author
Release Manager
committed
gh-36852: `failing doctest on Apple M1`: corrected the test case by sorting the result <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> I have added `rts = sorted(rts, key=lambda x: (x.real(), x.imag()))` after `rts = f.roots(ring=fld_out, multiplicities=False)` in ``` for (fld_in, fld_out) in flds: x = polygen(fld_in) f = x^3 - fld_in(2) x2 = polygen(fld_out) f2 = x2^3 - fld_out(2) for algo in (None, 'pari', 'numpy'): rts = f.roots(ring=fld_out, multiplicities=False) if fld_in == fld_out and algo is None: print("{} {}".format(fld_in, rts)) for rt in rts: assert(abs(f2(rt)) <= 1e-10) assert(rt.parent() == fld_out) ``` I have sorted the rts; first based on the real part of the complex number and then based on the complex part. I have also updated the test result by sorting them aswell. This ensures that the output matches the test results, resulting in a passing test. <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> Fixes #36850 <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> there where also many URL: #36852 Reported by: Aman Moon Reviewer(s): Dima Pasechnik
2 parents 49e6c9f + 4c46019 commit 033d95a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/sage/rings/polynomial/polynomial_element.pyx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8105,6 +8105,7 @@ cdef class Polynomial(CommutativePolynomial):
81058105
....: f2 = x2^3 - fld_out(2)
81068106
....: for algo in (None, 'pari', 'numpy'):
81078107
....: rts = f.roots(ring=fld_out, multiplicities=False)
8108+
....: rts = sorted(rts, key=lambda x: x.imag())
81088109
....: if fld_in == fld_out and algo is None:
81098110
....: print("{} {}".format(fld_in, rts))
81108111
....: for rt in rts:
@@ -8113,9 +8114,9 @@ cdef class Polynomial(CommutativePolynomial):
81138114
Real Field with 53 bits of precision [1.25992104989487]
81148115
Real Double Field [1.25992104989...]
81158116
Real Field with 100 bits of precision [1.2599210498948731647672106073]
8116-
Complex Field with 53 bits of precision [1.25992104989487, -0.62996052494743... - 1.09112363597172*I, -0.62996052494743... + 1.09112363597172*I]
8117-
Complex Double Field [1.25992104989..., -0.629960524947... - 1.0911236359717...*I, -0.629960524947... + 1.0911236359717...*I]
8118-
Complex Field with 100 bits of precision [1.2599210498948731647672106073, -0.62996052494743658238360530364 - 1.0911236359717214035600726142*I, -0.62996052494743658238360530364 + 1.0911236359717214035600726142*I]
8117+
Complex Field with 53 bits of precision [-0.62996052494743... - 1.09112363597172*I, 1.25992104989487, -0.62996052494743... + 1.09112363597172*I]
8118+
Complex Double Field [-0.629960524947... - 1.0911236359717...*I, 1.25992104989487..., -0.629960524947... + 1.0911236359717...*I]
8119+
Complex Field with 100 bits of precision [-0.62996052494743658238360530364 - 1.0911236359717214035600726142*I, 1.2599210498948731647672106073, -0.62996052494743658238360530364 + 1.0911236359717214035600726142*I]
81198120
81208121
Note that we can find the roots of a polynomial with algebraic
81218122
coefficients::

0 commit comments

Comments
 (0)