diff --git a/build/pkgs/configure/checksums.ini b/build/pkgs/configure/checksums.ini index e540688b62a..cb57961cae7 100644 --- a/build/pkgs/configure/checksums.ini +++ b/build/pkgs/configure/checksums.ini @@ -1,4 +1,4 @@ tarball=configure-VERSION.tar.gz -sha1=1041fee1d3ed5dc9c6c428668a895fb7109a48e5 -md5=e254e55345074cd0959cb21c8e4716ca -cksum=1271538328 +sha1=f352191d84047e5533516d7c6d36c4c774311e9e +md5=a432b194d57f7212100df43d7c9dd322 +cksum=2972134300 diff --git a/build/pkgs/configure/package-version.txt b/build/pkgs/configure/package-version.txt index d4589494fee..87bba198ebf 100644 --- a/build/pkgs/configure/package-version.txt +++ b/build/pkgs/configure/package-version.txt @@ -1 +1 @@ -c6bf497a0fd0f29c721481b52afaf49969c0cef8 +c6f7c918a0dc9922fe1bbc9255215014e45961e8 diff --git a/src/sage/rings/polynomial/binary_form_reduce.py b/src/sage/rings/polynomial/binary_form_reduce.py index 1a9896f2199..bb6b4296d1a 100644 --- a/src/sage/rings/polynomial/binary_form_reduce.py +++ b/src/sage/rings/polynomial/binary_form_reduce.py @@ -202,8 +202,7 @@ def covariant_z0(F, z0_cov=False, prec=53, emb=None, error_limit=0.000001): for p, e in L1: if e >= d / 2: raise ValueError('cannot have a root with multiplicity >= %s/2' % d) - for _ in range(e): - L.append(p) + L.extend(p for _ in range(e)) RCF = PolynomialRing(CF, 'u,t') a = RCF.zero() c = RCF.zero() diff --git a/src/sage/rings/polynomial/complex_roots.py b/src/sage/rings/polynomial/complex_roots.py index 4c66eeca40c..346b49d257c 100644 --- a/src/sage/rings/polynomial/complex_roots.py +++ b/src/sage/rings/polynomial/complex_roots.py @@ -290,8 +290,7 @@ def complex_roots(p, skip_squarefree=False, retval='interval', min_prec=0): break if retval != 'interval': factor = QQbar.common_polynomial(factor) - for irt in irts: - all_rts.append((irt, factor, exp)) + all_rts.extend((irt, factor, exp) for irt in irts) if ok and intervals_disjoint([rt for (rt, fac, mult) in all_rts]): all_rts = sort_complex_numbers_for_display(all_rts) diff --git a/src/sage/rings/polynomial/groebner_fan.py b/src/sage/rings/polynomial/groebner_fan.py index eb8928d09b5..cc6b5b9557b 100644 --- a/src/sage/rings/polynomial/groebner_fan.py +++ b/src/sage/rings/polynomial/groebner_fan.py @@ -643,11 +643,7 @@ def verts_for_normal(normal, poly): expmat = matrix(exps) vals = expmat * vector(QQ, normal) maxval = max(vals) - outverts = [] - for i in range(len(exps)): - if vals[i] == maxval: - outverts.append(exps[i]) - return outverts + return [exps[i] for i in range(len(exps)) if vals[i] == maxval] class TropicalPrevariety(PolyhedralFan): @@ -1316,16 +1312,13 @@ def render(self, file=None, larger=False, shift=0, rgbcolor=(0, 0, 0), xs = x.split(' ') y = [] if x[0:3] != '2 3' and len(xs) > 1: - for q in xs: - if q != '': - y.append(q) + y.extend(q for q in xs if q) sp2.append(y) sp3 = [] for j in range(len(sp2)): - temp = [] - for i in range(0, len(sp2[j]) - 1, 2): - temp.append([float(sp2[j][i]) / 1200.0, - float(sp2[j][i + 1]) / 1200.0]) + temp = [[float(sp2[j][i]) / 1200.0, + float(sp2[j][i + 1]) / 1200.0] + for i in range(0, len(sp2[j]) - 1, 2)] sp3.append(temp) r_lines = Graphics() for x in sp3: @@ -1370,10 +1363,7 @@ def _cone_to_ieq(self, facet_list): sage: gf._cone_to_ieq([[1,2,3,4]]) [[0, 1, 2, 3, 4]] """ - ieq_list = [] - for q in facet_list: - ieq_list.append([0] + q) - return ieq_list + return [[0] + q for q in facet_list] def _embed_tetra(self, fpoint): """ @@ -1505,8 +1495,7 @@ def render3d(self, verbose=False): except Exception: print(cone_data._rays) raise RuntimeError - for a_line in cone_lines: - all_lines.append(a_line) + all_lines.extend(a_line for a_line in cone_lines) return sum([line3d(a_line) for a_line in all_lines]) def _gfan_stats(self): diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py index b5de2e43a49..8d8b0de782c 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ideal.py +++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py @@ -605,9 +605,8 @@ def _groebner_cover(self): from sage.libs.singular.function import lib, singular_function lib("grobcov.lib") grobcov = singular_function("grobcov") - polynomials = [] - for f in self.gens(): - polynomials.append(f * lcm([c.denominator() for c in f.coefficients()])) + polynomials = [f * lcm([c.denominator() for c in f.coefficients()]) + for f in self.gens()] return grobcov(self.ring().ideal(polynomials)) @@ -2853,10 +2852,8 @@ def _variety(T, V, v=None): from sage.misc.converting_dict import KeyConvertingDict V = [] for t in T: - Vbar = _variety([P(f) for f in t], []) - - for v in Vbar: - V.append(KeyConvertingDict(P, v)) + V.extend(KeyConvertingDict(P, v) + for v in _variety([P(f) for f in t], [])) return V @require_field @@ -5586,8 +5583,8 @@ def weil_restriction(self): map_ideal = [a] variables = iter(intermediate_ring.gens()[1:]) - for _ in range(nvars): - map_ideal.append(sum([a**i * next(variables) for i in range(r)])) + map_ideal.extend(sum([a**i * next(variables) for i in range(r)]) + for _ in range(nvars)) myminpoly = myminpoly(*map_ideal) l = [f(*map_ideal).reduce([myminpoly]) for f in l] diff --git a/src/sage/rings/polynomial/pbori/blocks.py b/src/sage/rings/polynomial/pbori/blocks.py index 752e0a14ee8..ba6b9c7b493 100644 --- a/src/sage/rings/polynomial/pbori/blocks.py +++ b/src/sage/rings/polynomial/pbori/blocks.py @@ -57,10 +57,7 @@ def __init__(self, var_names, size_per_variable, start_index=0, if reverse: indices = reversed(indices) - names = [] - for i in indices: - for n in var_names: - names.append(n + "(" + str(i) + ")") + names = [f"{n}({str(i)})" for i in indices for n in var_names] self.indices = indices self.index2pos = {v: k for k, v in enumerate(indices)} self.names = names diff --git a/src/sage/rings/polynomial/pbori/cnf.py b/src/sage/rings/polynomial/pbori/cnf.py index 9f9e670a4c9..266a6f0f8a8 100644 --- a/src/sage/rings/polynomial/pbori/cnf.py +++ b/src/sage/rings/polynomial/pbori/cnf.py @@ -144,18 +144,14 @@ def dimacs_encode_polynomial(self, p): TESTS:: sage: from sage.rings.polynomial.pbori import * - sage: d=dict() + sage: d = {} sage: r = declare_ring(["x", "y", "z"], d) sage: from sage.rings.polynomial.pbori.cnf import CNFEncoder sage: e = CNFEncoder(r) sage: sorted(e.dimacs_encode_polynomial(d["x"]+d["y"]+d["z"])) ['-1 -2 -3 0', '-1 2 3 0', '1 -2 3 0', '1 2 -3 0'] """ - clauses = self.clauses(p) - res = [] - for c in clauses: - res.append(self.dimacs_encode_clause(c)) - return res + return [self.dimacs_encode_clause(c) for c in self.clauses(p)] def dimacs_cnf(self, polynomial_system): r""" @@ -174,13 +170,12 @@ def dimacs_cnf(self, polynomial_system): 'c cnf generated by PolyBoRi\np cnf 3 3\n-1 -2 -3 0\n1 -2 0\n-1 2 0' """ clauses_list = [c for p in polynomial_system for c in self. - dimacs_encode_polynomial(p)] + dimacs_encode_polynomial(p)] res = ["c cnf generated by PolyBoRi"] r = polynomial_system[0].ring() n_variables = r.n_variables() res.append("p cnf %s %s" % (n_variables, len(clauses_list))) - for c in clauses_list: - res.append(c) + res.extend(clauses_list) return "\n".join(res) @@ -239,6 +234,6 @@ def dimacs_cnf(self, polynomial_system): """ uv = list(used_vars_set(polynomial_system).variables()) res = super().dimacs_cnf(polynomial_system) - res = res + "\n" + "\n".join(["c v %s %s" % (self.to_dimacs_index(v), - v) for v in uv]) + res += "\n" + "\n".join("c v %s %s" % (self.to_dimacs_index(v), v) + for v in uv) return res diff --git a/src/sage/rings/polynomial/pbori/easy_polynomials.py b/src/sage/rings/polynomial/pbori/easy_polynomials.py index 8641e93afa3..8451e7536ee 100644 --- a/src/sage/rings/polynomial/pbori/easy_polynomials.py +++ b/src/sage/rings/polynomial/pbori/easy_polynomials.py @@ -20,9 +20,7 @@ def easy_linear_polynomials(p): res = [] if p.deg() >= 2: if p.vars_as_monomial().deg() > 8: - opp = p + 1 - for q in easy_linear_factors(opp): - res.append(q + 1) + res.extend(q + 1 for q in easy_linear_factors(p + 1)) else: res = easy_linear_polynomials_via_interpolation(p) return res diff --git a/src/sage/rings/polynomial/pbori/gbcore.py b/src/sage/rings/polynomial/pbori/gbcore.py index 5880a6811a7..3eb6a73ff25 100644 --- a/src/sage/rings/polynomial/pbori/gbcore.py +++ b/src/sage/rings/polynomial/pbori/gbcore.py @@ -488,14 +488,14 @@ def eliminate_identical_variables_pre(I, prot): def my_sort_key(l): return l.navigation().value() + for (t, leads) in rules.items(): if len(leads) > 1: changed = True leads = sorted(leads, key=my_sort_key, reverse=True) chosen = leads[0] - for v in leads[1:]: - ll_system.append(chosen + v) - if len(ll_system) > 0: + ll_system.extend(chosen + v for v in leads[1:]) + if ll_system: ll_encoded = ll_encode(ll_system, reduce=True) I = set(ll_red_nf_redsb(p, ll_encoded) for p in I) return (I, ll_system) @@ -592,7 +592,7 @@ def call_algorithm(I, max_generators=None): if clean_and_restart_algorithm: for max_generators in [1000, 10000, 50000, 100000, 200000, 300000, - 400000, None]: + 400000, None]: try: return call_algorithm(I, max_generators=max_generators) except GeneratorLimitExceeded as e: @@ -600,7 +600,7 @@ def call_algorithm(I, max_generators=None): del e.strat if prot: print("generator limit exceeded:", max_generators, - "restarting algorithm") + "restarting algorithm") else: return call_algorithm(I) diff --git a/src/sage/rings/polynomial/pbori/randompoly.py b/src/sage/rings/polynomial/pbori/randompoly.py index b0327a50062..1e0dcd56189 100644 --- a/src/sage/rings/polynomial/pbori/randompoly.py +++ b/src/sage/rings/polynomial/pbori/randompoly.py @@ -67,10 +67,8 @@ def sparse_random_system(ring, number_of_polynomials, variables_per_polynomial, if random_seed is not None: set_random_seed(random_seed) random_generator = Random(random_seed) - solutions = [] variables = [ring.variable(i) for i in range(ring.n_variables())] - for v in variables: - solutions.append(v + random_generator.randint(0, 1)) + solutions = [v + random_generator.randint(0, 1) for v in variables] solutions = ll_encode(solutions) res = [] while len(res) < number_of_polynomials: diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py index 0713a334afb..6b39d95752b 100644 --- a/src/sage/rings/polynomial/polynomial_quotient_ring.py +++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py @@ -1362,11 +1362,12 @@ def _S_decomposition(self, S): if not seen_before: S_abs = [] for p in S: - abs_gens = [] - for g in D.ideal(p.gens()).gens(): # this line looks a bit silly, due to inconsistency over QQ - see # 7596 - abs_gens.append(D_abs.structure()[1](g)) - S_abs += [pp for pp,_ in D_abs.ideal(abs_gens).factor()] - iso_classes.append((D_abs,S_abs)) + # next line looks a bit silly, + # due to inconsistency over QQ - see # 7596 + abs_gens = [D_abs.structure()[1](g) + for g in D.ideal(p.gens()).gens()] + S_abs += [pp for pp, _ in D_abs.ideal(abs_gens).factor()] + iso_classes.append((D_abs, S_abs)) isos.append((D_abs.embeddings(D_abs)[0], j)) return fields, isos, iso_classes diff --git a/src/sage/rings/polynomial/toy_variety.py b/src/sage/rings/polynomial/toy_variety.py index 6b0572e6010..b64d540ba63 100644 --- a/src/sage/rings/polynomial/toy_variety.py +++ b/src/sage/rings/polynomial/toy_variety.py @@ -289,8 +289,7 @@ def triangular_factorization(B, n=-1): # now add the current factor q of p to the factorization for each in T: each.append(q) - for each in T: - family.append(each) + family.extend(T) return family