diff --git a/src/sage/categories/regular_crystals.py b/src/sage/categories/regular_crystals.py index 0459c0e0695..e2f12ca9f1a 100644 --- a/src/sage/categories/regular_crystals.py +++ b/src/sage/categories/regular_crystals.py @@ -427,10 +427,7 @@ def dual_equivalence_graph(self, X=None, index_set=None, directed=True): index_set = self.index_set() def wt_zero(x): - for i in index_set: - if x.epsilon(i) != x.phi(i): - return False - return True + return all(x.epsilon(i) == x.phi(i) for i in index_set) if X is None: X = [x for x in self if wt_zero(x)] diff --git a/src/sage/coding/linear_code_no_metric.py b/src/sage/coding/linear_code_no_metric.py index 441e3713571..0845e19dee8 100644 --- a/src/sage/coding/linear_code_no_metric.py +++ b/src/sage/coding/linear_code_no_metric.py @@ -847,7 +847,7 @@ def __hash__(self): G = self.generator_matrix() return hash((Str, G)) ^ hash(Str) ^ hash(G) - def is_subcode(self, other): + def is_subcode(self, other) -> bool: """ Return ``True`` if ``self`` is a subcode of ``other``. @@ -880,7 +880,7 @@ def is_subcode(self, other): G = self.generator_matrix() return all(r in other for r in G.rows()) - def is_permutation_automorphism(self, g): + def is_permutation_automorphism(self, g) -> bool: r""" Return `1` if `g` is an element of `S_n` (`n` = length of ``self``) and if `g` is an automorphism of ``self``. @@ -907,11 +907,9 @@ def is_permutation_automorphism(self, g): basis = self.generator_matrix().rows() H = self.parity_check_matrix() V = H.column_space() - HGm = H*g.matrix() - for c in basis: - if HGm*c != V(0): - return False - return True + HGm = H * g.matrix() + V0 = V.zero() + return all(HGm * c == V0 for c in basis) def permuted_code(self, p): r""" diff --git a/src/sage/combinat/bijectionist.py b/src/sage/combinat/bijectionist.py index 3504fac8231..f486def0a47 100644 --- a/src/sage/combinat/bijectionist.py +++ b/src/sage/combinat/bijectionist.py @@ -2762,13 +2762,9 @@ def evaluate(f): coeff * values[index_block_value_dict[index]] for index, coeff in f.dict().items()) - for lhs, rhs in constraint.equations(): - if evaluate(lhs - rhs): - return False - for lhs, rhs in constraint.inequalities(): - if evaluate(lhs - rhs) > 0: - return False - return True + if any(evaluate(lhs - rhs) for lhs, rhs in constraint.equations()): + return False + return all(evaluate(lhs - rhs) <= 0 for lhs, rhs in constraint.inequalities()) def add_alpha_beta_constraints(self): r""" diff --git a/src/sage/combinat/designs/covering_design.py b/src/sage/combinat/designs/covering_design.py index afce7ec3091..2e75b2398d2 100644 --- a/src/sage/combinat/designs/covering_design.py +++ b/src/sage/combinat/designs/covering_design.py @@ -311,10 +311,7 @@ def is_covering(self): for z in Skt: y = (a[x] for x in z) tset[tuple(y)] = True - for i in Svt: - if not tset[tuple(i)]: # uncovered - return False - return True # everything was covered + return all(tset[tuple(i)] for i in Svt) # everything was covered def v(self): """ diff --git a/src/sage/combinat/designs/difference_family.py b/src/sage/combinat/designs/difference_family.py index 3cb8c96d827..983235d5c79 100644 --- a/src/sage/combinat/designs/difference_family.py +++ b/src/sage/combinat/designs/difference_family.py @@ -2029,10 +2029,7 @@ def is_fixed_relative_difference_set(R, q): sage: is_fixed_relative_difference_set(s2, len(s2)) # needs sage.libs.pari sage.modules False """ - for el in R: - if q * el not in R: - return False - return True + return all(q * el in R for el in R) def skew_supplementary_difference_set_over_polynomial_ring(n, existence=False, check=True): diff --git a/src/sage/combinat/ncsym/ncsym.py b/src/sage/combinat/ncsym/ncsym.py index f1438f2059e..3d46d2ebb22 100644 --- a/src/sage/combinat/ncsym/ncsym.py +++ b/src/sage/combinat/ncsym/ncsym.py @@ -399,10 +399,8 @@ def _m_to_p_on_basis(self, A): def lt(s, t): if s == t: return False - for p in s: - if len([z for z in t if z.intersection(p)]) != 1: - return False - return True + return all(len([1 for z in t if z.intersection(p)]) == 1 + for p in s) p = self.realization_of().p() P = Poset((A.coarsenings(), lt)) @@ -1733,10 +1731,8 @@ def _x_to_p_on_basis(self, A): def lt(s, t): if s == t: return False - for p in s: - if len([z for z in t if z.intersection(p)]) != 1: - return False - return True + return all(len([1 for z in t if z.intersection(p)]) == 1 + for p in s) p = self.realization_of().p() P_refine = Poset((A.refinements(), lt)) diff --git a/src/sage/combinat/partition_algebra.py b/src/sage/combinat/partition_algebra.py index 91e79be4cbc..eeac55ed696 100644 --- a/src/sage/combinat/partition_algebra.py +++ b/src/sage/combinat/partition_algebra.py @@ -191,7 +191,7 @@ def _repr_(self): s = self.k + 1 return "Set partitions of {1, ..., %s, -1, ..., -%s} with %s and -%s in the same block" % (s, s, s, s) - def __contains__(self, x): + def __contains__(self, x) -> bool: """ TESTS:: @@ -207,11 +207,8 @@ def __contains__(self, x): if x not in SetPartitionsAk_k(self.k + 1): return False - for part in x: - if self.k + 1 in part and -self.k - 1 not in part: - return False - - return True + return all(self.k + 1 not in part or -self.k - 1 in part + for part in x) def __iter__(self): """ @@ -668,11 +665,7 @@ def __contains__(self, x): if not SetPartitionsAk_k.__contains__(self, x): return False - for part in x: - if len(part) != 2: - return False - - return True + return all(len(part) == 2 for part in x) def cardinality(self): r""" @@ -764,10 +757,7 @@ def __contains__(self, x): """ if not SetPartitionsAkhalf_k.__contains__(self, x): return False - for part in x: - if len(part) != 2: - return False - return True + return all(len(part) == 2 for part in x) def cardinality(self): """ diff --git a/src/sage/combinat/posets/posets.py b/src/sage/combinat/posets/posets.py index e4e0ebb5607..0754db0a0f4 100644 --- a/src/sage/combinat/posets/posets.py +++ b/src/sage/combinat/posets/posets.py @@ -8057,10 +8057,7 @@ def is_rank_symmetric(self) -> bool: raise ValueError("the poset is not graded") levels = self._hasse_diagram.level_sets() h = len(levels) - for i in range(h // 2): - if len(levels[i]) != len(levels[h - 1 - i]): - return False - return True + return all(len(levels[i]) == len(levels[h - 1 - i]) for i in range(h // 2)) def is_slender(self, certificate=False) -> bool | tuple: r""" diff --git a/src/sage/combinat/root_system/root_lattice_realizations.py b/src/sage/combinat/root_system/root_lattice_realizations.py index a0cdc6ab887..2f2c422b7be 100644 --- a/src/sage/combinat/root_system/root_lattice_realizations.py +++ b/src/sage/combinat/root_system/root_lattice_realizations.py @@ -4435,10 +4435,7 @@ def is_parabolic_root(self, index_set): sage: alpha.is_parabolic_root([2]) False """ - for i in self.support(): - if i not in index_set: - return False - return True + return all(i in index_set for i in self.support()) def is_short_root(self): r""" diff --git a/src/sage/combinat/set_partition.py b/src/sage/combinat/set_partition.py index 6a2d8751fcd..f561d95b6fd 100644 --- a/src/sage/combinat/set_partition.py +++ b/src/sage/combinat/set_partition.py @@ -2099,11 +2099,7 @@ def __contains__(self, x): return False # Check to make sure each element of x is a set - for s in x: - if not isinstance(s, (set, frozenset, Set_generic)): - return False - - return True + return all(isinstance(s, (set, frozenset, Set_generic)) for s in x) def _element_constructor_(self, s, check=True): """ diff --git a/src/sage/combinat/sf/ns_macdonald.py b/src/sage/combinat/sf/ns_macdonald.py index 79379b26952..a26d1efa45a 100644 --- a/src/sage/combinat/sf/ns_macdonald.py +++ b/src/sage/combinat/sf/ns_macdonald.py @@ -352,10 +352,7 @@ def is_non_attacking(self): sage: a.is_non_attacking() True """ - for a, b in self.attacking_boxes(): - if self[a] == self[b]: - return False - return True + return all(self[a] != self[b] for a, b in self.attacking_boxes()) def weight(self): """ diff --git a/src/sage/combinat/skew_tableau.py b/src/sage/combinat/skew_tableau.py index a7551621f4e..1aadb563e21 100644 --- a/src/sage/combinat/skew_tableau.py +++ b/src/sage/combinat/skew_tableau.py @@ -1811,11 +1811,7 @@ def is_ribbon(self) -> bool: v += 1 # Check if lam[i]==mu[i] for all i >= v - for i in range(v, l_out): - if lam[i] != mu[i]: - return False - - return True + return all(lam[i] == mu[i] for i in range(v, l_out)) def to_ribbon(self, check_input=True): """ diff --git a/src/sage/combinat/words/finite_word.py b/src/sage/combinat/words/finite_word.py index ea3c17f8ce7..3642c8dc3b1 100644 --- a/src/sage/combinat/words/finite_word.py +++ b/src/sage/combinat/words/finite_word.py @@ -3581,13 +3581,9 @@ def has_period(self, p) -> bool: """ if p < 0: return False - elif p >= len(self): - return True - else: - for i in range(len(self) - p): - if self[i] != self[i + p]: - return False + if p >= len(self): return True + return all(self[i] == self[i + p] for i in range(len(self) - p)) def periods(self, divide_length=False): r""" diff --git a/src/sage/combinat/words/morphism.py b/src/sage/combinat/words/morphism.py index f9407adbb11..fe77b50fcfd 100644 --- a/src/sage/combinat/words/morphism.py +++ b/src/sage/combinat/words/morphism.py @@ -1324,10 +1324,7 @@ def is_erasing(self): sage: WordMorphism('').is_erasing() False """ - for image in self.images(): - if image.is_empty(): - return True - return False + return any(image.is_empty() for image in self.images()) def is_identity(self): r""" @@ -1547,10 +1544,7 @@ def _check_primitive(self): """ dom_alphabet = set(self.domain().alphabet()) - for image in self.images(): - if not dom_alphabet <= set(image): - return False - return True + return all(dom_alphabet <= set(image) for image in self.images()) def is_primitive(self): r""" @@ -2422,10 +2416,7 @@ def has_conjugate_in_classP(self, f=None) -> bool: sage: (fibo^2).has_conjugate_in_classP() True """ - for k in self.list_of_conjugates(): - if k.is_in_classP(f=f): - return True - return False + return any(k.is_in_classP(f=f) for k in self.list_of_conjugates()) def dual_map(self, k=1): r""" diff --git a/src/sage/crypto/util.py b/src/sage/crypto/util.py index dba4b1458ac..410bdd0cc85 100644 --- a/src/sage/crypto/util.py +++ b/src/sage/crypto/util.py @@ -342,10 +342,7 @@ def has_blum_prime(lbound, ubound) -> bool: if lbound > ubound: raise ValueError("The lower bound must be less than the upper bound.") # now test for presence of a Blum prime - for p in primes(lbound, ubound + 1): - if mod(p, 4).lift() == 3: - return True - return False + return any(mod(p, 4).lift() == 3 for p in primes(lbound, ubound + 1)) def is_blum_prime(n): diff --git a/src/sage/doctest/external.py b/src/sage/doctest/external.py index 3e9f1478d9d..96c418ff8f5 100644 --- a/src/sage/doctest/external.py +++ b/src/sage/doctest/external.py @@ -507,10 +507,7 @@ def issuperset(self, other): sage: available_software.issuperset(set(['internet','latex','magma'])) # random, optional - internet latex magma True """ - for item in other: - if item not in self: - return False - return True + return all(item in self for item in other) def detectable(self): """ diff --git a/src/sage/functions/piecewise.py b/src/sage/functions/piecewise.py index 2986e47960d..e12032db373 100644 --- a/src/sage/functions/piecewise.py +++ b/src/sage/functions/piecewise.py @@ -261,10 +261,7 @@ def in_operands(ex): def is_piecewise(ex): if ex.operator() is piecewise: return True - for op in ex.operands(): - if is_piecewise(op): - return True - return False + return any(is_piecewise(op) for op in ex.operands()) return is_piecewise(ex) @staticmethod diff --git a/src/sage/geometry/polyhedron/base1.py b/src/sage/geometry/polyhedron/base1.py index 40a94c1b2d7..0fcf41326c0 100644 --- a/src/sage/geometry/polyhedron/base1.py +++ b/src/sage/geometry/polyhedron/base1.py @@ -657,10 +657,7 @@ def contains(self, point): if len(p) != self.ambient_dim(): return False - for H in self.Hrep_generator(): - if not H.contains(p): - return False - return True + return all(H.contains(p) for H in self.Hrep_generator()) __contains__ = contains @@ -758,10 +755,7 @@ def interior_contains(self, point): if len(p) != self.ambient_dim(): return False - for H in self.Hrep_generator(): - if not H.interior_contains(p): - return False - return True + return all(H.interior_contains(p) for H in self.Hrep_generator()) def is_relatively_open(self): r""" @@ -878,8 +872,4 @@ def relative_interior_contains(self, point): if not eq.contains(p): return False - for ine in self.inequality_generator(): - if not ine.interior_contains(p): - return False - - return True + return all(ine.interior_contains(p) for ine in self.inequality_generator()) diff --git a/src/sage/geometry/polyhedron/face.py b/src/sage/geometry/polyhedron/face.py index 2663427c4b5..e03200cd2dd 100644 --- a/src/sage/geometry/polyhedron/face.py +++ b/src/sage/geometry/polyhedron/face.py @@ -806,10 +806,7 @@ def contains(self, point): if not self.polyhedron().contains(p): return False - for H in self.ambient_Hrepresentation(): - if H.eval(p) != 0: - return False - return True + return all(H.eval(p) == 0 for H in self.ambient_Hrepresentation()) __contains__ = contains diff --git a/src/sage/geometry/polyhedron/ppl_lattice_polytope.py b/src/sage/geometry/polyhedron/ppl_lattice_polytope.py index bd759455c65..b30bdc3e077 100644 --- a/src/sage/geometry/polyhedron/ppl_lattice_polytope.py +++ b/src/sage/geometry/polyhedron/ppl_lattice_polytope.py @@ -719,10 +719,7 @@ def contains(self, point_coordinates): """ p = C_Polyhedron(point(Linear_Expression(list(point_coordinates), 1))) is_included = Poly_Con_Relation.is_included() - for c in self.constraints(): - if not p.relation_with(c).implies(is_included): - return False - return True + return all(p.relation_with(c).implies(is_included) for c in self.constraints()) @cached_method def contains_origin(self): diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index d3f8ef77734..0ef6da74fdc 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -14206,11 +14206,7 @@ def is_regular(self, k=None): if k is None: k = next(deg_it) - for d in deg_it: - if d != k: - return False - - return True + return all(d == k for d in deg_it) # Substructures diff --git a/src/sage/graphs/isgci.py b/src/sage/graphs/isgci.py index 948ebefaad9..5efedd77616 100644 --- a/src/sage/graphs/isgci.py +++ b/src/sage/graphs/isgci.py @@ -564,7 +564,7 @@ def forbidden_subgraphs(self): return [smallgraphs[g] for g in excluded] - def __contains__(self, g): + def __contains__(self, g) -> bool: r""" Check if ``g`` belongs to the graph class represented by ``self``. @@ -603,11 +603,7 @@ def __contains__(self, g): raise NotImplementedError("No recognition algorithm is available " "for this class.") - for gg in excluded: - if g.subgraph_search(gg, induced=True): - return False - - return True + return not any(g.subgraph_search(gg, induced=True) for gg in excluded) def description(self): r""" diff --git a/src/sage/groups/abelian_gps/abelian_group.py b/src/sage/groups/abelian_gps/abelian_group.py index d19657c2e40..b8b4b594f45 100644 --- a/src/sage/groups/abelian_gps/abelian_group.py +++ b/src/sage/groups/abelian_gps/abelian_group.py @@ -607,10 +607,7 @@ def is_subgroup(left, right): sage: H < G False """ - for l in left.gens(): - if l not in right: - return False - return True + return all(l in right for l in left.gens()) __le__ = is_subgroup diff --git a/src/sage/manifolds/differentiable/degenerate_submanifold.py b/src/sage/manifolds/differentiable/degenerate_submanifold.py index fcb843a8abe..b960398cfd2 100644 --- a/src/sage/manifolds/differentiable/degenerate_submanifold.py +++ b/src/sage/manifolds/differentiable/degenerate_submanifold.py @@ -1394,10 +1394,7 @@ def is_tangent(self, v): for u in rad: if not g.along(im)(u.along(im),v).is_zero(): return False - for u in normal: - if not g.along(im)(u.along(im),v).is_zero(): - return False - return True + return all(g.along(im)(u.along(im), v).is_zero() for u in normal) #************************************************************************************** diff --git a/src/sage/manifolds/differentiable/vector_bundle.py b/src/sage/manifolds/differentiable/vector_bundle.py index cb28d8075da..407aaddd060 100644 --- a/src/sage/manifolds/differentiable/vector_bundle.py +++ b/src/sage/manifolds/differentiable/vector_bundle.py @@ -1305,10 +1305,7 @@ def is_manifestly_trivial(self): return True # Otherwise check whether a global frame on the pullback bundle is # defined: - for frame in self.frames(): - if frame._domain is self._base_space: - return True - return False + return any(frame._domain is self._base_space for frame in self.frames()) def local_frame(self, *args, **kwargs): r""" diff --git a/src/sage/modular/arithgroup/congroup_gammaH.py b/src/sage/modular/arithgroup/congroup_gammaH.py index 76887f2c798..26dade4ce23 100644 --- a/src/sage/modular/arithgroup/congroup_gammaH.py +++ b/src/sage/modular/arithgroup/congroup_gammaH.py @@ -1040,10 +1040,7 @@ def is_subgroup(self, other) -> bool: else: # difficult case t = other._list_of_elements_in_H() - for x in self._generators_for_H(): - if x not in t: - return False - return True + return all(x in t for x in self._generators_for_H()) def index(self): r""" diff --git a/src/sage/modular/btquotients/btquotient.py b/src/sage/modular/btquotients/btquotient.py index 445d32ec3a3..2bea75fba3a 100644 --- a/src/sage/modular/btquotients/btquotient.py +++ b/src/sage/modular/btquotients/btquotient.py @@ -2144,10 +2144,7 @@ def is_admissible(self, D) -> bool: for f in self.level().factor(): if kronecker_symbol(disc, f[0]) != -1: return False - for f in self._Nplus.factor(): - if kronecker_symbol(disc, f[0]) != 1: - return False - return True + return all(kronecker_symbol(disc, f[0]) == 1 for f in self._Nplus.factor()) def _local_splitting_map(self, prec): r""" diff --git a/src/sage/modular/modform/space.py b/src/sage/modular/modform/space.py index cbe5d498b57..36765b7427f 100644 --- a/src/sage/modular/modform/space.py +++ b/src/sage/modular/modform/space.py @@ -1853,7 +1853,4 @@ def contains_each(V, B): sage: contains_each( range(20), range(30) ) False """ - for b in B: - if b not in V: - return False - return True + return all(b in V for b in B) diff --git a/src/sage/modular/modform_hecketriangle/hecke_triangle_groups.py b/src/sage/modular/modform_hecketriangle/hecke_triangle_groups.py index 0b28530eb18..dcaa4e7f955 100644 --- a/src/sage/modular/modform_hecketriangle/hecke_triangle_groups.py +++ b/src/sage/modular/modform_hecketriangle/hecke_triangle_groups.py @@ -1004,10 +1004,7 @@ def is_cycle(seq) -> bool: return False def is_cycle_of_length(seq, n) -> bool: - for j in range(n, len(seq)): - if seq[j] != seq[j % n]: - return False - return True + return all(seq[j] == seq[j % n] for j in range(n, len(seq))) j_list = range(1, self.n()) diff --git a/src/sage/quadratic_forms/genera/genus.py b/src/sage/quadratic_forms/genera/genus.py index e4bc9b0d80c..e0e12bfe7b1 100644 --- a/src/sage/quadratic_forms/genera/genus.py +++ b/src/sage/quadratic_forms/genera/genus.py @@ -2489,10 +2489,7 @@ def __eq__(self, other) -> bool: t = len(self._local_symbols) if t != len(other._local_symbols): return False - for i in range(t): - if self._local_symbols[i] != other._local_symbols[i]: - return False - return True + return all(self._local_symbols[i] == other._local_symbols[i] for i in range(t)) def __ne__(self, other) -> bool: r""" diff --git a/src/sage/quivers/representation.py b/src/sage/quivers/representation.py index 416ae5c1a56..d27f55aabaf 100644 --- a/src/sage/quivers/representation.py +++ b/src/sage/quivers/representation.py @@ -1072,11 +1072,7 @@ def __eq__(self, other): return False # Return False if the elements differ at any vertex - for v in self._quiver: - if self._elems[v] != other._elems[v]: - return False - - return True + return all(self._elems[v] == other._elems[v] for v in self._quiver) def __ne__(self, other): """ @@ -1103,11 +1099,7 @@ def __ne__(self, other): return True # Return True if the elements differ at any vertex - for v in self._quiver: - if self._elems[v] != other._elems[v]: - return True - - return False + return any(self._elems[v] != other._elems[v] for v in self._quiver) ########################################################################### # # @@ -1224,11 +1216,7 @@ def is_zero(self) -> bool: sage: M.zero().is_zero() True """ - for v in self._quiver: - if not self._elems[v].is_zero(): - return False - - return True + return all(self._elems[v].is_zero() for v in self._quiver) def support(self): """ @@ -1831,10 +1819,7 @@ def is_semisimple(self) -> bool: """ # A quiver representation is semisimple if and only if the zero map is # assigned to each edge. - for x in self._semigroup._sorted_edges: - if not self._maps[x].is_zero(): - return False - return True + return all(self._maps[x].is_zero() for x in self._semigroup._sorted_edges) def an_element(self): """ diff --git a/src/sage/rings/derivation.py b/src/sage/rings/derivation.py index 24c9ac92dd7..50a65364f0e 100644 --- a/src/sage/rings/derivation.py +++ b/src/sage/rings/derivation.py @@ -495,10 +495,7 @@ def _coerce_map_from_(self, R): morS = self._defining_morphism try: # this test is not perfect - for g in self._domain.gens(): - if morR(g) != morS(g): - return False - return True + return all(morR(g) == morS(g) for g in self._domain.gens()) except (AttributeError, NotImplementedError): pass return super()._coerce_map_from_(R) @@ -1044,10 +1041,7 @@ def is_zero(self): sage: (f-f).is_zero() True """ - for c in self.list(): - if not c.is_zero(): - return False - return True + return all(c.is_zero() for c in self.list()) def _richcmp_(self, other, op): """ diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py index 2d3ac20b9eb..2bbff8c6e8f 100644 --- a/src/sage/rings/ideal.py +++ b/src/sage/rings/ideal.py @@ -444,10 +444,7 @@ def __bool__(self): sage: bool(I) False """ - for g in self.gens(): - if not g.is_zero(): - return True - return False + return any(not g.is_zero() for g in self.gens()) def base_ring(self): r""" diff --git a/src/sage/rings/polynomial/laurent_polynomial_ring_base.py b/src/sage/rings/polynomial/laurent_polynomial_ring_base.py index d9984a656b1..5e4ba93da24 100644 --- a/src/sage/rings/polynomial/laurent_polynomial_ring_base.py +++ b/src/sage/rings/polynomial/laurent_polynomial_ring_base.py @@ -412,11 +412,7 @@ def _is_valid_homomorphism_(self, codomain, im_gens, base_map=None): # we need that elements of the base ring # canonically coerce into codomain. return False - for a in im_gens: - # in addition, the image of each generator must be invertible. - if not a.is_unit(): - return False - return True + return all(a.is_unit() for a in im_gens) def term_order(self): """ diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py index 1e52b986d8a..8571e82993e 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ideal.py +++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py @@ -5087,10 +5087,7 @@ def is_homogeneous(self): sage: J.is_homogeneous() True """ - for f in self.gens(): - if not f.is_homogeneous(): - return False - return True + return all(f.is_homogeneous() for f in self.gens()) def degree_of_semi_regularity(self): r""" diff --git a/src/sage/rings/tate_algebra.py b/src/sage/rings/tate_algebra.py index 43223432650..5043178f1f4 100644 --- a/src/sage/rings/tate_algebra.py +++ b/src/sage/rings/tate_algebra.py @@ -810,10 +810,7 @@ def _coerce_map_from_(self, R): and self._names == R.variable_names() and self._order == R.term_order()): ratio = base.absolute_e() // Rbase.absolute_e() - for i in range(self._ngens) : - if logs[i] != ratio * Rlogs[i]: - return False - return True + return all(logs[i] == ratio * Rlogs[i] for i in range(self._ngens)) return False def _pushout_(self, R): diff --git a/src/sage/sandpiles/sandpile.py b/src/sage/sandpiles/sandpile.py index 6d685bcd6b7..39538152675 100644 --- a/src/sage/sandpiles/sandpile.py +++ b/src/sage/sandpiles/sandpile.py @@ -3732,10 +3732,7 @@ def is_stable(self): sage: (S.max_stable() & S.max_stable()).is_stable() True """ - for v in self._vertices: - if self[v] >= self._sandpile.out_degree(v): - return False - return True + return all(self[v] < self._sandpile.out_degree(v) for v in self._vertices) def _set_equivalent_recurrent(self): r""" diff --git a/src/sage/schemes/elliptic_curves/heegner.py b/src/sage/schemes/elliptic_curves/heegner.py index c7aa3b8ff22..63b58706a04 100644 --- a/src/sage/schemes/elliptic_curves/heegner.py +++ b/src/sage/schemes/elliptic_curves/heegner.py @@ -1149,10 +1149,7 @@ def is_kolyvagin(self): return False if not c.is_squarefree(): return False - for p in c.prime_divisors(): - if not is_inert(D,p): - return False - return True + return all(is_inert(D, p) for p in c.prime_divisors()) def _base_is_hilbert_class_field(self): """ @@ -7311,10 +7308,7 @@ def satisfies_heegner_hypothesis(self, D): return False if D.gcd(self.conductor()) != 1: return False - for p, _ in self.conductor().factor(): - if D.kronecker(p) != 1: - return False - return True + return all(D.kronecker(p) == 1 for p, _ in self.conductor().factor()) ##################################################################### diff --git a/src/sage/sets/finite_set_maps.py b/src/sage/sets/finite_set_maps.py index 290e32d5e3c..23269672196 100644 --- a/src/sage/sets/finite_set_maps.py +++ b/src/sage/sets/finite_set_maps.py @@ -284,10 +284,7 @@ def __contains__(self, x): x = list(x) if len(x) != self._m: return False - for i in x: - if not (0 <= i < self._n): - return False - return True + return all(0 <= i < self._n for i in x) def an_element(self): """ diff --git a/src/sage/sets/real_set.py b/src/sage/sets/real_set.py index d502dbc4a4a..a8ead177946 100644 --- a/src/sage/sets/real_set.py +++ b/src/sage/sets/real_set.py @@ -2328,10 +2328,7 @@ def contains(self, x): False """ x = RLF(x) - for interval in self._intervals: - if interval.contains(x): - return True - return False + return any(interval.contains(x) for interval in self._intervals) __contains__ = contains diff --git a/src/sage/tensor/modules/comp.py b/src/sage/tensor/modules/comp.py index 8fc33684346..98f9ff82d38 100644 --- a/src/sage/tensor/modules/comp.py +++ b/src/sage/tensor/modules/comp.py @@ -1404,10 +1404,7 @@ def is_zero(self): # any zero value # In other words, the full method should be # return self.comp == {} - for val in self._comp.values(): - if not (val == 0): - return False - return True + return all(val == 0 for val in self._comp.values()) def __eq__(self, other): r""" diff --git a/src/sage/topology/simplicial_complex_morphism.py b/src/sage/topology/simplicial_complex_morphism.py index 52a2d6e82b4..3f2263adce6 100644 --- a/src/sage/topology/simplicial_complex_morphism.py +++ b/src/sage/topology/simplicial_complex_morphism.py @@ -550,10 +550,7 @@ def is_injective(self): True """ v = [self._vertex_dictionary[i[0]] for i in self.domain().faces()[0]] - for i in v: - if v.count(i) > 1: - return False - return True + return all(v.count(i) <= 1 for i in v) def is_identity(self) -> bool: """