Skip to content

Commit a6e928e

Browse files
GiacomoPopetscrim
andauthored
Apply suggestions from code review
Co-authored-by: Travis Scrimshaw <[email protected]>
1 parent 7052c25 commit a6e928e

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/sage/rings/polynomial/polynomial_element.pyx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ from sage.categories.morphism cimport Morphism
133133

134134
from sage.misc.superseded import deprecation_cython as deprecation, deprecated_function_alias
135135
from sage.misc.cachefunc import cached_method
136-
from sage.misc.prandom import choice
137136

138137
cpdef is_Polynomial(f) noexcept:
139138
"""
@@ -2585,10 +2584,6 @@ cdef class Polynomial(CommutativePolynomial):
25852584
if ring not in FiniteFields():
25862585
rs = self.roots(ring=ring, multiplicities=False)
25872586
if rs:
2588-
# TODO: this has been deterministic and changing this to be random
2589-
# breaks many doctests. For now we leave it deterministic but you
2590-
# could change it to choice(rs). This mainly breaks examples over
2591-
# of elliptic curve stuff over number fields
25922587
return rs[0]
25932588
raise ValueError(f"polynomial {self} has no roots")
25942589

@@ -2617,7 +2612,7 @@ cdef class Polynomial(CommutativePolynomial):
26172612
except ValueError:
26182613
raise ValueError(f"no root of polynomial {self} can be computed over the ring {ring}")
26192614
# When d != 1 we then find the smallest extension
2620-
# TODO: This is really annoying. What we should do here is compute some minimal
2615+
# TODO: What we should do here is compute some minimal
26212616
# extension F_ext = self.base_ring().extension(d, names="a") and find a
26222617
# root here and then coerce this root into the parent ring. This means we
26232618
# would work with the smallest possible extension.
@@ -2644,8 +2639,7 @@ cdef class Polynomial(CommutativePolynomial):
26442639
# C library bindings for all finite fields.
26452640
# Until the coercion system for finite fields works better,
26462641
# this will be the most performant
2647-
roots = f.roots(ring, multiplicities=False)
2648-
return choice(roots)
2642+
return f.roots(ring, multiplicities=False)[0]
26492643

26502644
# The old version of `any_root()` allowed degree < 0 to indicate that the input polynomial
26512645
# had a distinct degree factorisation, we pass this to any_irreducible_factor as a bool and
@@ -2697,8 +2691,7 @@ cdef class Polynomial(CommutativePolynomial):
26972691
# C library bindings for all finite fields.
26982692
# Until the coercion system for finite fields works better,
26992693
# this will be the most performant
2700-
roots = f.roots(ring, multiplicities=False)
2701-
return choice(roots)
2694+
return f.roots(ring, multiplicities=False)[0]
27022695

27032696
def __truediv__(left, right):
27042697
r"""

0 commit comments

Comments
 (0)