@@ -2172,8 +2172,8 @@ cdef class Polynomial(CommutativePolynomial):
2172
2172
return self
2173
2173
2174
2174
# We expect to succeed with greater than 1/2 probability,
2175
- # so if we try 1000 times and fail, there's a bug somewhere.
2176
- for _ in range (1000 ):
2175
+ # so if we try 100 times and fail, there's a bug somewhere.
2176
+ for _ in range (100 ):
2177
2177
# Sample a polynomial "uniformly" from R
2178
2178
# TODO: once #37118 has been merged, this can be made cleaner,
2179
2179
# as we will actually have access to uniform sampling.
@@ -2281,7 +2281,9 @@ cdef class Polynomial(CommutativePolynomial):
2281
2281
return poly._cantor_zassenhaus_split_to_irreducible(d)
2282
2282
elif ZZ(d).divides(ext_degree):
2283
2283
return poly._cantor_zassenhaus_split_to_irreducible(d)
2284
- raise ValueError (f" no irreducible factor could be computed from {self}" )
2284
+ if d > ext_degree:
2285
+ raise ValueError (f" no irreducible factor of degree {degree} dividing {ext_degree} could be computed from {self}" )
2286
+ raise AssertionError (f" no irreducible factor could be computed from {self}" )
2285
2287
2286
2288
def any_irreducible_factor (self , degree = None , assume_squarefree = False , assume_distinct_deg = False , ext_degree = None ):
2287
2289
"""
@@ -2436,6 +2438,9 @@ cdef class Polynomial(CommutativePolynomial):
2436
2438
# If degree has been set, there could just be no factor of the desired degree
2437
2439
if degree:
2438
2440
raise ValueError (f" polynomial {self} has no irreducible factor of degree {degree}" )
2441
+ # If ext_degree has been set, then there may be no irreducible factor of degree dividing ext_degree
2442
+ if ext_degree:
2443
+ raise ValueError (f" polynomial {self} has no irreducible factor of degree dividing {ext_degree}" )
2439
2444
# But if any degree is allowed then there should certainly be a factor if self has degree > 0
2440
2445
raise AssertionError (f" no irreducible factor was computed for {self}. Bug." )
2441
2446
0 commit comments