diff --git a/src/sage/combinat/crystals/tensor_product.py b/src/sage/combinat/crystals/tensor_product.py index c194a2448ae..c96249b9e55 100644 --- a/src/sage/combinat/crystals/tensor_product.py +++ b/src/sage/combinat/crystals/tensor_product.py @@ -965,8 +965,9 @@ def __classcall_private__(cls, cartan_type, shapes=None, shape=None): raise ValueError("shapes should all be partitions") S = CrystalOfSpins(cartan_type) B = CrystalOfTableaux(cartan_type, shapes=shapes) - T = TensorProductOfCrystals(S, B, generators=[[S.module_generators[0],x] for x in B.module_generators]) - T.rename("The crystal of tableaux of type %s and shape(s) %s" % (cartan_type, list(list(shape) for shape in spin_shapes))) + T = TensorProductOfCrystals(S, B, generators=[[S.module_generators[0], x] for x in B.module_generators]) + T.rename("The crystal of tableaux of type %s and shape(s) %s" % + (cartan_type, [list(shape) for shape in spin_shapes])) T.shapes = spin_shapes return T @@ -987,13 +988,14 @@ def __init__(self, cartan_type, shapes): sage: T = crystals.Tableaux(['A',3], shape = [2,2]) sage: TestSuite(T).run() """ -# super().__init__(category = FiniteEnumeratedSets()) + # super().__init__(category = FiniteEnumeratedSets()) Parent.__init__(self, category=ClassicalCrystals()) self.letters = CrystalOfLetters(cartan_type) self.shapes = shapes - self.module_generators = tuple(self.module_generator(la) for la in shapes) + self.module_generators = tuple(self.module_generator(la) + for la in shapes) self.rename("The crystal of tableaux of type %s and shape(s) %s" - % (cartan_type, list(list(shape) for shape in shapes))) + % (cartan_type, [list(shape) for shape in shapes])) def cartan_type(self): """ diff --git a/src/sage/combinat/recognizable_series.py b/src/sage/combinat/recognizable_series.py index 38357976985..bf42b22c869 100644 --- a/src/sage/combinat/recognizable_series.py +++ b/src/sage/combinat/recognizable_series.py @@ -1842,8 +1842,8 @@ def _an_element_(self): z = self.coefficient_ring().zero() o = self.coefficient_ring().one() e = self.coefficient_ring().an_element() - return self(list(Matrix([[o, z], [i * o, o]]) - for i, _ in enumerate(self.alphabet())), + return self([Matrix([[o, z], [i * o, o]]) + for i, _ in enumerate(self.alphabet())], vector([z, e]), right=vector([e, z])) def some_elements(self, **kwds): diff --git a/src/sage/combinat/regular_sequence.py b/src/sage/combinat/regular_sequence.py index 6a98b9e6712..b77a69cbce7 100644 --- a/src/sage/combinat/regular_sequence.py +++ b/src/sage/combinat/regular_sequence.py @@ -1100,10 +1100,10 @@ def linear_representation_morphism_recurrence_order_1(C, D): Z = zero_matrix(C[0].dimensions()[0]) def blocks(r): - upper = list([C[s], D[s], Z] - for s in reversed(srange(max(0, r-2), r+1))) - lower = list([Z, C[s], D[s]] - for s in reversed(srange(k-3+len(upper), k))) + upper = [[C[s], D[s], Z] + for s in reversed(srange(max(0, r-2), r+1))] + lower = [[Z, C[s], D[s]] + for s in reversed(srange(k-3+len(upper), k))] return upper + lower return {r: Matrix.block(blocks(r)) for r in P.alphabet()} diff --git a/src/sage/combinat/regular_sequence_bounded.py b/src/sage/combinat/regular_sequence_bounded.py index 53b2d500a96..ea63ed8a35e 100644 --- a/src/sage/combinat/regular_sequence_bounded.py +++ b/src/sage/combinat/regular_sequence_bounded.py @@ -392,12 +392,11 @@ def make_positive(matrices) -> list: def do(mat): if is_non_negative(mat): return mat - elif is_non_negative(-mat): + if is_non_negative(-mat): return -mat - else: - raise ValueError('There is a matrix which is neither non-negative nor non-positive.') + raise ValueError('There is a matrix which is neither non-negative nor non-positive.') - return list(do(mat) for mat in matrices) + return [do(mat) for mat in matrices] def regular_sequence_is_bounded(S): @@ -521,8 +520,8 @@ def regular_sequence_is_bounded(S): if not has_bounded_matrix_powers(matrices): return False - matricesProd = list(ell * em for ell in matrices for em in matrices - if ell != em) + matricesProd = [ell * em for ell in matrices for em in matrices + if ell != em] if not has_bounded_matrix_powers(matricesProd): return False diff --git a/src/sage/combinat/skew_tableau.py b/src/sage/combinat/skew_tableau.py index 1e0dad9d4ef..f58673d39bc 100644 --- a/src/sage/combinat/skew_tableau.py +++ b/src/sage/combinat/skew_tableau.py @@ -175,8 +175,7 @@ def __eq__(self, other): """ if isinstance(other, (Tableau, SkewTableau)): return list(self) == list(other) - else: - return list(self) == other or list(list(row) for row in self) == other + return list(self) == other or [list(row) for row in self] == other def __ne__(self, other): r""" diff --git a/src/sage/env.py b/src/sage/env.py index c2a1f7e562d..57b7371dd6a 100644 --- a/src/sage/env.py +++ b/src/sage/env.py @@ -519,6 +519,6 @@ def sage_data_paths(name: str = '') -> set[str]: for path in site_data_dir("sagemath", multipath=True).split(os.pathsep) + site_data_dir(multipath=True).split(os.pathsep): paths.add(path) else: - paths = {path for path in SAGE_DATA_PATH.split(os.pathsep)} + paths = set(SAGE_DATA_PATH.split(os.pathsep)) return {os.path.join(path, name) for path in paths if os.path.exists(path)} diff --git a/src/sage/geometry/polyhedron/base5.py b/src/sage/geometry/polyhedron/base5.py index 47162d05c75..aaf8ad5d863 100644 --- a/src/sage/geometry/polyhedron/base5.py +++ b/src/sage/geometry/polyhedron/base5.py @@ -1907,11 +1907,11 @@ def linear_transformation(self, linear_transf, new_lines = () if self.is_compact() and self.n_vertices() and self.n_inequalities(): - homogeneous_basis = matrix(R, ( [1] + list(v) for v in self.an_affine_basis() )).transpose() + homogeneous_basis = matrix(R, ([1] + list(v) for v in self.an_affine_basis())).transpose() # To convert first to a list and then to a matrix seems to be necessary to obtain a meaningful error, # in case the number of columns doesn't match the dimension. - new_homogeneous_basis = matrix(list( [1] + list(linear_transf*vector(R, v)) for v in self.an_affine_basis()) ).transpose() + new_homogeneous_basis = matrix([[1] + list(linear_transf*vector(R, v)) for v in self.an_affine_basis()]).transpose() if self.dim() + 1 == new_homogeneous_basis.rank(): # The transformation is injective on the polytope. diff --git a/src/sage/geometry/polyhedron/generating_function.py b/src/sage/geometry/polyhedron/generating_function.py index c4bece2af55..ad630611ebb 100644 --- a/src/sage/geometry/polyhedron/generating_function.py +++ b/src/sage/geometry/polyhedron/generating_function.py @@ -684,7 +684,7 @@ def key(t): return (-sum(abs(d) for d in D), D) terms = sorted(terms, key=key, reverse=True) return Factorization([(numerator, 1)] + - list((1-t, -1) for t in terms), + [(1 - t, -1) for t in terms], sort=Factorization_sort, simplify=Factorization_simplify) @@ -1178,8 +1178,8 @@ def _transform_(self): inequalities_extra.append(tuple(coeffs)) T = matrix(ZZ, dim, dim, D) - self.inequalities = (list(tuple(T*vector(ieq)) - for ieq in inequalities_filtered) + self.inequalities = ([tuple(T * vector(ieq)) + for ieq in inequalities_filtered] + inequalities_extra) rules_pre = ((y, B({tuple(row[1:]): 1})) @@ -1465,8 +1465,8 @@ def _transform_(self): self.factor = next(rules_pre)[1] self.rules = dict(rules_pre) - self.inequalities = list(tuple(vector(e)*T) for e in self.inequalities) - self.equations = list(tuple(vector(e)*T) for e in self.equations) + self.inequalities = [tuple(vector(e) * T) for e in self.inequalities] + self.equations = [tuple(vector(e) * T) for e in self.equations] @staticmethod def generate_mods(equations): diff --git a/src/sage/geometry/toric_plotter.py b/src/sage/geometry/toric_plotter.py index 26c688bb3e6..39792db3174 100644 --- a/src/sage/geometry/toric_plotter.py +++ b/src/sage/geometry/toric_plotter.py @@ -833,9 +833,9 @@ def label_list(label, n, math_mode, index_set=None): index_set = range(n) if math_mode: label = label.strip("$") - return list("$%s_{%d}$" % (label, i) for i in index_set) + return ["$%s_{%d}$" % (label, i) for i in index_set] else: - return list("%s_%d" % (label, i) for i in index_set) + return ["%s_%d" % (label, i) for i in index_set] def options(option=None, **kwds): diff --git a/src/sage/graphs/generators/families.py b/src/sage/graphs/generators/families.py index 28db9a6c1ef..9e59c940e04 100644 --- a/src/sage/graphs/generators/families.py +++ b/src/sage/graphs/generators/families.py @@ -3131,7 +3131,7 @@ def next_step(triangle_list): resu += [(a, ab, ac), (ab, b, bc), (ac, bc, c)] return resu - tri_list = [list(vector(QQ, u) for u in [(0, 0), (0, 1), (1, 0)])] + tri_list = [[vector(QQ, u) for u in [(0, 0), (0, 1), (1, 0)]]] for k in range(n - 1): tri_list = next_step(tri_list) dg = Graph() diff --git a/src/sage/graphs/generators/generators_test.py b/src/sage/graphs/generators/generators_test.py index 5b57f1cd459..19160c32e54 100644 --- a/src/sage/graphs/generators/generators_test.py +++ b/src/sage/graphs/generators/generators_test.py @@ -11,7 +11,7 @@ def test_shortened_000_111_extended_binary_Golay_code_graph(): from sage.coding import codes_catalog from sage.coding.linear_code import LinearCode from sage.graphs.generators.distance_regular import ( - shortened_000_111_extended_binary_Golay_code_graph + shortened_000_111_extended_binary_Golay_code_graph ) from sage.matrix.constructor import matrix from sage.rings.finite_rings.finite_field_constructor import FiniteField @@ -23,7 +23,7 @@ def test_shortened_000_111_extended_binary_Golay_code_graph(): v = C_basis[0] + C_basis[1] + C_basis[2] # v has 111 at the start C_basis = C_basis[3:] C_basis.append(v) - C_basis = list(map(lambda x: x[3:], C_basis)) + C_basis = [x[3:] for x in C_basis] code = LinearCode(matrix(FiniteField(2), C_basis)) G = code.cosetGraph() diff --git a/src/sage/interfaces/maxima_lib.py b/src/sage/interfaces/maxima_lib.py index 169b964b72f..1b1172f0afc 100644 --- a/src/sage/interfaces/maxima_lib.py +++ b/src/sage/interfaces/maxima_lib.py @@ -1640,7 +1640,8 @@ def sr_to_max(expr): elif (op in special_sage_to_max): return EclObject(special_sage_to_max[op](*[sr_to_max(o) for o in expr.operands()])) elif op == tuple: - return EclObject(([mlist], list(sr_to_max(op) for op in expr.operands()))) + return EclObject(([mlist], + [sr_to_max(op) for op in expr.operands()])) elif op not in sage_op_dict: # Maxima does some simplifications automatically by default # so calling maxima(expr) can change the structure of expr diff --git a/src/sage/interfaces/regina.py b/src/sage/interfaces/regina.py index 6a1250a3353..52eb670be8f 100644 --- a/src/sage/interfaces/regina.py +++ b/src/sage/interfaces/regina.py @@ -259,7 +259,7 @@ def _start(self): for e in AlgorithmExt: d[e.name] = e # set up the globals - D = {k: v for k, v in d.items()} + D = dict(d) D[self._namespace.__name__] = self._namespace D[self.name()] = regina self._regina_globals = D diff --git a/src/sage/knots/link.py b/src/sage/knots/link.py index 81b6c75c49c..2e4cd0ed446 100644 --- a/src/sage/knots/link.py +++ b/src/sage/knots/link.py @@ -1256,7 +1256,7 @@ def _khovanov_homology_cached(self, height, implementation, ring=ZZ, **kwds): if not data: return [(0, HomologyGroup(0, ring))] - torsion = set([k[1] for k in data]) + torsion = {k[1] for k in data} invfac = {} for d in [k[0] for k in data]: invfac[d] = []