From b6af6e7aa20b4d8119772af0fe88001ef3548cc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 13 Feb 2023 21:33:08 +0100 Subject: [PATCH] fixing most of pycodestyle E271 --- src/sage/algebras/fusion_rings/f_matrix.py | 4 +--- src/sage/categories/function_fields.py | 2 +- src/sage/coding/information_set_decoder.py | 10 ++++----- src/sage/combinat/matrices/hadamard_matrix.py | 4 ++-- src/sage/combinat/t_sequences.py | 2 +- src/sage/crypto/mq/sr.py | 4 ++-- src/sage/databases/knotinfo_db.py | 6 ++--- src/sage/games/quantumino.py | 4 ++-- src/sage/geometry/cone.py | 5 ++--- .../hyperbolic_space/hyperbolic_isometry.py | 2 +- src/sage/geometry/lattice_polytope.py | 4 ++-- src/sage/geometry/polyhedron/base5.py | 22 +++++++++++-------- src/sage/geometry/ribbon_graph.py | 12 +++++----- .../parametrized_surface3d.py | 14 +++++------- src/sage/graphs/generic_graph.py | 4 ++-- src/sage/groups/cubic_braid.py | 17 ++++++-------- src/sage/groups/perm_gps/cubegroup.py | 16 +++++++------- src/sage/interacts/library.py | 2 +- src/sage/interfaces/maxima_abstract.py | 18 +++++++-------- src/sage/interfaces/tides.py | 7 +----- src/sage/knots/knotinfo.py | 18 +++++++-------- src/sage/knots/link.py | 12 +++++----- .../differentiable/affine_connection.py | 6 ++--- .../manifolds/differentiable/vectorfield.py | 4 ++-- src/sage/modular/hecke/hecke_operator.py | 11 ++++------ src/sage/modular/overconvergent/all.py | 2 +- src/sage/modules/free_module.py | 2 +- .../numerical/interactive_simplex_method.py | 2 +- src/sage/quadratic_forms/genera/genus.py | 4 ++-- .../quadratic_form__ternary_Tornaria.py | 5 ++--- src/sage/sets/non_negative_integers.py | 2 +- src/sage/symbolic/units.py | 2 +- .../tensor/modules/tensor_with_indices.py | 7 +++--- 33 files changed, 110 insertions(+), 126 deletions(-) diff --git a/src/sage/algebras/fusion_rings/f_matrix.py b/src/sage/algebras/fusion_rings/f_matrix.py index 82b5d764fa6..734d9cffa24 100644 --- a/src/sage/algebras/fusion_rings/f_matrix.py +++ b/src/sage/algebras/fusion_rings/f_matrix.py @@ -10,12 +10,10 @@ # Distributed under the terms of the GNU General Public License (GPL) # https://www.gnu.org/licenses/ # **************************************************************************** - - from copy import deepcopy from ctypes import cast, py_object from itertools import product, zip_longest -from multiprocessing import Pool, cpu_count, set_start_method, shared_memory +from multiprocessing import Pool, cpu_count, set_start_method, shared_memory import numpy as np from os import getpid, remove import pickle diff --git a/src/sage/categories/function_fields.py b/src/sage/categories/function_fields.py index 6c30067e53f..4536973233d 100644 --- a/src/sage/categories/function_fields.py +++ b/src/sage/categories/function_fields.py @@ -65,7 +65,7 @@ def _call_(self, x): try: return x.function_field() except AttributeError: - raise TypeError("unable to canonically associate a function field to %s"%x) + raise TypeError("unable to canonically associate a function field to %s" % x) class ParentMethods: pass diff --git a/src/sage/coding/information_set_decoder.py b/src/sage/coding/information_set_decoder.py index a2cbf94fc5e..85ac6923849 100644 --- a/src/sage/coding/information_set_decoder.py +++ b/src/sage/coding/information_set_decoder.py @@ -475,16 +475,16 @@ def decode(self, r): # I was not an information set continue Gt = Gi_inv * G - #step 2. + # step 2. y = r - vector([r[i] for i in I]) * Gt g = Gt.rows() - #step 3. - for pi in range(p+1): + # step 3. + for pi in range(p + 1): for A in itertools.combinations(range(k), pi): for m in itertools.product(Fstar, repeat=pi): - e = y - sum(m[i]*g[A[i]] for i in range(pi)) + e = y - sum(m[i] * g[A[i]] for i in range(pi)) errs = e.hamming_weight() - if errs >= tau[0] and errs <= tau[1]: + if tau[0] <= errs <= tau[1]: return r - e def calibrate(self): diff --git a/src/sage/combinat/matrices/hadamard_matrix.py b/src/sage/combinat/matrices/hadamard_matrix.py index 91f73d29101..3f97f532113 100644 --- a/src/sage/combinat/matrices/hadamard_matrix.py +++ b/src/sage/combinat/matrices/hadamard_matrix.py @@ -389,9 +389,9 @@ def williamson_hadamard_matrix_smallcases(n, existence=False, check=True): ... ValueError: The Williamson type Hadamard matrix of order 100 is not yet implemented. """ - assert n%4 == 0 + assert n % 4 == 0 - if not williamson_type_quadruples_smallcases(n//4, existence=True): + if not williamson_type_quadruples_smallcases(n // 4, existence=True): if existence: return False raise ValueError("The Williamson type Hadamard matrix of order %s is not yet implemented." % n) diff --git a/src/sage/combinat/t_sequences.py b/src/sage/combinat/t_sequences.py index 883d55c87bd..b86b8a1ef27 100644 --- a/src/sage/combinat/t_sequences.py +++ b/src/sage/combinat/t_sequences.py @@ -44,7 +44,7 @@ from sage.structure.sequence import Sequence -def _nonperiodic_autocorrelation(sequences, j): +def _nonperiodic_autocorrelation(sequences, j): r""" Compute the nonperiodic autocorrelation of a familiy of sequences. diff --git a/src/sage/crypto/mq/sr.py b/src/sage/crypto/mq/sr.py index 81ae146e204..0860c58ebaa 100644 --- a/src/sage/crypto/mq/sr.py +++ b/src/sage/crypto/mq/sr.py @@ -876,11 +876,11 @@ def sbox(self, inversion_only=False): if not inversion_only: with AllowZeroInversionsContext(self): S = [self.sub_byte(elem) for elem in sorted(k)] - return SBox(S) + return SBox(S) else: e = self.e S = [elem ** (2**e - 2) for elem in sorted(k)] - return SBox(S) + return SBox(S) def shift_rows(self, d): r""" diff --git a/src/sage/databases/knotinfo_db.py b/src/sage/databases/knotinfo_db.py index d70e6be6bac..29786ee56b2 100644 --- a/src/sage/databases/knotinfo_db.py +++ b/src/sage/databases/knotinfo_db.py @@ -596,10 +596,10 @@ def _create_data_sobj(self, sobj_path=None): for col in cols: val_list = [] - if col.column_type() != col.types.OnlyLinks: - for i in range(1 , len_knots): + if col.column_type() != col.types.OnlyLinks: + for i in range(1, len_knots): if col.name == self._names_column: - row_dict[self._knot_prefix + knot_list[i][col.name]] = [i - 1 , 1] + row_dict[self._knot_prefix + knot_list[i][col.name]] = [i - 1, 1] val_list.append(knot_list[i][col.name]) diff --git a/src/sage/games/quantumino.py b/src/sage/games/quantumino.py index dd52254bef7..98332762613 100644 --- a/src/sage/games/quantumino.py +++ b/src/sage/games/quantumino.py @@ -413,7 +413,7 @@ class QuantuminoSolver(SageObject): Quantumino solver for the box (5, 4, 4) Aside pentamino number: 12 """ - def __init__(self, aside, box=(5,8,2)): + def __init__(self, aside, box=(5, 8, 2)): r""" Constructor. @@ -424,7 +424,7 @@ def __init__(self, aside, box=(5,8,2)): Quantumino solver for the box (5, 8, 2) Aside pentamino number: 9 """ - if not 0 <= aside < 17: + if not(0 <= aside < 17): raise ValueError("aside (=%s) must be between 0 and 16" % aside) self._aside = aside self._box = box diff --git a/src/sage/geometry/cone.py b/src/sage/geometry/cone.py index 3d9cb0766fc..cf74a7ecac6 100644 --- a/src/sage/geometry/cone.py +++ b/src/sage/geometry/cone.py @@ -6639,7 +6639,7 @@ def random_cone(lattice=None, min_ambient_dim=0, max_ambient_dim=None, msg = 'all cones are solid when max_ambient_dim is zero.' raise ValueError(msg) if (max_ambient_dim is not None and - min_rays > 2*(max_ambient_dim - 1)): + min_rays > 2 * (max_ambient_dim - 1)): msg = 'every cone is solid when ' msg += 'min_rays > 2*(max_ambient_dim - 1).' raise ValueError(msg) @@ -6647,12 +6647,11 @@ def random_cone(lattice=None, min_ambient_dim=0, max_ambient_dim=None, if lattice.dimension() == 0: msg = 'all cones in the given lattice are solid.' raise ValueError(msg) - if min_rays > 2*(lattice.dimension() - 1): + if min_rays > 2 * (lattice.dimension() - 1): msg = 'every cone is solid when min_rays > 2*(d - 1) ' msg += 'where d is the dimension of the given lattice.' raise ValueError(msg) - # Now that we've sanity-checked our parameters, we can massage the # min/maxes for (non-)solid cones. It doesn't violate the user's # expectation to increase a minimum, decrease a maximum, or fix an diff --git a/src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py b/src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py index 9e3e8d3fc88..2de12812ddc 100644 --- a/src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py +++ b/src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py @@ -218,7 +218,7 @@ def __hash__(self): if self.domain().is_isometry_group_projective(): # Special care must be taken for projective groups m = matrix(self._matrix.nrows(), - [abs(x) for x in self._matrix.list()]) + [abs(x) for x in self._matrix.list()]) m.set_immutable() else: m = self._matrix diff --git a/src/sage/geometry/lattice_polytope.py b/src/sage/geometry/lattice_polytope.py index 0b30f206cbe..1b428f1c19e 100644 --- a/src/sage/geometry/lattice_polytope.py +++ b/src/sage/geometry/lattice_polytope.py @@ -3335,8 +3335,8 @@ def index_of_max(iterable): ccf = cf # Now let us find out where the end of the # next symmetry block is: - if h < c+1: - h = S[h-1] + if h < c + 1: + h = S[h - 1] s = n_p # Check through this block for each possible permutation while s > 0: diff --git a/src/sage/geometry/polyhedron/base5.py b/src/sage/geometry/polyhedron/base5.py index 04d1fa0314b..9cbddcc70ea 100644 --- a/src/sage/geometry/polyhedron/base5.py +++ b/src/sage/geometry/polyhedron/base5.py @@ -934,14 +934,14 @@ def product(self, other): new_vertices = (tuple(x) + tuple(y) for x in self.vertex_generator() for y in other.vertex_generator()) - self_zero = tuple(0 for _ in range( self.ambient_dim())) + self_zero = tuple(0 for _ in range( self.ambient_dim())) other_zero = tuple(0 for _ in range(other.ambient_dim())) - rays = chain((tuple(r) + other_zero for r in self.ray_generator()), - (self_zero + tuple(r) for r in other.ray_generator())) + rays = chain((tuple(r) + other_zero for r in self.ray_generator()), + (self_zero + tuple(r) for r in other.ray_generator())) - lines = chain((tuple(l) + other_zero for l in self.line_generator()), - (self_zero + tuple(l) for l in other.line_generator())) + lines = chain((tuple(l) + other_zero for l in self.line_generator()), + (self_zero + tuple(l) for l in other.line_generator())) if self.n_vertices() == 0 or other.n_vertices() == 0: # In this case we obtain the empty polyhedron. @@ -950,11 +950,15 @@ def product(self, other): rays = () lines = () - ieqs = chain((tuple(i) + other_zero for i in self.inequality_generator()), - ((i.b(),) + self_zero + tuple(i.A()) for i in other.inequality_generator())) + ieqs = chain((tuple(i) + other_zero + for i in self.inequality_generator()), + ((i.b(),) + self_zero + tuple(i.A()) + for i in other.inequality_generator())) - eqns = chain((tuple(e) + other_zero for e in self.equation_generator()), - ((e.b(),) + self_zero + tuple(e.A()) for e in other.equation_generator())) + eqns = chain((tuple(e) + other_zero + for e in self.equation_generator()), + ((e.b(),) + self_zero + tuple(e.A()) + for e in other.equation_generator())) pref_rep = 'Vrep' if self.n_vertices() + self.n_rays() + other.n_vertices() + other.n_rays() \ <= self.n_inequalities() + other.n_inequalities() else 'Hrep' diff --git a/src/sage/geometry/ribbon_graph.py b/src/sage/geometry/ribbon_graph.py index 6cc269c6b99..ed41f57f7dd 100644 --- a/src/sage/geometry/ribbon_graph.py +++ b/src/sage/geometry/ribbon_graph.py @@ -956,19 +956,19 @@ def homology_basis(self): [[25, 26]], [[27, 28]]] """ - aux_sigma = [list(x) for x in self._sigma.cycle_tuples(singletons=True)] + aux_sigma = [list(x) for x in self._sigma.cycle_tuples(singletons=True)] basis = [[list(x)] for x in self.reduced()._rho.cycle_tuples()] - #Now we define center as the set of edges that were contracted - #in reduced() this set is contractible and can be define as the - #complement of reduced_rho in rho + # Now we define center as the set of edges that were contracted + # in reduced() this set is contractible and can be define as the + # complement of reduced_rho in rho center = [list(x) for x in self._rho.cycle_tuples() if (x not in self.reduced()._rho.cycle_tuples())] - #We define an auxiliary list 'vertices' that will contain the - #vertices (cycles of sigma) corresponding to each half edge. + # We define an auxiliary list 'vertices' that will contain the + # vertices (cycles of sigma) corresponding to each half edge. vertices = [] diff --git a/src/sage/geometry/riemannian_manifolds/parametrized_surface3d.py b/src/sage/geometry/riemannian_manifolds/parametrized_surface3d.py index e1021f66a97..55d5609a861 100644 --- a/src/sage/geometry/riemannian_manifolds/parametrized_surface3d.py +++ b/src/sage/geometry/riemannian_manifolds/parametrized_surface3d.py @@ -905,28 +905,24 @@ def orthonormal_frame(self, coordinates='ext'): 0 sage: sphere.first_fundamental_form(frame_int[2], frame_int[2]) 1 - """ - - from sage.symbolic.constants import pi if coordinates not in ['ext', 'int']: raise ValueError("Coordinate system must be exterior ('ext') " "or interior ('int').") - c = self.first_fundamental_form_coefficient([1,1]) + c = self.first_fundamental_form_coefficient([1, 1]) if coordinates == 'ext': f1 = self.natural_frame()[1] - E1 = _simplify_full_rad(f1/sqrt(c)) + E1 = _simplify_full_rad(f1 / sqrt(c)) E2 = _simplify_full_rad( self.normal_vector(normalized=True).cross_product(E1)) else: - E1 = vector([_simplify_full_rad(1/sqrt(c)), 0]) - E2 = (self.rotation(pi/2)*E1).simplify_full() - return {1:E1, 2:E2} - + E1 = vector([_simplify_full_rad(1 / sqrt(c)), 0]) + E2 = (self.rotation(pi / 2) * E1).simplify_full() + return {1: E1, 2: E2} def orthonormal_frame_vector(self, index, coordinates='ext'): r""" diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index fa48183ecc4..633a97a5e75 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -20933,7 +20933,7 @@ def plot3d(self, bgcolor=(1, 1, 1), vertex_colors = {(1, 0, 0) : list(self)} if color_by_label: - if edge_colors is None: + if edge_colors is None: # do the coloring edge_colors = self._color_by_label(format=color_by_label) elif edge_colors is None: @@ -20975,7 +20975,7 @@ def plot3d(self, bgcolor=(1, 1, 1), vertex_size=vertex_size, pos3d=pos3d, **kwds) if color_by_label: - if edge_colors is None: + if edge_colors is None: # do the coloring edge_colors = self._color_by_label(format=color_by_label) diff --git a/src/sage/groups/cubic_braid.py b/src/sage/groups/cubic_braid.py index a9465ef2b3d..cd8b342ff6b 100644 --- a/src/sage/groups/cubic_braid.py +++ b/src/sage/groups/cubic_braid.py @@ -462,7 +462,7 @@ def burau_matrix(self, root_bur=None, domain=None, characteristic=None, if domain is not None: if isinstance(domain, UniversalCyclotomicField): - if root_bur is None: + if root_bur is None: if unitary: root_bur = domain.gen(12) else: @@ -503,7 +503,7 @@ def find_root(domain): except ValueError: raise ValueError('characteristic must be in integer') - if not characteristic.is_zero() and not characteristic.is_prime(): + if not characteristic.is_zero() and not characteristic.is_prime(): raise ValueError('characteristic must be a prime') if characteristic.is_zero(): if unitary: @@ -991,7 +991,6 @@ def _test_matrix_group(self, **options): self._internal_test_attached_group(matrix_grpF7, tester) return - def _test_reflection_group(self, **options): r""" Check the reflection group properties. @@ -1007,7 +1006,7 @@ def _test_reflection_group(self, **options): sage: CBG2 = CubicBraidGroup(2) sage: CBG2._test_reflection_group() """ - if self._cbg_type == CubicBraidGroup.type.Coxeter and self.is_finite() and self.strands() > 2: + if self._cbg_type == CubicBraidGroup.type.Coxeter and self.is_finite() and self.strands() > 2: from sage.combinat.root_system.reflection_group_real import is_chevie_available if is_chevie_available(): tester = self._tester(**options) @@ -1015,7 +1014,6 @@ def _test_reflection_group(self, **options): self._internal_test_attached_group(reflgrp, tester) return - # ------------------------------------------------------------------------------- # ------------------------------------------------------------------------------- # local utility-methods @@ -1258,9 +1256,9 @@ def create_unitary_realization(self, m): for j in range(mthird): pos = 3*(j+1)-1 transvections.append(xbas[pos-1]) # t_{3i} = x_{3i-1} - if pos +1 < m: + if pos +1 < m: transvections.append(xbas[pos-1]+xbas[pos]+xbas[pos+1]) # t_{3i+1} = x_{3i-1} + x_{3i} + x_{3i+1} - if pos +3 < m: + if pos +3 < m: transvections.append(xbas[pos+1]+xbas[pos+2]+xbas[pos+3]) # t_{3i+2} = x_{3i+1} + x_{3i+2} + x_{3i+3} # ----------------------------------------------------------- @@ -1797,8 +1795,8 @@ def as_reflection_group(self): from sage.combinat.root_system.reflection_group_real import ReflectionGroup - if self.strands() == 2: - reflection_group = ReflectionGroup([2 ,1 ,1]) + if self.strands() == 2: + reflection_group = ReflectionGroup([2, 1, 1]) elif self.strands() == 3: reflection_group = ReflectionGroup(4) elif self.strands() == 4: @@ -1810,7 +1808,6 @@ def as_reflection_group(self): reflection_group.register_conversion(hom_to_refl) return reflection_group - # ---------------------------------------------------------------------------------- # classical invariant form returns the invariant form of the classical realization # ---------------------------------------------------------------------------------- diff --git a/src/sage/groups/perm_gps/cubegroup.py b/src/sage/groups/perm_gps/cubegroup.py index 921c6201c43..3661c2afc10 100644 --- a/src/sage/groups/perm_gps/cubegroup.py +++ b/src/sage/groups/perm_gps/cubegroup.py @@ -431,21 +431,21 @@ def cubie_colors(label, state0): clr_any = named_colors['white'] state = inv_list(state0) if label == 1: - return [clr_any, named_colors[color_of_square(state[1-1])], clr_any] #ulb, + return [clr_any, named_colors[color_of_square(state[1-1])], clr_any] #ulb, if label == 2: - return [clr_any,named_colors[color_of_square(state[2-1])],clr_any] # ub, + return [clr_any,named_colors[color_of_square(state[2-1])],clr_any] # ub, if label == 3: - return [clr_any, named_colors[color_of_square(state[3-1])], named_colors[color_of_square(state[27-1])]] # ubr, + return [clr_any, named_colors[color_of_square(state[3-1])], named_colors[color_of_square(state[27-1])]] # ubr, if label == 4: - return [clr_any, named_colors[color_of_square(state[4-1])], clr_any] # ul, + return [clr_any, named_colors[color_of_square(state[4-1])], clr_any] # ul, if label == 5: - return [clr_any, named_colors[color_of_square(state[5-1])], named_colors[color_of_square(state[26-1])]] # ur, + return [clr_any, named_colors[color_of_square(state[5-1])], named_colors[color_of_square(state[26-1])]] # ur, if label == 6: - return [named_colors[color_of_square(state[17-1])], named_colors[color_of_square(state[6-1])], clr_any] # ufl, + return [named_colors[color_of_square(state[17-1])], named_colors[color_of_square(state[6-1])], clr_any] # ufl, if label == 7: - return [named_colors[color_of_square(state[18-1])], named_colors[color_of_square(state[7-1])], clr_any] # uf, + return [named_colors[color_of_square(state[18-1])], named_colors[color_of_square(state[7-1])], clr_any] # uf, if label == 8: - return [named_colors[color_of_square(state[19-1])], named_colors[color_of_square(state[8-1])], named_colors[color_of_square(state[25-1])]] # urf, + return [named_colors[color_of_square(state[19-1])], named_colors[color_of_square(state[8-1])], named_colors[color_of_square(state[25-1])]] # urf, if label == 17: return [named_colors[color_of_square(state[17-1])], named_colors[color_of_square(state[6-1])], clr_any] # flu if label == 18: diff --git a/src/sage/interacts/library.py b/src/sage/interacts/library.py index bb6dfbcf8f4..094db0c7be2 100644 --- a/src/sage/interacts/library.py +++ b/src/sage/interacts/library.py @@ -1032,7 +1032,7 @@ def _secant_method(f, a, b, maxn, h): L = sum(line([(c,k*i), (d,k*i)]) for i, (c,d) in enumerate(intervals) ) L += sum(line([(c,k*i-k/4), (c,k*i+k/4)]) for i, (c,d) in enumerate(intervals) ) L += sum(line([(d,k*i-k/4), (d,k*i+k/4)]) for i, (c,d) in enumerate(intervals) ) - S = sum(line([(c,f(c)), (d,f(d)), (d-(d-c)*f(d)/(f(d)-f(c)), 0)], color="green") for (c,d) in intervals) + S = sum(line([(c,f(c)), (d,f(d)), (d-(d-c)*f(d)/(f(d)-f(c)), 0)], color="green") for (c, d) in intervals) show(P + L + S, xmin=a, xmax=b) diff --git a/src/sage/interfaces/maxima_abstract.py b/src/sage/interfaces/maxima_abstract.py index cc1d88160bb..14062fa18a4 100644 --- a/src/sage/interfaces/maxima_abstract.py +++ b/src/sage/interfaces/maxima_abstract.py @@ -947,17 +947,17 @@ def solve_linear(self, eqns,vars): """ eqs = "[" for i in range(len(eqns)): - if i, , ] """ from sage.rings.integer import Integer - if not type(item) in (int, Integer): + if not type(item) in (int, Integer): raise ValueError('Item must be an integer') l = self.list() max_item = len(l) - if item < 0 or item > max_item: - raise ValueError('Item must be non negative and smaller than %s' %(max_item)) + if item < 0 or item > max_item: + raise ValueError('Item must be non negative and smaller than %s' % (max_item)) return l[item] @@ -2464,12 +2464,12 @@ def __call__(self, item): return self[item] from sage.rings.integer import Integer - if not type(item) in (int, Integer): + if not type(item) in (int, Integer): raise ValueError('Item must be an integer') - l =self.list() - max_item = len(l)+1 - if item < 1 or item > max_item: - raise ValueError('Item must be positive and smaller than %s' %(max_item)) + l = self.list() + max_item = len(l) + 1 + if item < 1 or item > max_item: + raise ValueError('Item must be positive and smaller than %s' % (max_item)) return l[item-1] diff --git a/src/sage/knots/link.py b/src/sage/knots/link.py index 12e159db251..00907779ec9 100644 --- a/src/sage/knots/link.py +++ b/src/sage/knots/link.py @@ -2914,14 +2914,14 @@ def homfly_polynomial(self, var1=None, var2=None, normalization='lm'): - http://mathworld.wolfram.com/HOMFLYPolynomial.html """ if not var1: - if normalization == 'az': + if normalization == 'az': var1 = 'a' elif normalization == 'vz': var1 = 'v' else: var1 = 'L' if not var2: - if normalization == 'lm': + if normalization == 'lm': var2 = 'M' else: var2 = 'z' @@ -4016,7 +4016,7 @@ def answer(L): if ach is None and achp is None: if unique: raise NotImplementedError('this link cannot be uniquely determined (unknown chirality)%s' %non_unique_hint) - elif L.is_amphicheiral() or L.is_amphicheiral(positive=True): + elif L.is_amphicheiral() or L.is_amphicheiral(positive=True): chiral = False if not chiral: @@ -4192,13 +4192,13 @@ def is_isotopic(self, other): try: ki, m = self.get_knotinfo() - verbose('KnotInfo self: %s mirrored %s' %(ki, m)) + verbose('KnotInfo self: %s mirrored %s' % (ki, m)) try: if ki.is_unique(): try: kio = other.get_knotinfo() - verbose('KnotInfo other: %s mirrored %s' %kio) - return (ki, m) == kio + verbose('KnotInfo other: %s mirrored %s' % kio) + return (ki, m) == kio except NotImplementedError: pass except AttributeError: diff --git a/src/sage/manifolds/differentiable/affine_connection.py b/src/sage/manifolds/differentiable/affine_connection.py index 008f13be22e..1380cc316ed 100644 --- a/src/sage/manifolds/differentiable/affine_connection.py +++ b/src/sage/manifolds/differentiable/affine_connection.py @@ -2210,7 +2210,7 @@ def connection_form(self, i, j, frame=None): comega[k] = coef_frame[[i1,j1,k]] forms[(i1,j1)] = omega self._connection_forms[frame] = forms - return self._connection_forms[frame][(i,j)] + return self._connection_forms[frame][(i,j)] def torsion_form(self, i, frame=None): r""" @@ -2312,7 +2312,7 @@ def torsion_form(self, i, frame=None): ctheta[k,l] = torsion_comp[[i1,k,l]] forms[i1] = theta self._torsion_forms[frame] = forms - return self._torsion_forms[frame][i] + return self._torsion_forms[frame][i] def curvature_form(self, i, j, frame=None): r""" @@ -2422,7 +2422,7 @@ def curvature_form(self, i, j, frame=None): comega[k,l] = riemann_comp[[i1,j1,k,l]] forms[(i1,j1)] = omega self._curvature_forms[frame] = forms - return self._curvature_forms[frame][(i,j)] + return self._curvature_forms[frame][(i, j)] def set_calc_order(self, symbol, order, truncate=False): r""" diff --git a/src/sage/manifolds/differentiable/vectorfield.py b/src/sage/manifolds/differentiable/vectorfield.py index acf07f25aca..ecd41a9882f 100644 --- a/src/sage/manifolds/differentiable/vectorfield.py +++ b/src/sage/manifolds/differentiable/vectorfield.py @@ -799,8 +799,8 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, list_xx = [] while ind != ind_max: - for i in range(ncp): - xx[ind_coord[i]] = xmin[i] + ind[i]*step_tab[i] + for i in range(ncp): + xx[ind_coord[i]] = xmin[i] + ind[i] * step_tab[i] if chart_domain.valid_coordinates(*xx, tolerance=1e-13, parameters=parameters): diff --git a/src/sage/modular/hecke/hecke_operator.py b/src/sage/modular/hecke/hecke_operator.py index 0974629977d..df65f1b526d 100644 --- a/src/sage/modular/hecke/hecke_operator.py +++ b/src/sage/modular/hecke/hecke_operator.py @@ -1,8 +1,7 @@ """ Hecke operators """ - -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2004 William Stein # # Distributed under the terms of the GNU General Public License (GPL) @@ -14,15 +13,13 @@ # # The full text of the GPL is available at: # -# http://www.gnu.org/licenses/ -#***************************************************************************** - - +# https://www.gnu.org/licenses/ +# **************************************************************************** from sage.structure.element import AlgebraElement from sage.structure.richcmp import richcmp, rich_to_bool from sage.categories.homset import End import sage.arith.all as arith -from sage.rings.integer import Integer +from sage.rings.integer import Integer from . import algebra from . import morphism diff --git a/src/sage/modular/overconvergent/all.py b/src/sage/modular/overconvergent/all.py index a6a3b8d158b..11e23071854 100644 --- a/src/sage/modular/overconvergent/all.py +++ b/src/sage/modular/overconvergent/all.py @@ -1,4 +1,4 @@ -from .weightspace import WeightSpace_constructor as pAdicWeightSpace +from .weightspace import WeightSpace_constructor as pAdicWeightSpace from .genus0 import OverconvergentModularForms diff --git a/src/sage/modules/free_module.py b/src/sage/modules/free_module.py index cd0cfdde32d..9deea7e1458 100644 --- a/src/sage/modules/free_module.py +++ b/src/sage/modules/free_module.py @@ -5653,7 +5653,7 @@ def basis(self): """ try: return self.__basis - except AttributeError: + except AttributeError: ZERO = self(0) one = self.coordinate_ring().one() w = [] diff --git a/src/sage/numerical/interactive_simplex_method.py b/src/sage/numerical/interactive_simplex_method.py index 0210d9aea87..3b7e29e9f6f 100644 --- a/src/sage/numerical/interactive_simplex_method.py +++ b/src/sage/numerical/interactive_simplex_method.py @@ -785,7 +785,7 @@ def _latex_(self): latex(xj), r"\geq" if vt == ">=" else r"\leq") for xj, vt in zip(x, self._variable_types) if vt)) lines.append(r"\end{array}") - return "\n".join(lines) + return "\n".join(lines) def _repr_(self): r""" diff --git a/src/sage/quadratic_forms/genera/genus.py b/src/sage/quadratic_forms/genera/genus.py index 0fc43f33c62..c400f73da49 100644 --- a/src/sage/quadratic_forms/genera/genus.py +++ b/src/sage/quadratic_forms/genera/genus.py @@ -676,10 +676,10 @@ def canonical_2_adic_trains(genus_symbol_quintuple_list, compartments=None): trains = [] new_train = [0] - for i in range(1,len(symbol)-1): + for i in range(1, len(symbol) - 1): # start a new train if there are two adjacent even symbols prev, cur = symbol[i-1:i+1] - if cur[0] - prev[0] > 2: + if cur[0] - prev[0] > 2: trains.append(new_train) new_train = [i] # create a new train starting at elif (cur[0] - prev[0] == 2) and cur[3]*prev[3] == 0: diff --git a/src/sage/quadratic_forms/quadratic_form__ternary_Tornaria.py b/src/sage/quadratic_forms/quadratic_form__ternary_Tornaria.py index 22334a8e857..ae836c20ce3 100644 --- a/src/sage/quadratic_forms/quadratic_form__ternary_Tornaria.py +++ b/src/sage/quadratic_forms/quadratic_form__ternary_Tornaria.py @@ -331,7 +331,7 @@ def clifford_invariant(self, p): 1 """ n = self.dim() % 8 - if n == 1 or n == 2: + if n == 1 or n == 2: s = 1 elif n == 3 or n == 4: s = hilbert_symbol(-1, -self.disc(), p) @@ -586,12 +586,11 @@ def is_zero(self, v, p=0) -> bool: True sage: Q1.is_zero([1,1,0], 2) False - """ norm = self(v) if p != 0: norm = norm % p - return norm == 0 + return norm == 0 def is_zero_nonsingular(self, v, p=0) -> bool: diff --git a/src/sage/sets/non_negative_integers.py b/src/sage/sets/non_negative_integers.py index 9b5def119e0..29edc3a11a1 100644 --- a/src/sage/sets/non_negative_integers.py +++ b/src/sage/sets/non_negative_integers.py @@ -115,7 +115,7 @@ def __contains__(self, elt): """ try: i = Integer(elt) - return i >= Integer(0) and i == elt + return i >= Integer(0) and i == elt except (TypeError, ValueError): return False diff --git a/src/sage/symbolic/units.py b/src/sage/symbolic/units.py index 9b5407786e1..8445499cb01 100644 --- a/src/sage/symbolic/units.py +++ b/src/sage/symbolic/units.py @@ -1458,7 +1458,7 @@ def convert_temperature(expr, target): target_temp = target.variables()[0] a = sage_eval(unitdict['temperature'][str(expr_temp)], locals={'x': coeff}) - if target is None or target_temp == units.temperature.kelvin: + if target is None or target_temp == units.temperature.kelvin: return a[0]*units.temperature.kelvin elif target_temp == units.temperature.celsius or target_temp == units.temperature.centigrade: return a[1]*target_temp diff --git a/src/sage/tensor/modules/tensor_with_indices.py b/src/sage/tensor/modules/tensor_with_indices.py index fd5eaf6824b..1e658682d41 100644 --- a/src/sage/tensor/modules/tensor_with_indices.py +++ b/src/sage/tensor/modules/tensor_with_indices.py @@ -628,7 +628,6 @@ def __mul__(self, other): True sage: s[:] [3, -6, 9] - """ if not isinstance(other, TensorWithIndices): raise TypeError("the second item of * must be a tensor with " + @@ -636,12 +635,12 @@ def __mul__(self, other): contraction_pairs = [] for ind in self._con: if ind != '.': - if ind in other._cov: + if ind in other._cov: pos1 = self._con.index(ind) pos2 = other._tensor._tensor_type[0] + other._cov.index(ind) contraction_pairs.append((pos1, pos2)) if ind in other._con: - raise IndexError("the index {} appears twice ".format(ind) + raise IndexError(f"the index {ind} appears twice " + "in a contravariant position") for ind in self._cov: if ind != '.': @@ -650,7 +649,7 @@ def __mul__(self, other): pos2 = other._con.index(ind) contraction_pairs.append((pos1, pos2)) if ind in other._cov: - raise IndexError("the index {} appears twice ".format(ind) + raise IndexError(f"the index {ind} appears twice " + "in a covariant position") if not contraction_pairs: # No contraction is performed: the tensor product is returned