From cff51df0d57870061e58796548fd7ac08a752a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sat, 8 Nov 2025 09:31:28 +0100 Subject: [PATCH] fixing a few badly written loops --- src/sage/graphs/strongly_regular_db.pyx | 7 ++++--- src/sage/modules/fp_graded/module.py | 6 ++++-- src/sage/plot/animate.py | 3 ++- src/sage/schemes/elliptic_curves/ell_field.py | 3 ++- src/sage/topology/simplicial_complex.py | 4 ++-- src/sage/topology/simplicial_set_examples.py | 5 +++-- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/sage/graphs/strongly_regular_db.pyx b/src/sage/graphs/strongly_regular_db.pyx index 8010b309869..84d4b272c0c 100644 --- a/src/sage/graphs/strongly_regular_db.pyx +++ b/src/sage/graphs/strongly_regular_db.pyx @@ -2492,16 +2492,17 @@ def strongly_regular_from_two_intersection_set(M): M = [list(p) for p in M] # For every point in F_q^{k+1} not on the hyperplane of M - for u in [tuple(x) for x in product(K,repeat=k)]: + for x in product(K, repeat=k): + u = tuple(x) # For every v point of M for v in M: # u is adjacent with all vertices on a uv line. g.add_edges([[u, tuple([u[i] + qq*v[i] for i in range(k)])] for qq in K if not qq == K.zero()]) g.relabel() - e = QQ((1,k)) + e = QQ((1, k)) qq = g.n_vertices()**e - g.name('two-intersection set in PG('+str(k)+','+str(qq)+')') + g.name(f'two-intersection set in PG({k},{qq})') return g diff --git a/src/sage/modules/fp_graded/module.py b/src/sage/modules/fp_graded/module.py index 77a51e1b4b9..8c04a1fa107 100644 --- a/src/sage/modules/fp_graded/module.py +++ b/src/sage/modules/fp_graded/module.py @@ -175,10 +175,12 @@ def __classcall__(cls, arg0, generator_degrees=None, relations=(), names=None): # Use the coefficients given for the relations and make module elements # from them. Filter out the zero elements, as they are redundant. - rels = [v for v in [generator_module(r) for r in relations] if not v.is_zero()] + rels = [v for r in relations + if not (v := generator_module(r)).is_zero()] # The free module for the relations of the module. - relations_module = arg0.free_graded_module(tuple([r.degree() for r in rels])) + relations_module = arg0.free_graded_module(tuple([r.degree() + for r in rels])) # The module we want to model is the cokernel of the following morphism j = Hom(relations_module, generator_module)(rels) diff --git a/src/sage/plot/animate.py b/src/sage/plot/animate.py index 6a9454d04ab..f73f74c644c 100644 --- a/src/sage/plot/animate.py +++ b/src/sage/plot/animate.py @@ -281,7 +281,8 @@ def _combine_kwds(self, *kwds_tuple): new_kwds.update(kwds) for name in ['xmin', 'xmax', 'ymin', 'ymax']: - values = [v for v in [kwds.get(name, None) for kwds in kwds_tuple] if v is not None] + values = [v for kwds in kwds_tuple + if (v := kwds.get(name, None)) is not None] if values: new_kwds[name] = getattr(builtins, name[1:])(values) return new_kwds diff --git a/src/sage/schemes/elliptic_curves/ell_field.py b/src/sage/schemes/elliptic_curves/ell_field.py index f3008b44989..51d18a727cf 100644 --- a/src/sage/schemes/elliptic_curves/ell_field.py +++ b/src/sage/schemes/elliptic_curves/ell_field.py @@ -2594,7 +2594,8 @@ class of curves. If the j-invariant is not unique in the isogeny curve_max = 0 r = [0] * len(Es) # adjacency matrix row - for C in [I.codomain() for I in E.isogenies_prime_degree(l)]: + for I in E.isogenies_prime_degree(l): + C = I.codomain() j = next((k for k, F in enumerate(Es) if C.is_isomorphic(F)), -1) # index of curve isomorphic to codomain of isogeny if j >= 0: diff --git a/src/sage/topology/simplicial_complex.py b/src/sage/topology/simplicial_complex.py index cc3253ec937..3cd267d135a 100644 --- a/src/sage/topology/simplicial_complex.py +++ b/src/sage/topology/simplicial_complex.py @@ -1763,10 +1763,10 @@ def is_pseudomanifold(self) -> bool: if d == 0: return len(self.facets()) == 2 F = self.facets() - X = self.faces()[d-1] + X = self.faces()[d - 1] # is each (d-1)-simplex is the face of exactly two facets? for s in X: - if len([a for a in [s.is_face(f) for f in F] if a]) != 2: + if len([1 for f in F if s.is_face(f)]) != 2: return False # construct a graph with one vertex for each facet, one edge # when two facets intersect in a (d-1)-simplex, and see diff --git a/src/sage/topology/simplicial_set_examples.py b/src/sage/topology/simplicial_set_examples.py index 5f0a4f2d228..be7a4084be2 100644 --- a/src/sage/topology/simplicial_set_examples.py +++ b/src/sage/topology/simplicial_set_examples.py @@ -683,9 +683,10 @@ def simplicial_data_from_kenzo_output(filename) -> dict: else: simplex_string = data[start:end].strip() - for s in [_.strip() for _ in simplex_string.split('Simplex : ')]: + for ns in simplex_string.split('Simplex : '): + s = ns.strip() if s: - name, face_str = (_.strip() for _ in s.split('Faces : ')) + name, face_str = (nf.strip() for nf in s.split('Faces : ')) face_str = face_str.strip('()') face_str = face_str.split('