diff --git a/src/sage/algebras/quatalg/quaternion_algebra.py b/src/sage/algebras/quatalg/quaternion_algebra.py index ee939ec06f2..dd77f9b04c7 100644 --- a/src/sage/algebras/quatalg/quaternion_algebra.py +++ b/src/sage/algebras/quatalg/quaternion_algebra.py @@ -955,9 +955,10 @@ def maximal_order(self, take_shortcuts=True, order_basis=None): Order of Quaternion Algebra (-22, 210) with base ring Rational Field with basis (1, i, 1/2*i + 1/2*j, 1/2 + 17/22*i + 1/44*k) - sage: for d in ( m for m in range(1, 750) if is_squarefree(m) ): # long time (3s) - ....: A = QuaternionAlgebra(d) - ....: assert A.maximal_order(take_shortcuts=False).is_maximal() + sage: Q = QuaternionAlgebra + sage: all(Q(d).maximal_order(take_shortcuts=False).is_maximal() + ....: for d in range(1, 350) if is_squarefree(d)) + True Specifying an order basis gives an extension of orders:: diff --git a/src/sage/categories/finite_semigroups.py b/src/sage/categories/finite_semigroups.py index 831da9308bc..ee723aef28d 100644 --- a/src/sage/categories/finite_semigroups.py +++ b/src/sage/categories/finite_semigroups.py @@ -95,7 +95,7 @@ def j_classes(self): return self.cayley_graph(side='twosided', simple=True).strongly_connected_components() @cached_method - def j_classes_of_idempotents(self): + def j_classes_of_idempotents(self) -> list[list]: r""" Return all the idempotents of self, grouped by J-class. @@ -108,7 +108,9 @@ def j_classes_of_idempotents(self): [['a'], ['ab', 'ba'], ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'], ['ac', 'ca'], ['b'], ['bc', 'cb'], ['c']] """ - return [l for l in ([x for x in cl if attrcall('is_idempotent')(x)] for cl in self.j_classes()) if len(l) > 0] + it = ([x for x in cl if attrcall('is_idempotent')(x)] + for cl in self.j_classes()) + return [ell for ell in it if ell] @cached_method def j_transversal_of_idempotents(self): diff --git a/src/sage/combinat/partition.py b/src/sage/combinat/partition.py index beb6f3d1760..51ec8a760a5 100644 --- a/src/sage/combinat/partition.py +++ b/src/sage/combinat/partition.py @@ -2043,7 +2043,7 @@ def cell_poset(self, orientation='SE'): covers[(i, j)] = [(i, j - 1)] return Poset(covers) - def frobenius_coordinates(self): + def frobenius_coordinates(self) -> tuple[list, list]: """ Return a pair of sequences of Frobenius coordinates aka beta numbers of the partition. @@ -2065,11 +2065,11 @@ def frobenius_coordinates(self): mu = self muconj = mu.conjugate() # Naive implementation if len(mu) <= len(muconj): - a = [x for x in (val-i-1 for i, val in enumerate(mu)) if x >= 0] - b = [x for x in (muconj[i]-i-1 for i in range(len(a))) if x >= 0] + a = [x for i, val in enumerate(mu) if (x := val - i - 1) >= 0] + b = [x for i in range(len(a)) if (x := muconj[i] - i - 1) >= 0] else: - b = [x for x in (val-i-1 for i, val in enumerate(muconj)) if x >= 0] - a = [x for x in (mu[i]-i-1 for i in range(len(b))) if x >= 0] + b = [x for i, val in enumerate(muconj) if (x := val - i - 1) >= 0] + a = [x for i in range(len(b)) if (x := mu[i] - i - 1) >= 0] return (a, b) def frobenius_rank(self): diff --git a/src/sage/graphs/generators/smallgraphs.py b/src/sage/graphs/generators/smallgraphs.py index 63ccb5188f4..55e2d493bf9 100644 --- a/src/sage/graphs/generators/smallgraphs.py +++ b/src/sage/graphs/generators/smallgraphs.py @@ -5473,8 +5473,9 @@ def JankoKharaghaniTonchevGraph(): 301, 304, 308, 309, 310, 312, 313, 314, 316, 317, 318) Gamma = Graph(multiedges=False, name='Janko-Kharaghani-Tonchev') for i, b in ((1, B1), (163, B163)): - for j in (x[0] for x in st.OrbitsDomain(b)): - Gamma.add_edges(map(tuple, G.Orbit(libgap.Set([i, j]), libgap.OnSets))) + for x in st.OrbitsDomain(b): + Gamma.add_edges(map(tuple, G.Orbit(libgap.Set([i, x[0]]), + libgap.OnSets))) Gamma.relabel(range(Gamma.order())) return Gamma diff --git a/src/sage/graphs/orientations.py b/src/sage/graphs/orientations.py index 085bb7202cf..3a1da1fcbf8 100644 --- a/src/sage/graphs/orientations.py +++ b/src/sage/graphs/orientations.py @@ -1361,7 +1361,7 @@ def bounded_outdegree_orientation(G, bound, solver=None, verbose=False, d.add_edges(('s', vertices_id[v], b[v]) for v in vertices) d.add_edges(((vertices_id[u], vertices_id[v]), 't', 1) - for u, v in G.edges(sort=False, labels=None)) + for u, v in G.edges(sort=False, labels=None)) # each v is linked to its incident edges @@ -1381,7 +1381,7 @@ def bounded_outdegree_orientation(G, bound, solver=None, verbose=False, # The flow graph may not contain all the vertices, if they are # not part of the flow... edges = ((vertices[u], vertices[vv if vv != u else uu]) - for u in (x for x in range(n) if x in flow) + for u in range(n) if u in flow for uu, vv in flow.neighbors_out(u)) return _initialize_digraph(G, edges)