@@ -133,7 +133,6 @@ from sage.categories.morphism cimport Morphism
133
133
134
134
from sage.misc.superseded import deprecation_cython as deprecation, deprecated_function_alias
135
135
from sage.misc.cachefunc import cached_method
136
- from sage.misc.prandom import choice
137
136
138
137
cpdef is_Polynomial(f) noexcept:
139
138
"""
@@ -2585,10 +2584,6 @@ cdef class Polynomial(CommutativePolynomial):
2585
2584
if ring not in FiniteFields():
2586
2585
rs = self .roots(ring = ring, multiplicities = False )
2587
2586
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
2592
2587
return rs[0 ]
2593
2588
raise ValueError (f" polynomial {self} has no roots" )
2594
2589
@@ -2617,7 +2612,7 @@ cdef class Polynomial(CommutativePolynomial):
2617
2612
except ValueError :
2618
2613
raise ValueError (f" no root of polynomial {self} can be computed over the ring {ring}" )
2619
2614
# 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
2621
2616
# extension F_ext = self.base_ring().extension(d, names="a") and find a
2622
2617
# root here and then coerce this root into the parent ring. This means we
2623
2618
# would work with the smallest possible extension.
@@ -2644,8 +2639,7 @@ cdef class Polynomial(CommutativePolynomial):
2644
2639
# C library bindings for all finite fields.
2645
2640
# Until the coercion system for finite fields works better,
2646
2641
# 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 ]
2649
2643
2650
2644
# The old version of `any_root()` allowed degree < 0 to indicate that the input polynomial
2651
2645
# had a distinct degree factorisation, we pass this to any_irreducible_factor as a bool and
@@ -2697,8 +2691,7 @@ cdef class Polynomial(CommutativePolynomial):
2697
2691
# C library bindings for all finite fields.
2698
2692
# Until the coercion system for finite fields works better,
2699
2693
# 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 ]
2702
2695
2703
2696
def __truediv__ (left , right ):
2704
2697
r """
0 commit comments