diff --git a/src/sage/algebras/fusion_rings/f_matrix.py b/src/sage/algebras/fusion_rings/f_matrix.py index 82d4e300156..a8dc22901c8 100644 --- a/src/sage/algebras/fusion_rings/f_matrix.py +++ b/src/sage/algebras/fusion_rings/f_matrix.py @@ -2199,7 +2199,7 @@ def _fix_gauge(self, algorithm=""): adding equation... fx18 - 1 adding equation... fx21 - 1 """ - while not all(v for v in self._solved): + while not all(self._solved): # Get a variable that has not been fixed # In ascending index order, for consistent results for i, var in enumerate(self._poly_ring.gens()): diff --git a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_element.py b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_element.py index b41cdf32811..723ae5c385a 100644 --- a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_element.py +++ b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_element.py @@ -66,7 +66,7 @@ def T(self, n=1): a, m = self.index() coef = self._monomial_coefficients[(a, m)] if (a, m + n) in p._indices: - return coef * prod(j for j in range(m + 1, m + n + 1))\ + return coef * prod(range(m + 1, m + n + 1))\ * p.monomial((a, m + n)) else: return p.zero() diff --git a/src/sage/categories/examples/commutative_additive_monoids.py b/src/sage/categories/examples/commutative_additive_monoids.py index 7422604e8e9..5295afb55ef 100644 --- a/src/sage/categories/examples/commutative_additive_monoids.py +++ b/src/sage/categories/examples/commutative_additive_monoids.py @@ -124,7 +124,7 @@ def __bool__(self) -> bool: sage: [bool(m) for m in M.additive_semigroup_generators()] [True, True, True, True] """ - return any(x for x in self.value.values()) + return any(self.value.values()) Example = FreeCommutativeAdditiveMonoid diff --git a/src/sage/categories/group_algebras.py b/src/sage/categories/group_algebras.py index 46e36fd47cf..1bc40687c4f 100644 --- a/src/sage/categories/group_algebras.py +++ b/src/sage/categories/group_algebras.py @@ -408,7 +408,7 @@ def central_form(self): sage: G = PermutationGroup([[(1,2,3),(4,5)], [(3,4)]]) # optional - sage.groups sage.modules sage: QG = GroupAlgebras(QQ).example(G) # optional - sage.groups sage.modules - sage: s = sum(i for i in QG.basis()) # optional - sage.groups sage.modules + sage: s = sum(QG.basis()) # optional - sage.groups sage.modules sage: s.central_form() # not tested # optional - sage.groups sage.modules B[()] + B[(4,5)] + B[(3,4,5)] + B[(2,3)(4,5)] + B[(2,3,4,5)] + B[(1,2)(3,4,5)] + B[(1,2,3,4,5)] diff --git a/src/sage/categories/monoids.py b/src/sage/categories/monoids.py index 386b1b133f1..ecf591c7559 100644 --- a/src/sage/categories/monoids.py +++ b/src/sage/categories/monoids.py @@ -589,10 +589,11 @@ def is_central(self): True sage: SG4(Permutation([1,3,2,4])).is_central() # optional - sage.groups sage.modules False + sage: A = GroupAlgebras(QQ).example(); A # optional - sage.groups sage.modules Algebra of Dihedral group of order 8 as a permutation group over Rational Field - sage: sum(i for i in A.basis()).is_central() # optional - sage.groups sage.modules + sage: sum(A.basis()).is_central() # optional - sage.groups sage.modules True """ return all(i * self == self * i diff --git a/src/sage/combinat/crystals/generalized_young_walls.py b/src/sage/combinat/crystals/generalized_young_walls.py index 2d8114eeda2..0ff8a9d3805 100644 --- a/src/sage/combinat/crystals/generalized_young_walls.py +++ b/src/sage/combinat/crystals/generalized_young_walls.py @@ -562,8 +562,8 @@ def weight(self, root_lattice=False): for i in r: W.append(-1*alpha[i]) if not root_lattice: - return E(sum(w for w in W)) - return L(sum(w for w in W)) + return E(sum(W)) + return L(sum(W)) def epsilon(self, i): r""" diff --git a/src/sage/combinat/crystals/littelmann_path.py b/src/sage/combinat/crystals/littelmann_path.py index 89fbf8e4253..7bb0a67ed08 100644 --- a/src/sage/combinat/crystals/littelmann_path.py +++ b/src/sage/combinat/crystals/littelmann_path.py @@ -1330,7 +1330,7 @@ def e(self, i, power=1, length_only=False): return ret WLR = self.parent().weight_lattice_realization() value = list(ret.value) - endpoint = sum(p for p in value) + endpoint = sum(value) rho = WLR.rho() h = WLR.simple_coroots() @@ -1385,7 +1385,7 @@ def f(self, i, power=1, length_only=False): ret = dual_path.dualize() WLR = self.parent().weight_lattice_realization() value = list(ret.value) - endpoint = sum(p for p in value) + endpoint = sum(value) rho = WLR.rho() h = WLR.simple_coroots() diff --git a/src/sage/combinat/derangements.py b/src/sage/combinat/derangements.py index 0be5c209105..0c4b8a3d9d7 100644 --- a/src/sage/combinat/derangements.py +++ b/src/sage/combinat/derangements.py @@ -420,7 +420,7 @@ def cardinality(self): sL = set(self._set) A = [self._set.count(i) for i in sL] R = PolynomialRing(QQ, 'x', len(A)) - S = sum(i for i in R.gens()) + S = sum(R.gens()) e = prod((S - x)**y for (x, y) in zip(R.gens(), A)) return Integer(e.coefficient(dict([(x, y) for (x, y) in zip(R.gens(), A)]))) return self._count_der(len(self._set)) diff --git a/src/sage/combinat/designs/incidence_structures.py b/src/sage/combinat/designs/incidence_structures.py index bac1c481b89..1aa6c34d733 100644 --- a/src/sage/combinat/designs/incidence_structures.py +++ b/src/sage/combinat/designs/incidence_structures.py @@ -2069,7 +2069,7 @@ def coloring(self, k=None, solver=None, verbose=0, raise RuntimeError("No coloring can be defined " "when there is a set of size 1") elif k == 1: - if any(x for x in self._blocks): + if any(self._blocks): raise ValueError("This hypergraph contains a set. " "It is not 1-chromatic") return [self.ground_set()] diff --git a/src/sage/combinat/parallelogram_polyomino.py b/src/sage/combinat/parallelogram_polyomino.py index 56378c527e2..bb73b09df96 100644 --- a/src/sage/combinat/parallelogram_polyomino.py +++ b/src/sage/combinat/parallelogram_polyomino.py @@ -2652,7 +2652,7 @@ def area(self): sage: pp.area() 0 """ - return sum(h for h in self.heights()) + return sum(self.heights()) def _repr_(self) -> str: r""" diff --git a/src/sage/combinat/plane_partition.py b/src/sage/combinat/plane_partition.py index 642bcca5ed0..471335947fa 100644 --- a/src/sage/combinat/plane_partition.py +++ b/src/sage/combinat/plane_partition.py @@ -340,7 +340,7 @@ def number_of_boxes(self) -> Integer: sage: PP.number_of_boxes() 6 """ - return sum(sum(k for k in row) for row in self) + return sum(sum(row) for row in self) def _repr_diagram(self, show_box=False, use_unicode=False) -> str: r""" @@ -451,8 +451,8 @@ def add_leftside(i, j, k): return u"∅" if use_unicode else "" if use_unicode: - return u'\n'.join(u"".join(s for s in row) for row in drawing) - return '\n'.join("".join(s for s in row) for row in drawing) + return u'\n'.join(u"".join(row) for row in drawing) + return '\n'.join("".join(row) for row in drawing) def _ascii_art_(self): r""" diff --git a/src/sage/combinat/posets/poset_examples.py b/src/sage/combinat/posets/poset_examples.py index c31f507edc8..f5b32cc30bd 100644 --- a/src/sage/combinat/posets/poset_examples.py +++ b/src/sage/combinat/posets/poset_examples.py @@ -1002,7 +1002,7 @@ def tableaux_is_less_than(a, b): return all(ix <= iy for x, y in zip(a, b) for ix, iy in zip(x, y)) if f is None: - f = sum(i for i in s) + f = sum(s) E = SemistandardTableaux(s, max_entry=f) return LatticePoset((E, tableaux_is_less_than)) diff --git a/src/sage/combinat/tableau.py b/src/sage/combinat/tableau.py index 0b327db6c06..4df26efd41d 100644 --- a/src/sage/combinat/tableau.py +++ b/src/sage/combinat/tableau.py @@ -4763,12 +4763,12 @@ def standard_descents(self): [] """ descents = [] - #whatpart gives the number for which self is a partition - whatpart = sum(i for i in self.shape()) - #now find the descents + # whatpart gives the number for which self is a partition + whatpart = sum(self.shape()) + # now find the descents for i in range(1, whatpart): - #find out what row i and i+1 are in (we're using the - #standardness of self here) + # find out what row i and i+1 are in (we're using the + # standardness of self here) for row in self: if row.count(i + 1): break diff --git a/src/sage/databases/findstat.py b/src/sage/databases/findstat.py index de96975b692..ecb85b8364e 100644 --- a/src/sage/databases/findstat.py +++ b/src/sage/databases/findstat.py @@ -4187,7 +4187,7 @@ def __hash__(self): EXAMPLES:: sage: from sage.databases.findstat import FindStatCollections - sage: set(c for c in FindStatCollections()) # optional -- internet + sage: set(FindStatCollections()) # optional -- internet {Cc0001: Permutations, Cc0002: Integer partitions, ... diff --git a/src/sage/functions/piecewise.py b/src/sage/functions/piecewise.py index f73b016555c..6955f6209eb 100644 --- a/src/sage/functions/piecewise.py +++ b/src/sage/functions/piecewise.py @@ -1430,7 +1430,7 @@ def _giac_init_(self, parameters, variable): args = [(domain._giac_condition_(variable), func._giac_init_()) for domain, func in parameters] - args = ",".join(a for a in flatten(args)) + args = ",".join(flatten(args)) return f"piecewise({args})" diff --git a/src/sage/games/sudoku.py b/src/sage/games/sudoku.py index 05ba52b1fc6..2d2a2b36ab3 100644 --- a/src/sage/games/sudoku.py +++ b/src/sage/games/sudoku.py @@ -464,7 +464,7 @@ def to_latex(self): nsquare = n*n array = [] array.append('\\begin{array}{|*{%s}{*{%s}{r}|}}\\hline\n' % (n, n)) - gen = (x for x in self.puzzle) + gen = iter(self.puzzle) for row in range(nsquare): for col in range(nsquare): entry = next(gen) diff --git a/src/sage/geometry/hyperplane_arrangement/arrangement.py b/src/sage/geometry/hyperplane_arrangement/arrangement.py index b740ef79956..a5f0dac0b67 100644 --- a/src/sage/geometry/hyperplane_arrangement/arrangement.py +++ b/src/sage/geometry/hyperplane_arrangement/arrangement.py @@ -1833,9 +1833,9 @@ def regions(self): sage: from itertools import product sage: def zero_one(d): ....: for x in product([0,1], repeat=d): - ....: if any(y for y in x): + ....: if any(x): ....: yield [0] + list(x) - ....: + sage: K. = HyperplaneArrangements(QQ) sage: A = K(*zero_one(2)) sage: len(A.regions()) diff --git a/src/sage/geometry/polyhedron/face.py b/src/sage/geometry/polyhedron/face.py index 2166f016ba8..d4d089389ba 100644 --- a/src/sage/geometry/polyhedron/face.py +++ b/src/sage/geometry/polyhedron/face.py @@ -1074,7 +1074,7 @@ def combinatorial_face_to_polyhedral_face(polyhedron, combinatorial_face): elif polyhedron.backend() in ('normaliz', 'cdd', 'field', 'number_field', 'polymake'): # Equations after the inequalities in Hrep. n_ieqs = polyhedron.n_inequalities() - H_indices = tuple(x for x in combinatorial_face.ambient_H_indices(add_equations=False)) + H_indices = tuple(combinatorial_face.ambient_H_indices(add_equations=False)) H_indices += tuple(range(n_ieqs, n_ieqs + n_equations)) else: raise NotImplementedError("unknown backend") diff --git a/src/sage/geometry/polyhedron/library.py b/src/sage/geometry/polyhedron/library.py index f621f9329ff..0d27427d159 100644 --- a/src/sage/geometry/polyhedron/library.py +++ b/src/sage/geometry/polyhedron/library.py @@ -458,7 +458,7 @@ def gale_transform_to_primal(vectors, base_ring=None, backend=None): ker = Matrix(base_ring, vectors).left_kernel() else: ker = Matrix(vectors).left_kernel() - solutions = Polyhedron(lines=tuple(y for y in ker.basis_matrix()), base_ring=base_ring, backend=backend) + solutions = Polyhedron(lines=tuple(ker.basis_matrix()), base_ring=base_ring, backend=backend) from sage.matrix.special import identity_matrix pos_orthant = Polyhedron(rays=identity_matrix(len(vectors)), base_ring=base_ring, backend=backend) @@ -2015,7 +2015,7 @@ def twenty_four_cell(self, backend=None): q12 = QQ((1, 2)) verts = list(itertools.product([q12, -q12], repeat=4)) B4 = (ZZ**4).basis() - verts.extend(v for v in B4) + verts.extend(B4) verts.extend(-v for v in B4) return Polyhedron(vertices=verts, backend=backend) diff --git a/src/sage/manifolds/differentiable/examples/euclidean.py b/src/sage/manifolds/differentiable/examples/euclidean.py index 3c24482356b..21ae796fad5 100644 --- a/src/sage/manifolds/differentiable/examples/euclidean.py +++ b/src/sage/manifolds/differentiable/examples/euclidean.py @@ -694,7 +694,7 @@ def __classcall_private__(cls, n=None, name=None, latex_name=None, if names[1] in ['p', 'ph', 'phi']: names[1] = names[1] + ':\\phi' - symbols = ' '.join(x for x in names) + symbols = ' '.join(names) # Technical bit for UniqueRepresentation from sage.misc.prandom import getrandbits diff --git a/src/sage/manifolds/utilities.py b/src/sage/manifolds/utilities.py index e082e2584af..852dd0be1f1 100644 --- a/src/sage/manifolds/utilities.py +++ b/src/sage/manifolds/utilities.py @@ -987,7 +987,7 @@ def _repr_(self): for i in diffargs) res = "d" + str(numargs) + "(" + str(funcname) + ")/d" + "d".join( - [i for i in occ.values()]) + occ.values()) # str representation of the operator s = self._parent._repr_element_(m[0]) diff --git a/src/sage/modules/fp_graded/module.py b/src/sage/modules/fp_graded/module.py index 79353e754a9..914a4ad1dc1 100755 --- a/src/sage/modules/fp_graded/module.py +++ b/src/sage/modules/fp_graded/module.py @@ -551,7 +551,7 @@ def connectivity(self): # We must check that the generator(s) in the free generator module are # not hit by relations, since we are not guaranteed that the # presentation we have is minimal. - X = sorted(x for x in self.generator_degrees()) + X = sorted(self.generator_degrees()) previous = None for k in X: diff --git a/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py b/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py index 37c2b2b81a6..ea027e8a716 100644 --- a/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py +++ b/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py @@ -1874,7 +1874,7 @@ def asymptotics_smooth(self, p, alpha, N, asy_var, coordinate=None, Uderivs = diff_prod(Hderivs, U, Hcheck, X, range(1, k + 1), end, Uderivs, atP) # Check for a nonzero U derivative. - if any(u for u in Uderivs.values()): + if any(Uderivs.values()): all_zero = False if all_zero: # Then, using a proposition at the end of [RW2012], we can @@ -2265,7 +2265,7 @@ def asymptotics_multiple(self, p, alpha, N, asy_var, coordinate=None, Uderivs = diff_prod(Hprodderivs, U, Hcheck, X, range(1, k + 1), end, Uderivs, atP) # Check for a nonzero U derivative. - if any(u for u in Uderivs.values()): + if any(Uderivs.values()): all_zero = False if all_zero: # Then all higher derivatives of U are zero. diff --git a/src/sage/rings/lazy_series.py b/src/sage/rings/lazy_series.py index f31488d5354..bc22360542e 100644 --- a/src/sage/rings/lazy_series.py +++ b/src/sage/rings/lazy_series.py @@ -1078,7 +1078,7 @@ def __bool__(self): if any(cache[a] for a in cache): return True else: - if any(a for a in self._coeff_stream._cache): + if any(self._coeff_stream._cache): return True v = self._coeff_stream._approximate_order diff --git a/src/sage/rings/lazy_series_ring.py b/src/sage/rings/lazy_series_ring.py index d8ba728a61b..7fc7ead4a4a 100644 --- a/src/sage/rings/lazy_series_ring.py +++ b/src/sage/rings/lazy_series_ring.py @@ -187,8 +187,7 @@ def _element_constructor_(self, x=None, valuation=None, degree=None, constant=No sage: def g(i): ....: if i < 0: ....: return 1 - ....: else: - ....: return 1 + sum(k for k in range(i+1)) + ....: return 1 + sum(range(i + 1)) sage: e = L(g, valuation=-5); e z^-5 + z^-4 + z^-3 + z^-2 + z^-1 + 1 + 2*z + O(z^2) sage: f = e^-1; f diff --git a/src/sage/rings/polynomial/polydict.pyx b/src/sage/rings/polynomial/polydict.pyx index 3db1bb6c531..a807a33f9f8 100644 --- a/src/sage/rings/polynomial/polydict.pyx +++ b/src/sage/rings/polynomial/polydict.pyx @@ -716,7 +716,7 @@ cdef class PolyDict: return True if len(self.__repn) > 1: return False - return not any(e for e in self.__repn) + return not any(self.__repn) def homogenize(self, size_t var): r""" diff --git a/src/sage/schemes/elliptic_curves/cm.py b/src/sage/schemes/elliptic_curves/cm.py index 57f8744dc80..1eeee0cc9f3 100644 --- a/src/sage/schemes/elliptic_curves/cm.py +++ b/src/sage/schemes/elliptic_curves/cm.py @@ -209,7 +209,7 @@ def is_HCP(f, check_monic_irreducible=True): sage: H = hilbert_class_polynomial(D) sage: H.degree() 100 - sage: max(c for c in H).ndigits() + sage: max(H).ndigits() 2774 sage: is_HCP(H) -1856563 diff --git a/src/sage/sets/totally_ordered_finite_set.py b/src/sage/sets/totally_ordered_finite_set.py index 8289c10c93a..c2ce75bd8ce 100644 --- a/src/sage/sets/totally_ordered_finite_set.py +++ b/src/sage/sets/totally_ordered_finite_set.py @@ -241,7 +241,7 @@ def __classcall__(cls, iterable, facade=True): sage: S1 = TotallyOrderedFiniteSet([1, 2, 3]) sage: S2 = TotallyOrderedFiniteSet((1, 2, 3)) - sage: S3 = TotallyOrderedFiniteSet((x for x in range(1,4))) + sage: S3 = TotallyOrderedFiniteSet(range(1,4)) sage: S1 is S2 True sage: S2 is S3