From e1a6ffae7b9c8b49b4d7fcbe0de57989afc98f10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sat, 14 Dec 2024 15:07:34 +0100 Subject: [PATCH 1/2] some care for pep8 E262 (comments) --- src/sage/categories/category_with_axiom.py | 2 +- src/sage/categories/groupoid.py | 6 ++-- src/sage/categories/unital_algebras.py | 2 +- .../coding/guruswami_sudan/interpolation.py | 6 ++-- src/sage/combinat/diagram_algebras.py | 32 +++++++++---------- src/sage/combinat/growth.py | 4 +-- src/sage/combinat/k_tableau.py | 20 ++++++------ src/sage/combinat/partition_kleshchev.py | 16 +++++----- src/sage/combinat/root_system/cartan_type.py | 4 ++- src/sage/combinat/sf/sfa.py | 28 ++++++++-------- src/sage/combinat/six_vertex_model.py | 6 ++-- src/sage/databases/db_class_polynomials.py | 6 ++-- src/sage/features/ffmpeg.py | 12 +++---- .../hyperbolic_space/hyperbolic_isometry.py | 28 ++++++++-------- .../modules/formal_polyhedra_module.py | 2 +- .../differentiable/automorphismfield.py | 4 +-- .../differentiable/integrated_curve.py | 29 +++++++++-------- .../differentiable/tensorfield_paral.py | 2 +- .../manifolds/differentiable/vectorframe.py | 2 +- src/sage/matroids/chow_ring_ideal.py | 19 +++++------ .../numerical/backends/logging_backend.py | 16 +++++----- .../numerical/interactive_simplex_method.py | 4 +-- src/sage/plot/hyperbolic_regular_polygon.py | 6 ++-- .../rings/number_field/number_field_ideal.py | 7 ++-- src/sage/rings/padics/factory.py | 2 +- src/sage/rings/padics/generic_nodes.py | 8 +++-- .../rings/padics/relative_extension_leaves.py | 4 +-- src/sage/tensor/modules/comp.py | 2 +- 28 files changed, 144 insertions(+), 135 deletions(-) diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py index 014ac68d369..5e5b7ec8aff 100644 --- a/src/sage/categories/category_with_axiom.py +++ b/src/sage/categories/category_with_axiom.py @@ -2525,7 +2525,7 @@ def __init__(self, base_category): Category_over_base_ring.__init__(self, base_category.base_ring()) -class CategoryWithAxiom_singleton(Category_singleton, CategoryWithAxiom):#, Category_singleton, FastHashable_class): +class CategoryWithAxiom_singleton(Category_singleton, CategoryWithAxiom): # Category_singleton, FastHashable_class): pass diff --git a/src/sage/categories/groupoid.py b/src/sage/categories/groupoid.py index b197c092be5..4833b4e6f57 100644 --- a/src/sage/categories/groupoid.py +++ b/src/sage/categories/groupoid.py @@ -40,7 +40,7 @@ def __init__(self, G=None): sage: C = Groupoid(S8) sage: TestSuite(C).run() """ - CategoryWithParameters.__init__(self) #, "Groupoid") + CategoryWithParameters.__init__(self) # "Groupoid") if G is None: from sage.groups.perm_gps.permgroup_named import SymmetricGroup G = SymmetricGroup(8) @@ -56,8 +56,8 @@ def _repr_(self): """ return "Groupoid with underlying set %s" % self.__G - #def construction(self): - # return (self.__class__, self.__G) + # def construction(self): + # return (self.__class__, self.__G) def _make_named_class_key(self, name): """ diff --git a/src/sage/categories/unital_algebras.py b/src/sage/categories/unital_algebras.py index b5c0dd73e86..33c10cf2c4a 100644 --- a/src/sage/categories/unital_algebras.py +++ b/src/sage/categories/unital_algebras.py @@ -319,7 +319,7 @@ def one_from_one_basis(self): sage: Aone().parent() is A # needs sage.combinat sage.modules True """ - return self.monomial(self.one_basis()) #. + return self.monomial(self.one_basis()) @lazy_attribute def one(self): diff --git a/src/sage/coding/guruswami_sudan/interpolation.py b/src/sage/coding/guruswami_sudan/interpolation.py index b1334307e79..ae667c5dae1 100644 --- a/src/sage/coding/guruswami_sudan/interpolation.py +++ b/src/sage/coding/guruswami_sudan/interpolation.py @@ -284,10 +284,10 @@ def gs_interpolation_linalg(points, tau, parameters, wy): # Pick a nonzero element from the right kernel sol = Ker.basis()[0] # Construct the Q polynomial - PF = M.base_ring()['x', 'y'] #make that ring a ring in + PF = M.base_ring()['x', 'y'] # make that ring a ring in x, y = PF.gens() - Q = sum([x**monomials[i][0] * y**monomials[i][1] * sol[i] for i in range(0, len(monomials))]) - return Q + return sum([x**monomials[i][0] * y**monomials[i][1] * sol[i] + for i in range(len(monomials))]) ####################### Lee-O'Sullivan's method ############################### diff --git a/src/sage/combinat/diagram_algebras.py b/src/sage/combinat/diagram_algebras.py index 6410a4a93ea..b929327a28e 100644 --- a/src/sage/combinat/diagram_algebras.py +++ b/src/sage/combinat/diagram_algebras.py @@ -129,14 +129,14 @@ def brauer_diagrams(k): {{-3, 3}, {-2, 2}, {-1, 1}}] """ if k in ZZ: - s = list(range(1,k+1)) + list(range(-k,0)) + s = list(range(1, k+1)) + list(range(-k,0)) for p in perfect_matchings_iterator(k): yield [(s[a],s[b]) for a,b in p] - elif k + ZZ(1) / ZZ(2) in ZZ: # Else k in 1/2 ZZ - k = ZZ(k + ZZ(1) / ZZ(2)) + elif k + ZZ.one() / 2 in ZZ: # Else k in 1/2 ZZ + k = ZZ(k + ZZ.one() / 2) s = list(range(1, k)) + list(range(-k+1,0)) for p in perfect_matchings_iterator(k-1): - yield [(s[a],s[b]) for a,b in p] + [[k, -k]] + yield [(s[a], s[b]) for a, b in p] + [[k, -k]] def temperley_lieb_diagrams(k): @@ -1203,7 +1203,7 @@ def __init__(self, order, category=None): self.order = ZZ(order) base_set = frozenset(list(range(1,order+1)) + list(range(-order,0))) else: - #order is a half-integer. + # order is a half-integer. self.order = QQ(order) base_set = frozenset(list(range(1,ZZ(ZZ(1)/ZZ(2) + order)+1)) + list(range(ZZ(-ZZ(1)/ZZ(2) - order),0))) @@ -4865,7 +4865,7 @@ def key_func(P): count_left += 1 for j in range(i): prop_intervals[j].append([bot]) - for j in range(i+1,total_prop): + for j in range(i+1, total_prop): prop_intervals[j].append([top]) if not left_moving: top, bot = bot, top @@ -4964,10 +4964,10 @@ def sgn(x): for i in list(diagram): l1.append(list(i)) l2.extend(list(i)) - output = "\\begin{tikzpicture}[scale = 0.5,thick, baseline={(0,-1ex/2)}] \n\\tikzstyle{vertex} = [shape = circle, minimum size = 7pt, inner sep = 1pt] \n" #setup beginning of picture - for i in l2: #add nodes + output = "\\begin{tikzpicture}[scale = 0.5,thick, baseline={(0,-1ex/2)}] \n\\tikzstyle{vertex} = [shape = circle, minimum size = 7pt, inner sep = 1pt] \n" # setup beginning of picture + for i in l2: # add nodes output = output + "\\node[vertex] (G-{}) at ({}, {}) [shape = circle, draw{}] {{}}; \n".format(i, (abs(i)-1)*1.5, sgn(i), filled_str) - for i in l1: #add edges + for i in l1: # add edges if len(i) > 1: l4 = list(i) posList = [] @@ -4980,21 +4980,21 @@ def sgn(x): posList.sort() negList.sort() l4 = posList + negList - l5 = l4[:] #deep copy + l5 = l4[:] # deep copy for j in range(len(l5)): - l5[j-1] = l4[j] #create a permuted list + l5[j-1] = l4[j] # create a permuted list if len(l4) == 2: l4.pop() - l5.pop() #pops to prevent duplicating edges + l5.pop() # pops to prevent duplicating edges for j in zip(l4, l5): xdiff = abs(j[1])-abs(j[0]) y1 = sgn(j[0]) y2 = sgn(j[1]) - if y2-y1 == 0 and abs(xdiff) < 5: #if nodes are close to each other on same row - diffCo = (0.5+0.1*(abs(xdiff)-1)) #gets bigger as nodes are farther apart; max value of 1; min value of 0.5. + if y2-y1 == 0 and abs(xdiff) < 5: # if nodes are close to each other on same row + diffCo = (0.5+0.1*(abs(xdiff)-1)) # gets bigger as nodes are farther apart; max value of 1; min value of 0.5. outVec = (sgn(xdiff)*diffCo, -1*diffCo*y1) inVec = (-1*diffCo*sgn(xdiff), -1*diffCo*y2) - elif y2-y1 != 0 and abs(xdiff) == 1: #if nodes are close enough curviness looks bad. + elif y2-y1 != 0 and abs(xdiff) == 1: # if nodes are close enough curviness looks bad. outVec = (sgn(xdiff)*0.75, -1*y1) inVec = (-1*sgn(xdiff)*0.75, -1*y2) else: @@ -5002,7 +5002,7 @@ def sgn(x): inVec = (-1*sgn(xdiff), -1*y2) output = output + "\\draw[{}] (G-{}) .. controls +{} and +{} .. {}(G-{}); \n".format( edge_options(j), j[0], outVec, inVec, edge_additions(j), j[1]) - output = output + "\\end{tikzpicture}" #end picture + output = output + "\\end{tikzpicture}" # end picture return output diff --git a/src/sage/combinat/growth.py b/src/sage/combinat/growth.py index 958b664e7cd..542d4dfb280 100644 --- a/src/sage/combinat/growth.py +++ b/src/sage/combinat/growth.py @@ -2592,11 +2592,11 @@ def forward_rule(self, y, e, t, f, x, content): z, h = x, e elif x == t != y: z, h = y, e - else: # x != t and y != t + else: # x != t and y != t qx = SkewPartition([x.to_partition(), t.to_partition()]) qy = SkewPartition([y.to_partition(), t.to_partition()]) if not all(c in qx.cells() for c in qy.cells()): - res = [(j-i) % self.k for i,j in qx.cells()] + res = [(j-i) % self.k for i, j in qx.cells()] assert len(set(res)) == 1 r = res[0] z = y.affine_symmetric_group_simple_action(r) diff --git a/src/sage/combinat/k_tableau.py b/src/sage/combinat/k_tableau.py index de6b783f15b..cb6d6fbc087 100644 --- a/src/sage/combinat/k_tableau.py +++ b/src/sage/combinat/k_tableau.py @@ -1625,12 +1625,12 @@ def from_core_tableau(cls, t, k): [[None, 2], [3]] """ t = SkewTableau(list(t)) - shapes = [ Core(p, k+1).to_bounded_partition() for p in intermediate_shapes(t) ]#.to_chain() ] + shapes = [ Core(p, k+1).to_bounded_partition() for p in intermediate_shapes(t) ] # .to_chain() ] if t.inner_shape() == Partition([]): l = [] else: l = [[None]*i for i in shapes[0]] - for i in range(1,len(shapes)): + for i in range(1, len(shapes)): p = shapes[i] if len(l) < len(p): l += [[]] @@ -2068,8 +2068,10 @@ def from_core_tableau(cls, t, k): [s0*s3, s2*s1] """ t = SkewTableau(list(t)) - shapes = [ Core(p, k+1).to_grassmannian() for p in intermediate_shapes(t) ] #t.to_chain() ] - perms = [ shapes[i]*(shapes[i-1].inverse()) for i in range(len(shapes)-1,0,-1)] + shapes = [Core(p, k + 1).to_grassmannian() + for p in intermediate_shapes(t)] # t.to_chain() ] + perms = [shapes[i] * (shapes[i - 1].inverse()) + for i in range(len(shapes) - 1, 0, -1)] return cls(perms, k, inner_shape=t.inner_shape()) def k_charge(self, algorithm='I'): @@ -4222,16 +4224,16 @@ def _left_action_list( cls, Tlist, tij, v, k ): """ innershape = Core([len(r) for r in Tlist], k + 1) outershape = innershape.affine_symmetric_group_action(tij, transposition=True) - if outershape.length() == innershape.length()+1: + if outershape.length() == innershape.length() + 1: for c in SkewPartition([outershape.to_partition(),innershape.to_partition()]).cells(): while c[0] >= len(Tlist): Tlist.append([]) - Tlist[c[0]].append( v ) + Tlist[c[0]].append(v) if len(Tlist[c[0]])-c[0] == tij[1]: - Tlist[c[0]][-1] = -Tlist[c[0]][-1] #mark the cell that is on the j-1 diagonal + Tlist[c[0]][-1] = -Tlist[c[0]][-1] # mark the cell that is on the j-1 diagonal return Tlist - else: - raise ValueError("%s is not a single step up in the strong lattice" % tij) + + raise ValueError("%s is not a single step up in the strong lattice" % tij) @classmethod def follows_tableau_unsigned_standard( cls, Tlist, k ): diff --git a/src/sage/combinat/partition_kleshchev.py b/src/sage/combinat/partition_kleshchev.py index cfa78933e37..444a46f2cf1 100644 --- a/src/sage/combinat/partition_kleshchev.py +++ b/src/sage/combinat/partition_kleshchev.py @@ -162,9 +162,9 @@ def conormal_cells(self, i=None): carry[res] += 1 else: res = KP._multicharge[0] + self[row] - row - 1 - if row == len(self)-1 or self[row] > self[row+1]: # removable cell + if row == len(self)-1 or self[row] > self[row+1]: # removable cell carry[res] -= 1 - if row == 0 or self[row-1] > self[row]: #addable cell + if row == 0 or self[row-1] > self[row]: # addable cell if carry[res+1] >= 0: conormals[res+1].append((row, self[row])) else: @@ -661,25 +661,25 @@ def normal_cells(self, i=None): part_lens = [len(part) for part in self] # so we don't repeatedly call these KP = self.parent() if KP._convention[0] == 'L': - rows = [(k,r) for k,ell in enumerate(part_lens) for r in range(ell+1)] + rows = [(k, r) for k, ell in enumerate(part_lens) for r in range(ell+1)] else: - rows = [(k,r) for k,ell in reversed(list(enumerate(part_lens))) for r in range(ell+1)] + rows = [(k, r) for k, ell in reversed(list(enumerate(part_lens))) for r in range(ell+1)] if KP._convention[1] == 'S': rows.reverse() for row in rows: - k,r = row - if r == part_lens[k]: # addable cell at bottom of a component + k, r = row + if r == part_lens[k]: # addable cell at bottom of a component carry[KP._multicharge[k]-r] += 1 else: part = self[k] res = KP._multicharge[k] + (part[r] - r - 1) - if r == part_lens[k]-1 or part[r] > part[r+1]: # removable cell + if r == part_lens[k]-1 or part[r] > part[r+1]: # removable cell if carry[res] == 0: normals[res].insert(0, (k, r, part[r]-1)) else: carry[res] -= 1 - if r == 0 or part[r-1] > part[r]: #addable cell + if r == 0 or part[r-1] > part[r]: # addable cell carry[res+1] += 1 # finally return the result diff --git a/src/sage/combinat/root_system/cartan_type.py b/src/sage/combinat/root_system/cartan_type.py index ce5762719e2..19c500a412f 100644 --- a/src/sage/combinat/root_system/cartan_type.py +++ b/src/sage/combinat/root_system/cartan_type.py @@ -841,7 +841,9 @@ def _samples(self): [CartanType(t) for t in [["I", 5], ["H", 3], ["H", 4]]] + \ [t.affine() for t in finite_crystallographic if t.is_irreducible()] + \ [CartanType(t) for t in [["BC", 1, 2], ["BC", 5, 2]]] + \ - [CartanType(t).dual() for t in [["B", 5, 1], ["C", 4, 1], ["F", 4, 1], ["G", 2, 1],["BC", 1, 2], ["BC", 5, 2]]] #+ \ + [CartanType(t).dual() for t in [["B", 5, 1], ["C", 4, 1], + ["F", 4, 1], ["G", 2, 1], + ["BC", 1, 2], ["BC", 5, 2]]] # + \ # [ g ] _colors = {1: 'blue', -1: 'blue', diff --git a/src/sage/combinat/sf/sfa.py b/src/sage/combinat/sf/sfa.py index 92a068e4c8c..60fc4b65c53 100644 --- a/src/sage/combinat/sf/sfa.py +++ b/src/sage/combinat/sf/sfa.py @@ -2284,28 +2284,28 @@ def _invert_morphism(self, n, base_ring, sage: c2 == d2 True """ - #Decide whether we know how to go from self to other or - #from other to self + # Decide whether we know how to go from self to other or + # from other to self if to_other_function is not None: - known_cache = self_to_other_cache #the known direction - unknown_cache = other_to_self_cache #the unknown direction + known_cache = self_to_other_cache # the known direction + unknown_cache = other_to_self_cache # the unknown direction known_function = to_other_function else: - unknown_cache = self_to_other_cache #the known direction - known_cache = other_to_self_cache #the unknown direction + unknown_cache = self_to_other_cache # the known direction + known_cache = other_to_self_cache # the unknown direction known_function = to_self_function - #Do nothing if we've already computed the inverse - #for degree n. + # Do nothing if we've already computed the inverse + # for degree n. if n in known_cache and n in unknown_cache: return - #Univariate polynomial arithmetic is faster - #over ZZ. Since that is all we need to compute - #the transition matrices between S and P, we - #should use that. - #Zt = ZZ['t'] - #t = Zt.gen() + # Univariate polynomial arithmetic is faster + # over ZZ. Since that is all we need to compute + # the transition matrices between S and P, we + # should use that. + # Zt = ZZ['t'] + # t = Zt.gen() one = base_ring.one() zero = base_ring.zero() diff --git a/src/sage/combinat/six_vertex_model.py b/src/sage/combinat/six_vertex_model.py index 879418f18d9..ca70c9661c6 100644 --- a/src/sage/combinat/six_vertex_model.py +++ b/src/sage/combinat/six_vertex_model.py @@ -777,7 +777,7 @@ def to_alternating_sign_matrix(self): [ 0 1 -1 1] [ 0 0 1 0] """ - from sage.combinat.alternating_sign_matrix import AlternatingSignMatrix #AlternatingSignMatrices - #ASM = AlternatingSignMatrices(self.parent()._nrows) - #return ASM(self.to_signed_matrix()) + from sage.combinat.alternating_sign_matrix import AlternatingSignMatrix # AlternatingSignMatrices + # ASM = AlternatingSignMatrices(self.parent()._nrows) + # return ASM(self.to_signed_matrix()) return AlternatingSignMatrix(self.to_signed_matrix()) diff --git a/src/sage/databases/db_class_polynomials.py b/src/sage/databases/db_class_polynomials.py index 57acde7c05a..4362df56837 100644 --- a/src/sage/databases/db_class_polynomials.py +++ b/src/sage/databases/db_class_polynomials.py @@ -30,8 +30,8 @@ from .db_modular_polynomials import _dbz_to_integers -disc_format = "%07d" # disc_length = 7 -level_format = "%03d" # level_length = 3 +disc_format = "%07d" # disc_length = 7 +level_format = "%03d" # level_length = 3 class ClassPolynomialDatabase: @@ -52,7 +52,7 @@ def _dbpath(self, disc, level=1): if level != 1: raise NotImplementedError("Level (= %s) > 1 not yet implemented" % level) n1 = 5000*((abs(disc)-1)//5000) - s1 = disc_format % (n1+1) #_pad_int(n1+1, disc_length) + s1 = disc_format % (n1+1) # _pad_int(n1+1, disc_length) s2 = disc_format % (n1+5000) subdir = "%s-%s" % (s1, s2) discstr = disc_format % abs(disc) diff --git a/src/sage/features/ffmpeg.py b/src/sage/features/ffmpeg.py index 8214e4d6ff3..c33e36062a1 100644 --- a/src/sage/features/ffmpeg.py +++ b/src/sage/features/ffmpeg.py @@ -76,19 +76,19 @@ def is_functional(self): # The `-nostdin` is needed to avoid the command to hang, see # https://stackoverflow.com/questions/16523746/ffmpeg-hangs-when-run-in-background commands = [] - for ext in ['.avi', '.flv', '.gif', '.mkv', '.mov', #'.mpg', - '.mp4', '.ogg', '.ogv', '.webm', '.wmv']: + for ext in ['.avi', '.flv', '.gif', '.mkv', '.mov', + '.mp4', '.ogg', '.ogv', '.webm', '.wmv']: cmd = ['ffmpeg', '-nostdin', '-y', '-f', 'image2', '-r', '5', - '-i', filename_png, '-pix_fmt', 'rgb24', '-loop', '0', - filename + ext] + '-i', filename_png, '-pix_fmt', 'rgb24', '-loop', '0', + filename + ext] commands.append(cmd) for ext in ['.avi', '.flv', '.gif', '.mkv', '.mov', '.mpg', - '.mp4', '.ogg', '.ogv', '.webm', '.wmv']: + '.mp4', '.ogg', '.ogv', '.webm', '.wmv']: cmd = ['ffmpeg', '-nostdin', '-y', '-f', 'image2', '-i', - filename_png, filename + ext] + filename_png, filename + ext] commands.append(cmd) # Running the commands and reporting any issue encountered diff --git a/src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py b/src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py index 2dd20676215..9fe8f9e5a67 100644 --- a/src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py +++ b/src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py @@ -188,9 +188,9 @@ def __eq__(self, other): return False test_matrix = bool((self.matrix() - other.matrix()).norm() < EPSILON) if self.domain().is_isometry_group_projective(): - A,B = self.matrix(), other.matrix() # Rename for simplicity + A, B = self.matrix(), other.matrix() # Rename for simplicity m = self.matrix().ncols() - A = A / sqrt(A.det(), m) # Normalized to have determinant 1 + A = A / sqrt(A.det(), m) # Normalized to have determinant 1 B = B / sqrt(B.det(), m) test_matrix = ((A - B).norm() < EPSILON or (A + B).norm() < EPSILON) @@ -636,7 +636,7 @@ class HyperbolicIsometryUHP(HyperbolicIsometry): [1 0] [0 1] """ - def _call_(self, p): #UHP + def _call_(self, p): # UHP r""" Return image of ``p`` under the action of ``self``. @@ -656,7 +656,7 @@ def _call_(self, p): #UHP coords = coords.conjugate() return self.codomain().get_point(moebius_transform(self._matrix, coords)) - def preserves_orientation(self): #UHP + def preserves_orientation(self): # UHP r""" Return ``True`` if ``self`` is orientation-preserving and ``False`` otherwise. @@ -673,7 +673,7 @@ def preserves_orientation(self): #UHP """ return bool(self._matrix.det() > 0) - def classification(self): #UHP + def classification(self): # UHP r""" Classify the hyperbolic isometry as elliptic, parabolic, or hyperbolic. @@ -725,7 +725,7 @@ def classification(self): #UHP return 'reflection' return 'orientation-reversing hyperbolic' - def translation_length(self): #UHP + def translation_length(self): # UHP r""" For hyperbolic elements, return the translation length; otherwise, raise a :exc:`ValueError`. @@ -800,7 +800,7 @@ def fixed_point_set(self): # UHP d = sqrt(tau - 4) return [pt((M[0,0] - M[1,1] + sign(M[1,0])*d) / (2*M[1,0]))] elif M_cls == 'hyperbolic': - if M[1,0] != 0: #if the isometry doesn't fix infinity + if M[1,0] != 0: # if the isometry does not fix infinity d = sqrt(tau - 4) p_1 = (M[0,0] - M[1,1]+d) / (2*M[1,0]) p_2 = (M[0,0] - M[1,1]-d) / (2*M[1,0]) @@ -898,7 +898,7 @@ class HyperbolicIsometryPD(HyperbolicIsometry): [1 0] [0 1] """ - def _call_(self, p): #PD + def _call_(self, p): # PD r""" Return image of ``p`` under the action of ``self``. @@ -917,7 +917,7 @@ def _call_(self, p): #PD _image = moebius_transform(self._matrix, coords) return self.codomain().get_point(_image) - def __mul__(self, other): #PD + def __mul__(self, other): # PD r""" Return image of ``p`` under the action of ``self``. @@ -935,7 +935,7 @@ def __mul__(self, other): #PD return M.to_model('PD') return super().__mul__(other) - def __pow__(self, n): #PD + def __pow__(self, n): # PD r""" EXAMPLES:: @@ -948,7 +948,7 @@ def __pow__(self, n): #PD """ return (self._cached_isometry**n).to_model('PD') - def preserves_orientation(self): #PD + def preserves_orientation(self): # PD """ Return ``True`` if ``self`` preserves orientation and ``False`` otherwise. @@ -964,7 +964,7 @@ def preserves_orientation(self): #PD return bool(self._matrix.det() > 0) and HyperbolicIsometryPD._orientation_preserving(self._matrix) @staticmethod - def _orientation_preserving(A): #PD + def _orientation_preserving(A): # PD r""" For a matrix ``A`` of a PD isometry, determine if it preserves orientation. @@ -1001,7 +1001,7 @@ class HyperbolicIsometryKM(HyperbolicIsometry): [0 1 0] [0 0 1] """ - def _call_(self, p): #KM + def _call_(self, p): # KM r""" Return image of ``p`` under the action of ``self``. @@ -1019,7 +1019,7 @@ def _call_(self, p): #KM return self.codomain().get_point(v[0:2] / v[2]) ##################################################################### -## Helper functions +# Helper functions def moebius_transform(A, z): diff --git a/src/sage/geometry/polyhedron/modules/formal_polyhedra_module.py b/src/sage/geometry/polyhedron/modules/formal_polyhedra_module.py index d7ef932a4cf..91101f120fc 100644 --- a/src/sage/geometry/polyhedron/modules/formal_polyhedra_module.py +++ b/src/sage/geometry/polyhedron/modules/formal_polyhedra_module.py @@ -82,7 +82,7 @@ def __classcall__(cls, base_ring, dimension, basis, category=None): """ if isinstance(basis, list): basis = tuple(basis) - if isinstance(basis, tuple): #To make sure it only check for finite input + if isinstance(basis, tuple): # To make sure it only checks for finite input from sage.geometry.polyhedron.base import Polyhedron_base for P in basis: if not isinstance(P, Polyhedron_base): diff --git a/src/sage/manifolds/differentiable/automorphismfield.py b/src/sage/manifolds/differentiable/automorphismfield.py index c8f2143beb2..320620a0d8b 100644 --- a/src/sage/manifolds/differentiable/automorphismfield.py +++ b/src/sage/manifolds/differentiable/automorphismfield.py @@ -1199,7 +1199,7 @@ def __invert__(self): if isinstance(frame, CoordFrame): chart = frame._chart else: - chart = self._domain._def_chart #!# to be improved + chart = self._domain._def_chart # ! # to be improved try: # TODO: do the computation without the 'SR' enforcement mat_self = matrix( @@ -1370,7 +1370,7 @@ def at(self, point): if dest_map.is_identity(): amb_point = point else: - amb_point = dest_map(point) # "ambient" point + amb_point = dest_map(point) # "ambient" point ts = amb_point._manifold.tangent_space(amb_point) if self._is_identity: return ts.identity_map() diff --git a/src/sage/manifolds/differentiable/integrated_curve.py b/src/sage/manifolds/differentiable/integrated_curve.py index 77d6a419325..8b2d1f0251c 100644 --- a/src/sage/manifolds/differentiable/integrated_curve.py +++ b/src/sage/manifolds/differentiable/integrated_curve.py @@ -1096,7 +1096,7 @@ def solve(self, step=None, method='odeint', solution_key=None, # raise error if coordinates in chart cannot be obtained initial_coord_basis = chart.frame().at(initial_pt) - initial_tgt_vec_comps = list(v0[initial_coord_basis,:]) #idem + initial_tgt_vec_comps = list(v0[initial_coord_basis,:]) # idem dim = self.codomain().dim() @@ -2372,15 +2372,15 @@ def plot_integrated(self, chart=None, ambient_coords=None, else: if across_charts: for key in self._interpolations: - if key[-8:-1] != '_chart_': # check if not a subplot + if key[-8:-1] != '_chart_': # check if not a subplot interpolation_key = key break else: raise ValueError("Did you forget to " "integrate or interpolate the result?") else: - interpolation_key = next(iter(self._interpolations)) #will - # raise error if self._interpolations empty + interpolation_key = next(iter(self._interpolations)) + # will raise error if self._interpolations empty if verbose: print("Plotting from the interpolation associated " + @@ -2484,7 +2484,7 @@ def plot_integrated(self, chart=None, ambient_coords=None, raise ValueError("the argument prange must be a " + "tuple/list of 2 elements") else: - p = prange #'p' declared only for the line below to be shorter + p = prange # 'p' declared only for the line below to be shorter if p[0] < param_min or p[0] > param_max or p[1] < param_min or p[1] > param_max: raise ValueError("parameter range should be a " + "subinterval of the curve domain " + @@ -3972,18 +3972,19 @@ def system(self, verbose=False): if verbose: initial_tgt_space = v0.parent() - initial_pt = initial_tgt_space.base_point()#retrieves - # the initial point as the base point of the tangent space - # to which initial tangent vector belongs + initial_pt = initial_tgt_space.base_point() + # retrieves the initial point as the base point of the + # tangent space to which initial tangent vector belongs + initial_pt_coords = list(initial_pt.coordinates(chart)) - # previous line converts to list since would otherwise be a - # tuple ; will raise error if coordinates in chart are not - # known + # previous line converts to list since would otherwise be + # a tuple ; will raise error if coordinates in chart are + # not known initial_coord_basis = chart.frame().at(initial_pt) - initial_tgt_vec_comps = v0[initial_coord_basis,:] # will - # raise error if components in coordinate basis are not - # known + initial_tgt_vec_comps = v0[initial_coord_basis,:] + # will raise error if components in coordinate basis are + # not known description = "Geodesic " if self._name is not None: diff --git a/src/sage/manifolds/differentiable/tensorfield_paral.py b/src/sage/manifolds/differentiable/tensorfield_paral.py index 3fa7166234c..08b151e50c9 100644 --- a/src/sage/manifolds/differentiable/tensorfield_paral.py +++ b/src/sage/manifolds/differentiable/tensorfield_paral.py @@ -2118,7 +2118,7 @@ def at(self, point): if dest_map.is_identity(): amb_point = point else: - amb_point = dest_map(point) # "ambient" point + amb_point = dest_map(point) # "ambient" point ts = amb_point._manifold.tangent_space(amb_point) resu = ts.tensor(self._tensor_type, name=self._name, latex_name=self._latex_name, sym=self._sym, diff --git a/src/sage/manifolds/differentiable/vectorframe.py b/src/sage/manifolds/differentiable/vectorframe.py index 8cc75ab0f2d..a4df55bd276 100644 --- a/src/sage/manifolds/differentiable/vectorframe.py +++ b/src/sage/manifolds/differentiable/vectorframe.py @@ -1404,7 +1404,7 @@ def at(self, point): """ # Case of a non-trivial destination map if self._from_frame is not None: - if self._dest_map.is_identity(): #!# probably not necessary + if self._dest_map.is_identity(): # ! # probably not necessary raise ValueError("the destination map should not be the identity") ambient_point = self._dest_map(point) return self._from_frame.at(ambient_point) diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py index d0ac04a23ee..85913786c74 100644 --- a/src/sage/matroids/chow_ring_ideal.py +++ b/src/sage/matroids/chow_ring_ideal.py @@ -52,9 +52,10 @@ def _lattice_flats(self): flats = list(lattice_flats) flats.sort(key=lambda X: (len(X), sorted(X))) ranks = {F: self._matroid.rank(F) for F in flats} - chains = lattice_flats.chains() #Only chains + chains = lattice_flats.chains() # Only chains return (ranks, chains) + class ChowRingIdeal_nonaug(ChowRingIdeal): r""" The Chow ring ideal of a matroid `M`. @@ -116,8 +117,8 @@ def __init__(self, M, R): for X in self._matroid.flats(i)] names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in flats] try: - poly_ring = PolynomialRing(R, names) #self.ring - except ValueError: # variables are not proper names + poly_ring = PolynomialRing(R, names) # self.ring + except ValueError: # variables are not proper names poly_ring = PolynomialRing(R, 'A', len(flats)) gens = poly_ring.gens() self._flats_generator = dict(zip(flats, gens)) @@ -392,8 +393,8 @@ def __init__(self, M, R): try: names_groundset = ['A{}'.format(''.join(str(x))) for x in E] names_flats = ['B{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self._flats] - poly_ring = PolynomialRing(R, names_groundset + names_flats) #self.ring() - except ValueError: #variables are not proper names + poly_ring = PolynomialRing(R, names_groundset + names_flats) # self.ring() + except ValueError: # variables are not proper names poly_ring = PolynomialRing(R, 'A', len(E) + len(self._flats)) for i, x in enumerate(E): self._flats_generator[x] = poly_ring.gens()[i] @@ -526,7 +527,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs): for H in lattice_flats.order_filter([F]): term1 += self._flats_generator[H] if term1 != poly_ring.zero(): - gb.append(term1**(self._matroid.rank(F) + 1)) #5.6 (MM2022) + gb.append(term1**(self._matroid.rank(F) + 1)) # 5.6 (MM2022) order_ideal_modified = lattice_flats.order_ideal([F]) order_ideal_modified.remove(F) for G in order_ideal_modified: # nested flats @@ -643,8 +644,8 @@ def __init__(self, M, R): for X in self._matroid.flats(i)] names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self._flats] try: - poly_ring = PolynomialRing(R, names) #self.ring - except ValueError: # variables are not proper names + poly_ring = PolynomialRing(R, names) # self.ring + except ValueError: # variables are not proper names poly_ring = PolynomialRing(R, 'A', len(self._flats)) gens = poly_ring.gens() self._flats_generator = dict(zip(self._flats, gens)) @@ -797,4 +798,4 @@ def normal_basis(self, algorithm='', *args, **kwargs): for val, c in zip(subset, combination): expression *= flats_gen[val] ** c monomial_basis.append(expression) - return PolynomialSequence(R, [monomial_basis]) \ No newline at end of file + return PolynomialSequence(R, [monomial_basis]) diff --git a/src/sage/numerical/backends/logging_backend.py b/src/sage/numerical/backends/logging_backend.py index a7acf57341f..ae0c6b22d36 100644 --- a/src/sage/numerical/backends/logging_backend.py +++ b/src/sage/numerical/backends/logging_backend.py @@ -7,15 +7,15 @@ See :class:`LoggingBackendFactory` for more information. """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2016 Matthias Koeppe # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -# http://www.gnu.org/licenses/ -#***************************************************************************** +# https://www.gnu.org/licenses/ +# **************************************************************************** from sage.numerical.backends.generic_backend import GenericBackend @@ -31,7 +31,7 @@ def _format_function_call(fn_name, *v, **k): sage: _format_function_call('foo', 17, hellooooo='goodbyeeee') "foo(17, hellooooo='goodbyeeee')" """ - args = [ repr(a) for a in v ] + [ "%s=%r" % (arg,val) for arg, val in k.items() ] + args = [repr(a) for a in v] + ["%s=%r" % (arg, val) for arg, val in k.items()] return "{}({})".format(fn_name, ", ".join(args)) @@ -359,15 +359,15 @@ def LoggingBackendFactory(solver=None, printing=True, doctest_file=None, test_me # Construct output file name from method name. test_method_file = "test_{}.py".format(test_method) else: - test_method = 'CHANGE' # Will have to be edited by user in - # generated file. + test_method = 'CHANGE' + # Will have to be edited by user in generated file. if doctest_file is not None: - doctest = open(doctest_file, "w", 1) #line-buffered + doctest = open(doctest_file, "w", 1) # line-buffered else: doctest = None if test_method_file is not None: - test_method_output = open(test_method_file, "w", 1) #line-buffered + test_method_output = open(test_method_file, "w", 1) # line-buffered else: test_method_output = None diff --git a/src/sage/numerical/interactive_simplex_method.py b/src/sage/numerical/interactive_simplex_method.py index 24dd0ded920..e394224a3c9 100644 --- a/src/sage/numerical/interactive_simplex_method.py +++ b/src/sage/numerical/interactive_simplex_method.py @@ -1538,7 +1538,7 @@ def plot(self, *args, **kwds): result += line(level.vertices(), color='black', linestyle='--') result.set_axes_range(xmin, xmax, ymin, ymax) - result.axes_labels(FP.axes_labels()) #FIXME: should be preserved! + result.axes_labels(FP.axes_labels()) # FIXME: should be preserved! return result def plot_feasible_set(self, xmin=None, xmax=None, ymin=None, ymax=None, @@ -3933,7 +3933,7 @@ def _latex_(self): lines.append(r"\renewcommand{\arraystretch}{1.5} %notruncate") if generate_real_LaTeX: lines[-1] += r" \setlength{\arraycolsep}{0.125em}" - relations = [_latex_product(-Ai,N, head=[xi, "=", bi], + relations = [_latex_product(-Ai, N, head=[xi, "=", bi], drop_plus=False, allow_empty=True) + r"\\" for xi, bi, Ai in zip(B, b, A.rows())] objective = _latex_product(c, N, head=[z, "=", v], diff --git a/src/sage/plot/hyperbolic_regular_polygon.py b/src/sage/plot/hyperbolic_regular_polygon.py index 14e8bdcaf68..a6df71ebc11 100644 --- a/src/sage/plot/hyperbolic_regular_polygon.py +++ b/src/sage/plot/hyperbolic_regular_polygon.py @@ -141,9 +141,9 @@ def __init__(self, sides, i_angle, center, options): # real part of the given center. h_disp = self.center.real() - d_z_k = [z_0[0]*scale + h_disp] #d_k has the points for the polygon in the given center - z_k = z_0 #z_k has the Re(z)>0 vertices for the I centered polygon - r_z_k = [] #r_z_k has the Re(z)<0 vertices + d_z_k = [z_0[0]*scale + h_disp] # d_k has the points for the polygon in the given center + z_k = z_0 # z_k has the Re(z)>0 vertices for the I centered polygon + r_z_k = [] # r_z_k has the Re(z)<0 vertices if is_odd(self.sides): vert = (self.sides - 1) // 2 else: diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py index 3686840ccba..171fba9af6e 100644 --- a/src/sage/rings/number_field/number_field_ideal.py +++ b/src/sage/rings/number_field/number_field_ideal.py @@ -2170,17 +2170,18 @@ def reduce(self, f): M = MatrixSpace(ZZ,n)([R.coordinates(y) for y in self.basis()]) D = M.hermite_form() - d = [D[i,i] for i in range(n)] + d = [D[i, i] for i in range(n)] v = R.coordinates(f) for i in range(n): - q, r = ZZ(v[i]).quo_rem(d[i])#v is a vector of rationals, we want division of integers + q, r = ZZ(v[i]).quo_rem(d[i]) + # v is a vector of rationals, we want division of integers if 2*r > d[i]: q = q + 1 v = v - q*D[i] - return sum([v[i]*Rbasis[i] for i in range(n)]) + return sum([v[i] * Rbasis[i] for i in range(n)]) def residues(self): r""" diff --git a/src/sage/rings/padics/factory.py b/src/sage/rings/padics/factory.py index 44093d2cf67..a0990ad1720 100644 --- a/src/sage/rings/padics/factory.py +++ b/src/sage/rings/padics/factory.py @@ -3548,7 +3548,7 @@ def krasner_check(poly, prec): sage: krasner_check(1,2) # this is a stupid example. True """ - return True #This needs to be implemented + return True # This needs to be implemented def is_eisenstein(poly): diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py index 27ca55b274f..5b8c7468c75 100644 --- a/src/sage/rings/padics/generic_nodes.py +++ b/src/sage/rings/padics/generic_nodes.py @@ -257,7 +257,7 @@ def _test_additive_associativity(self, **options): tester = self._tester(**options) S = tester.some_elements() from sage.misc.misc import some_tuples - for x,y,z in some_tuples(S, 3, tester._max_runs): + for x, y, z in some_tuples(S, 3, tester._max_runs): tester.assertTrue(((x + y) + z).is_equal_to(x + (y + z), min(x.precision_absolute(), y.precision_absolute(), z.precision_absolute()))) @@ -265,7 +265,8 @@ class FloatingPointRingGeneric(FloatingPointGeneric): pass -class FloatingPointFieldGeneric(FloatingPointGeneric):#, sage.rings.ring.Field): +class FloatingPointFieldGeneric(FloatingPointGeneric): + # in category of Fields() pass @@ -273,7 +274,8 @@ class CappedRelativeRingGeneric(CappedRelativeGeneric): pass -class CappedRelativeFieldGeneric(CappedRelativeGeneric):#, sage.rings.ring.Field): +class CappedRelativeFieldGeneric(CappedRelativeGeneric): + # in category of Fields() pass diff --git a/src/sage/rings/padics/relative_extension_leaves.py b/src/sage/rings/padics/relative_extension_leaves.py index 3005ae0825b..b88aebf129a 100644 --- a/src/sage/rings/padics/relative_extension_leaves.py +++ b/src/sage/rings/padics/relative_extension_leaves.py @@ -378,7 +378,7 @@ def __init__(self, exact_modulus, approx_modulus, prec, print_mode, shift_seed, """ self._exact_modulus = exact_modulus unram_prec = (prec + approx_modulus.degree() - 1) // approx_modulus.degree() - KFP = approx_modulus.base_ring()#.change(field=False, show_prec=False) + KFP = approx_modulus.base_ring() # .change(field=False, show_prec=False) self.prime_pow = PowComputer_relative_maker(approx_modulus.base_ring().prime(), max(min(unram_prec - 1, 30), 1), unram_prec, prec, False, exact_modulus.change_ring(KFP), shift_seed.change_ring(KFP), 'floating-point') self._implementation = 'Polynomial' EisensteinExtensionGeneric.__init__(self, approx_modulus, prec, print_mode, names, RelativeRamifiedFloatingPointElement) @@ -416,7 +416,7 @@ def __init__(self, exact_modulus, approx_modulus, prec, print_mode, shift_seed, """ self._exact_modulus = exact_modulus unram_prec = (prec + approx_modulus.degree() - 1) // approx_modulus.degree() - KFP = approx_modulus.base_ring()#.change(field=False, show_prec=False) + KFP = approx_modulus.base_ring() # .change(field=False, show_prec=False) self.prime_pow = PowComputer_relative_maker(approx_modulus.base_ring().prime(), max(min(unram_prec - 1, 30), 1), unram_prec, prec, True, exact_modulus.change_ring(KFP), shift_seed.change_ring(KFP), 'floating-point') self._implementation = 'Polynomial' EisensteinExtensionGeneric.__init__(self, approx_modulus, prec, print_mode, names, RelativeRamifiedFloatingPointElement) diff --git a/src/sage/tensor/modules/comp.py b/src/sage/tensor/modules/comp.py index 32ac954c7b4..f52cdfb744b 100644 --- a/src/sage/tensor/modules/comp.py +++ b/src/sage/tensor/modules/comp.py @@ -1688,7 +1688,7 @@ def __sub__(self, other): """ if isinstance(other, (int, Integer)) and other == 0: return +self - return self + (-other) #!# correct, deals properly with + return self + (-other) # ! # correct, deals properly with # symmetries, but is probably not optimal def __rsub__(self, other): From 5518497049d5b038c74de95e9d166f90fe22b5e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sat, 14 Dec 2024 18:11:27 +0100 Subject: [PATCH 2/2] suggested detail + clean that file --- .../coding/guruswami_sudan/interpolation.py | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/sage/coding/guruswami_sudan/interpolation.py b/src/sage/coding/guruswami_sudan/interpolation.py index ae667c5dae1..3adc0ef1130 100644 --- a/src/sage/coding/guruswami_sudan/interpolation.py +++ b/src/sage/coding/guruswami_sudan/interpolation.py @@ -24,7 +24,7 @@ from sage.matrix.constructor import matrix from sage.misc.misc_c import prod -####################### Linear algebra system solving ############################### +# ###################### Linear algebra system solving ############################### def _flatten_once(lstlst): @@ -50,9 +50,9 @@ def _flatten_once(lstlst): for lst in lstlst: yield from lst -#************************************************************* +# ************************************************************* # Linear algebraic Interpolation algorithm, helper functions -#************************************************************* +# ************************************************************* def _monomial_list(maxdeg, l, wy): @@ -137,9 +137,9 @@ def eqs_affine(x0, y0): jhat = monomial[1] if ihat >= i and jhat >= j: icoeff = binomial(ihat, i) * x0**(ihat-i) \ - if ihat > i else 1 + if ihat > i else 1 jcoeff = binomial(jhat, j) * y0**(jhat-j) \ - if jhat > j else 1 + if jhat > j else 1 eq[monomial] = jcoeff * icoeff eqs.append([eq.get(monomial, 0) for monomial in monomials]) return eqs @@ -286,10 +286,10 @@ def gs_interpolation_linalg(points, tau, parameters, wy): # Construct the Q polynomial PF = M.base_ring()['x', 'y'] # make that ring a ring in x, y = PF.gens() - return sum([x**monomials[i][0] * y**monomials[i][1] * sol[i] - for i in range(len(monomials))]) + return sum([x**m[0] * y**m[1] * sol[i] + for i, m in enumerate(monomials)]) -####################### Lee-O'Sullivan's method ############################### +# ###################### Lee-O'Sullivan's method ############################### def lee_osullivan_module(points, parameters, wy): @@ -397,12 +397,11 @@ def gs_interpolation_lee_osullivan(points, tau, parameters, wy): from .utils import _degree_of_vector s, l = parameters[0], parameters[1] F = points[0][0].parent() - M = lee_osullivan_module(points, (s,l), wy) - shifts = [i * wy for i in range(0,l+1)] + M = lee_osullivan_module(points, (s, l), wy) + shifts = [i * wy for i in range(l + 1)] Mnew = M.reduced_form(shifts=shifts) # Construct Q as the element of the row with the lowest weighted degree Qlist = min(Mnew.rows(), key=lambda r: _degree_of_vector(r, shifts)) PFxy = F['x,y'] xx, yy = PFxy.gens() - Q = sum(yy**i * PFxy(Qlist[i]) for i in range(0,l+1)) - return Q + return sum(yy**i * PFxy(Qlist[i]) for i in range(l + 1))