From b1687553c2bfa27b36e6279025c69a6523e01a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Thu, 9 Jan 2025 21:32:34 +0100 Subject: [PATCH 1/2] simplify many range(0,n) to range(n) --- src/sage/calculus/desolvers.py | 2 +- src/sage/coding/grs_code.py | 7 +++---- src/sage/coding/guruswami_sudan/gs_decoder.py | 8 ++++---- src/sage/coding/guruswami_sudan/interpolation.py | 7 ++++--- src/sage/crypto/mq/sr.py | 16 ++++++++-------- src/sage/data_structures/stream.py | 8 ++++---- .../dynamics/arithmetic_dynamics/affine_ds.py | 2 +- .../arithmetic_dynamics/endPN_minimal_model.py | 5 +++-- .../dynamics/arithmetic_dynamics/wehlerK3.py | 7 ++++--- .../geometry/hyperplane_arrangement/library.py | 3 ++- src/sage/geometry/polyhedral_complex.py | 2 +- .../parametrized_surface3d.py | 4 ++-- src/sage/geometry/triangulation/base.pyx | 4 ++-- src/sage/interfaces/phc.py | 2 +- src/sage/interfaces/r.py | 2 +- src/sage/knots/knot.py | 2 +- src/sage/libs/mpmath/ext_impl.pyx | 4 ++-- src/sage/schemes/elliptic_curves/ell_point.py | 4 ++-- src/sage/structure/global_options.py | 8 ++++---- src/sage/tensor/modules/free_module_tensor.py | 4 ++-- src/sage/topology/delta_complex.py | 8 ++++---- src/sage/topology/simplicial_complex.py | 2 +- src/sage/topology/simplicial_complex_examples.py | 10 +++------- 23 files changed, 60 insertions(+), 61 deletions(-) diff --git a/src/sage/calculus/desolvers.py b/src/sage/calculus/desolvers.py index d17f5a14e90..6a8d8fbe2bb 100644 --- a/src/sage/calculus/desolvers.py +++ b/src/sage/calculus/desolvers.py @@ -741,7 +741,7 @@ def desolve_laplace(de, dvar, ics=None, ivar=None): # maxima("de:"+de._repr_()+"=0;") # if ics is not None: # d = len(ics) - # for i in range(0,d-1): + # for i in range(d-1): # ic = "atvalue(diff("+vars[1]+"("+vars[0]+"),"+str(vars[0])+","+str(i)+"),"+str(vars[0])+"="+str(ics[0])+","+str(ics[1+i])+")" # maxima(ic) # diff --git a/src/sage/coding/grs_code.py b/src/sage/coding/grs_code.py index a37a5b15a7b..aead68b0bb3 100644 --- a/src/sage/coding/grs_code.py +++ b/src/sage/coding/grs_code.py @@ -1525,7 +1525,7 @@ def _polynomial_vanishing_at_alphas(self, PolRing): """ G = PolRing.one() x = PolRing.gen() - for i in range(0, self.code().length()): + for i in range(self.code().length()): G = G*(x-self.code().evaluation_points()[i]) return G @@ -1612,11 +1612,10 @@ def _decode_to_code_and_message(self, r): if n == C.dimension() or r in C: return r, self.connected_encoder().unencode_nocheck(r) - points = [(alphas[i], r[i]/col_mults[i]) for i in - range(0, n)] + points = [(alphas[i], r[i]/col_mults[i]) for i in range(n)] R = PolRing.lagrange_polynomial(points) - (Q1, Q0) = self._partial_xgcd(G, R, PolRing) + Q1, Q0 = self._partial_xgcd(G, R, PolRing) h, rem = Q1.quo_rem(Q0) if not rem.is_zero(): diff --git a/src/sage/coding/guruswami_sudan/gs_decoder.py b/src/sage/coding/guruswami_sudan/gs_decoder.py index e909c3a0bf3..f3e194491d2 100644 --- a/src/sage/coding/guruswami_sudan/gs_decoder.py +++ b/src/sage/coding/guruswami_sudan/gs_decoder.py @@ -849,15 +849,15 @@ def decode_to_code(self, r): s = self.multiplicity() l = self.list_size() tau = self.decoding_radius() - ## SETUP INTERPOLATION PROBLEM + # SETUP INTERPOLATION PROBLEM wy = k-1 - points = [(alphas[i], r[i]/colmults[i]) for i in range(0,len(alphas))] - ## SOLVE INTERPOLATION + points = [(alphas[i], r[i]/colmults[i]) for i in range(len(alphas))] + # SOLVE INTERPOLATION try: Q = self.interpolation_algorithm()(points, tau, (s,l), wy) except TypeError: raise ValueError("The provided interpolation algorithm has a wrong signature. See the documentation of `codes.decoders.GRSGuruswamiSudanDecoder.interpolation_algorithm()` for details") - ## EXAMINE THE FACTORS AND CONVERT TO CODEWORDS + # EXAMINE THE FACTORS AND CONVERT TO CODEWORDS try: polynomials = self.rootfinding_algorithm()(Q, maxd=wy) except TypeError: diff --git a/src/sage/coding/guruswami_sudan/interpolation.py b/src/sage/coding/guruswami_sudan/interpolation.py index 3adc0ef1130..bfeb0efd2a9 100644 --- a/src/sage/coding/guruswami_sudan/interpolation.py +++ b/src/sage/coding/guruswami_sudan/interpolation.py @@ -342,14 +342,15 @@ def lee_osullivan_module(points, parameters, wy): PF = F['x'] x = PF.gens()[0] R = PF.lagrange_polynomial(points) - G = prod(x - points[i][0] for i in range(0, len(points))) + G = prod(x - points[i][0] for i in range(len(points))) PFy = PF['y'] y = PFy.gens()[0] - ybasis = [(y-R)**i * G**(s-i) for i in range(0, s+1)] \ - + [y**(i-s) * (y-R)**s for i in range(s+1, l+1)] + ybasis = [(y-R)**i * G**(s-i) for i in range(s + 1)] \ + + [y**(i-s) * (y-R)**s for i in range(s + 1, l + 1)] def pad(lst): return lst + [0]*(l+1-len(lst)) + modbasis = [pad(yb.coefficients(sparse=False)) for yb in ybasis] return matrix(PF, modbasis) diff --git a/src/sage/crypto/mq/sr.py b/src/sage/crypto/mq/sr.py index 610a97b05fb..c60202c6f23 100644 --- a/src/sage/crypto/mq/sr.py +++ b/src/sage/crypto/mq/sr.py @@ -2248,8 +2248,8 @@ def shift_rows_matrix(self): bs = r*c*e shift_rows = matrix(k, bs, bs) I = MatrixSpace(k, e, e)(1) - for x in range(0, c): - for y in range(0, r): + for x in range(c): + for y in range(r): _r = ((x*r)+y) * e _c = (((x*r)+((r+1)*y)) * e) % bs self._insert_matrix_into_matrix(shift_rows, I, _r, _c) @@ -2290,14 +2290,14 @@ def lin_matrix(self, length=None): if e == 4: l = [k.from_integer(x) for x in (5, 1, 12, 5)] for k in range( 0, length ): - for i in range(0, 4): - for j in range(0, 4): + for i in range(4): + for j in range(4): lin[k*4+j, k*4+i] = l[(i-j) % 4] ** (2**j) elif e == 8: l = [k.from_integer(x) for x in (5, 9, 249, 37, 244, 1, 181, 143)] for k in range( 0, length ): - for i in range(0, 8): - for j in range(0, 8): + for i in range(8): + for j in range(8): lin[k*8+j, k*8+i] = l[(i-j) % 8] ** (2**j) return lin @@ -2651,8 +2651,8 @@ def shift_rows_matrix(self): k = self.k bs = r*c shift_rows = matrix(k, r*c, r*c) - for x in range(0, c): - for y in range(0, r): + for x in range(c): + for y in range(r): _r = ((x*r)+y) _c = ((x*r)+((r+1)*y)) % bs shift_rows[_r, _c] = 1 diff --git a/src/sage/data_structures/stream.py b/src/sage/data_structures/stream.py index ddca8fb26b2..eade622907f 100644 --- a/src/sage/data_structures/stream.py +++ b/src/sage/data_structures/stream.py @@ -3247,7 +3247,7 @@ def __init__(self, series, shift, minimal_valuation): true order at initialization:: sage: f = Stream_function(fun, True, 0) - sage: [f[i] for i in range(0, 10)] + sage: [f[i] for i in range(10)] [0, 1, 1, 0, 1, 0, 0, 0, 1, 0] sage: f._cache {1: 1, 2: 1, 3: 0, 4: 1, 5: 0, 6: 0, 7: 0, 8: 1, 9: 0} @@ -3257,7 +3257,7 @@ def __init__(self, series, shift, minimal_valuation): sage: s._approximate_order 3 sage: f = Stream_function(fun, False, 0) - sage: [f[i] for i in range(0, 10)] + sage: [f[i] for i in range(10)] [0, 1, 1, 0, 1, 0, 0, 0, 1, 0] sage: f._cache [1, 1, 0, 1, 0, 0, 0, 1, 0] @@ -3432,7 +3432,7 @@ def is_nonzero(self): sage: from sage.data_structures.stream import Stream_function, Stream_truncated sage: def fun(n): return 1 if ZZ(n).is_power_of(2) else 0 sage: f = Stream_function(fun, False, 0) - sage: [f[i] for i in range(0, 4)] + sage: [f[i] for i in range(4)] [0, 1, 1, 0] sage: f._cache [1, 1, 0] @@ -3445,7 +3445,7 @@ def is_nonzero(self): True sage: f = Stream_function(fun, True, 0) - sage: [f[i] for i in range(0, 4)] + sage: [f[i] for i in range(4)] [0, 1, 1, 0] sage: f._cache {1: 1, 2: 1, 3: 0} diff --git a/src/sage/dynamics/arithmetic_dynamics/affine_ds.py b/src/sage/dynamics/arithmetic_dynamics/affine_ds.py index ecf61822ba9..c9d9a0e5403 100644 --- a/src/sage/dynamics/arithmetic_dynamics/affine_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/affine_ds.py @@ -800,7 +800,7 @@ def multiplier(self, P, n, check=True): l = identity_matrix(FractionField(self.codomain().base_ring()), N, N) Q = P J = self.jacobian() - for i in range(0, n): + for i in range(n): R = self(Q) l = J(tuple(Q)) * l # chain rule matrix multiplication Q = R diff --git a/src/sage/dynamics/arithmetic_dynamics/endPN_minimal_model.py b/src/sage/dynamics/arithmetic_dynamics/endPN_minimal_model.py index 902f83b55ae..ccd2041d1ca 100644 --- a/src/sage/dynamics/arithmetic_dynamics/endPN_minimal_model.py +++ b/src/sage/dynamics/arithmetic_dynamics/endPN_minimal_model.py @@ -66,12 +66,13 @@ def bCheck(c, v, p, b): sage: bCheck(11664*b^2 + 70227*b + 76059, 15/2, 3, b) -1 """ - val = (v+1).floor() + val = (v + 1).floor() deg = c.degree() coeffs = c.coefficients(sparse=False) lcoeff = coeffs[deg] coeffs.remove(lcoeff) - check1 = [(coeffs[i].valuation(p) - lcoeff.valuation(p))/(deg - i) for i in range(0,len(coeffs)) if coeffs[i] != 0] + check1 = [(coeffs[i].valuation(p) - lcoeff.valuation(p))/(deg - i) + for i in range(len(coeffs)) if coeffs[i] != 0] check2 = (val - lcoeff.valuation(p))/deg check1.append(check2) bval = min(check1) diff --git a/src/sage/dynamics/arithmetic_dynamics/wehlerK3.py b/src/sage/dynamics/arithmetic_dynamics/wehlerK3.py index 766dff990e0..0a1a5ba1526 100644 --- a/src/sage/dynamics/arithmetic_dynamics/wehlerK3.py +++ b/src/sage/dynamics/arithmetic_dynamics/wehlerK3.py @@ -1200,7 +1200,7 @@ def sigmaX(self, P, **kwds): e = min(maxexp) #Fix L and Q - for i in range(0,2): + for i in range(2): while T[i].subs({w1:t1}) == 0: T[i] = T[i]/t T[i] = T[i].subs({w1:t1}) @@ -1435,7 +1435,8 @@ def sigmaY(self, P, **kwds): -phi(self.Hpoly(0, 1, 2))] maxexp = [] - #Find highest exponent that we can divide out by to get a nonzero answer + # Find highest exponent that we can divide out by to get a + # nonzero answer for i in range(2, len(T)): e = 0 while (T[i]/t**e).subs({w1:t1}) == 0: @@ -1444,7 +1445,7 @@ def sigmaY(self, P, **kwds): e = min(maxexp) - for i in range(0, 2): + for i in range(2): while T[i].subs({w1:t1}) == 0: T[i] = T[i]/t T[i] = T[i].subs({w1:t1}) diff --git a/src/sage/geometry/hyperplane_arrangement/library.py b/src/sage/geometry/hyperplane_arrangement/library.py index 9e2ca3336f6..2c731eba212 100644 --- a/src/sage/geometry/hyperplane_arrangement/library.py +++ b/src/sage/geometry/hyperplane_arrangement/library.py @@ -502,7 +502,8 @@ def Ish(self, n, K=QQ, names=None): A = H(*hyperplanes) x = polygen(QQ, 'x') charpoly = x * sum([(-1)**k * stirling_number2(n, n-k) * - prod([(x - 1 - j) for j in range(k, n-1)]) for k in range(0, n)]) + prod([(x - 1 - j) for j in range(k, n-1)]) + for k in range(n)]) A.characteristic_polynomial.set_cache(charpoly) return A diff --git a/src/sage/geometry/polyhedral_complex.py b/src/sage/geometry/polyhedral_complex.py index 0dc45748578..fa4aab394d4 100644 --- a/src/sage/geometry/polyhedral_complex.py +++ b/src/sage/geometry/polyhedral_complex.py @@ -412,7 +412,7 @@ def cell_iterator(self, increasing=True): 11 """ cells = self.cells() - dim_index = range(0, self.dimension() + 1) + dim_index = range(self.dimension() + 1) if not increasing: dim_index = reversed(dim_index) for d in dim_index: diff --git a/src/sage/geometry/riemannian_manifolds/parametrized_surface3d.py b/src/sage/geometry/riemannian_manifolds/parametrized_surface3d.py index 17fb5028df1..308a151fad3 100644 --- a/src/sage/geometry/riemannian_manifolds/parametrized_surface3d.py +++ b/src/sage/geometry/riemannian_manifolds/parametrized_surface3d.py @@ -276,11 +276,11 @@ class ParametrizedSurface3D(SageObject): sage: cc_array = [(ccc - K_min)/(K_max - K_min) for ccc in K_array] sage: points_array = [ellipsoid_equation(u_array[counter][0], ....: u_array[counter][1]) - ....: for counter in range(0,len(u_array))] + ....: for counter in range(len(u_array))] sage: curvature_ellipsoid_plot = sum(point([xx # needs sage.plot ....: for xx in points_array[counter]], ....: color=hue(cc_array[counter]/2)) - ....: for counter in range(0,len(u_array))) + ....: for counter in range(len(u_array))) sage: curvature_ellipsoid_plot.show(aspect_ratio=1) # needs sage.plot We can find the principal curvatures and principal directions of the diff --git a/src/sage/geometry/triangulation/base.pyx b/src/sage/geometry/triangulation/base.pyx index 55144d1623c..3bbbaddef6b 100644 --- a/src/sage/geometry/triangulation/base.pyx +++ b/src/sage/geometry/triangulation/base.pyx @@ -595,13 +595,13 @@ cdef class PointConfiguration_base(Parent): EXAMPLES:: sage: p = PointConfiguration([[1,0], [2,3], [3,2]]) - sage: [ p[i] for i in range(0,p.n_points()) ] + sage: [p[i] for i in range(p.n_points())] [P(1, 0), P(2, 3), P(3, 2)] sage: list(p) [P(1, 0), P(2, 3), P(3, 2)] sage: list(p.points()) [P(1, 0), P(2, 3), P(3, 2)] - sage: [ p.point(i) for i in range(0,p.n_points()) ] + sage: [p.point(i) for i in range(p.n_points())] [P(1, 0), P(2, 3), P(3, 2)] """ return self._pts[i] diff --git a/src/sage/interfaces/phc.py b/src/sage/interfaces/phc.py index 3aa5964352b..d687d456eaf 100644 --- a/src/sage/interfaces/phc.py +++ b/src/sage/interfaces/phc.py @@ -567,7 +567,7 @@ def _parse_path_file(self, input_filename, verbose=False): t_val = CC(m.group(2), m.group(3)) temp_dict = {} temp_dict["t"] = t_val - for i in range(0, count): + for i in range(count): a_line = fh.readline() m = sols_regex.match(a_line) if m: diff --git a/src/sage/interfaces/r.py b/src/sage/interfaces/r.py index b44fe1381ff..6bf0ddc6ab7 100644 --- a/src/sage/interfaces/r.py +++ b/src/sage/interfaces/r.py @@ -894,7 +894,7 @@ def available_packages(self): # The following was more structural, but breaks on my machine. (stein) # p = p._sage_() # s = p['_Dim'][0] - # l = [[p['DATA'][i],p['DATA'][s+1+i]] for i in range(0,s)] + # l = [[p['DATA'][i],p['DATA'][s+1+i]] for i in range(s)] # return l def _object_class(self): diff --git a/src/sage/knots/knot.py b/src/sage/knots/knot.py index 607c73085aa..d8c688b3c32 100644 --- a/src/sage/knots/knot.py +++ b/src/sage/knots/knot.py @@ -292,7 +292,7 @@ def dt_code(self): crossing = i break if not string_found: - for i in range(0, crossing): + for i in range(crossing): if abs(b[i]) == string or abs(b[i]) == string - 1: string_found = True crossing = i diff --git a/src/sage/libs/mpmath/ext_impl.pyx b/src/sage/libs/mpmath/ext_impl.pyx index fdbbfa80a3a..8996d6296cf 100644 --- a/src/sage/libs/mpmath/ext_impl.pyx +++ b/src/sage/libs/mpmath/ext_impl.pyx @@ -2116,7 +2116,7 @@ cdef MPF_hypsum(MPF *a, MPF *b, int p, int q, param_types, str ztype, coeffs, z, raise ZeroDivisionError # Multiply real factors - for k in range(0, cancellable_real): + for k in range(cancellable_real): sig_check() mpz_mul(PRE, PRE, AREAL[k]) mpz_fdiv_q(PRE, PRE, BREAL[k]) @@ -2129,7 +2129,7 @@ cdef MPF_hypsum(MPF *a, MPF *b, int p, int q, param_types, str ztype, coeffs, z, mpz_mul_2exp(PRE, PRE, wp) mpz_fdiv_q(PRE, PRE, BREAL[k]) if have_complex: - for k in range(0, cancellable_real): + for k in range(cancellable_real): sig_check() mpz_mul(PIM, PIM, AREAL[k]) mpz_fdiv_q(PIM, PIM, BREAL[k]) diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py index d05196240a1..395735d469a 100644 --- a/src/sage/schemes/elliptic_curves/ell_point.py +++ b/src/sage/schemes/elliptic_curves/ell_point.py @@ -4604,8 +4604,8 @@ def padic_elliptic_logarithm(self, Q, p): if Q.is_zero(): k = 0 else: - for k in range(0,p): - Eqp = EllipticCurve(Qp(p, 2), [ ZZ(t) + k * p for t in E.a_invariants() ]) + for k in range(p): + Eqp = EllipticCurve(Qp(p, 2), [ZZ(t) + k * p for t in E.a_invariants()]) P_Qps = Eqp.lift_x(ZZ(self.x()), all=True) for P_Qp in P_Qps: diff --git a/src/sage/structure/global_options.py b/src/sage/structure/global_options.py index cbf08174532..d27bda16658 100644 --- a/src/sage/structure/global_options.py +++ b/src/sage/structure/global_options.py @@ -130,7 +130,7 @@ ....: cake='waist begins again', ....: cream='fluffy, white stuff')) ....: tip = dict(default=10, description='Reward for good service', - ....: checker = lambda tip: tip in range(0,20)) + ....: checker = lambda tip: tip in range(20)) sage: Menu.options Current options for menu - dessert: espresso @@ -409,7 +409,7 @@ class options(GlobalOptions): ....: cake='waist begins again', ....: cream='fluffy, white stuff')), ....: tip=dict(default=10, description='Reward for good service', - ....: checker=lambda tip: tip in range(0,20)) + ....: checker=lambda tip: tip in range(20)) ....: ) sage: Menu.options Current options for menu @@ -908,7 +908,7 @@ class GlobalOptions(metaclass=GlobalOptionsMeta): ....: cake='waist begins again', ....: cream='fluffy white stuff')) ....: tip = dict(default=10, description='Reward for good service', - ....: checker=lambda tip: tip in range(0,20)) + ....: checker=lambda tip: tip in range(20)) sage: Menu.options Current options for menu - dessert: espresso @@ -1013,7 +1013,7 @@ def __init__(self, NAME=None, module='', option_class='', doc='', end_doc='', ** ....: cake='waist begins again', ....: cream='fluffy white stuff')) ....: tip = dict(default=10, description='Reward for good service', - ....: checker=lambda tip: tip in range(0,20)) + ....: checker=lambda tip: tip in range(20)) sage: menu._name # Default name is class name 'menu' sage: class specials(GlobalOptions): diff --git a/src/sage/tensor/modules/free_module_tensor.py b/src/sage/tensor/modules/free_module_tensor.py index 94974e6059b..19c42c53081 100644 --- a/src/sage/tensor/modules/free_module_tensor.py +++ b/src/sage/tensor/modules/free_module_tensor.py @@ -2801,12 +2801,12 @@ def contract(self, *args): # nb_cov_s = 0 # Number of covariant indices of self not involved in the # contraction - for pos in range(k1,k1+l1): + for pos in range(k1, k1 + l1): if pos not in pos1: nb_cov_s += 1 nb_con_o = 0 # Number of contravariant indices of other not involved # in the contraction - for pos in range(0,k2): + for pos in range(k2): if pos not in pos2: nb_con_o += 1 if nb_cov_s != 0 and nb_con_o != 0: diff --git a/src/sage/topology/delta_complex.py b/src/sage/topology/delta_complex.py index b9ce4d5fb62..338a6008931 100644 --- a/src/sage/topology/delta_complex.py +++ b/src/sage/topology/delta_complex.py @@ -304,7 +304,7 @@ def store_bdry(simplex, faces): # else a dictionary indexed by simplices dimension = max([f.dimension() for f in data]) old_data_by_dim = {} - for dim in range(0, dimension+1): + for dim in range(dimension + 1): old_data_by_dim[dim] = [] new_data[dim] = [] for x in data: @@ -466,7 +466,7 @@ def subcomplex(self, data): new_dict[d+1].append(tuple([translate[n] for n in f])) new_dict[d].append(cells[d][x]) cells_to_add.update(cells[d][x]) - new_cells = [new_dict[n] for n in range(0, max_dim+1)] + new_cells = [new_dict[n] for n in range(max_dim + 1)] sub = DeltaComplex(new_cells) sub._is_subcomplex_of = {self: new_data} return sub @@ -564,7 +564,7 @@ def cells(self, subcomplex=None): raise ValueError("this is not a subcomplex of self") else: subcomplex_cells = subcomplex._is_subcomplex_of[self] - for d in range(0, max(subcomplex_cells.keys())+1): + for d in range(max(subcomplex_cells.keys()) + 1): L = list(cells[d]) for c in subcomplex_cells[d]: L[c] = None @@ -1303,7 +1303,7 @@ def elementary_subdivision(self, idx=-1): # added_cells: dict indexed by (n-1)-cells, with value the # corresponding new n-cell. added_cells = {(): len(cells_dict[0])-1} - for n in range(0, dim): + for n in range(dim): new_cells = {} # for each n-cell in the standard simplex, add an # (n+1)-cell to the subdivided complex. diff --git a/src/sage/topology/simplicial_complex.py b/src/sage/topology/simplicial_complex.py index 54166cf4f1f..ac0af5dcd7b 100644 --- a/src/sage/topology/simplicial_complex.py +++ b/src/sage/topology/simplicial_complex.py @@ -1477,7 +1477,7 @@ def h_vector(self): d = self.dimension() f = self.f_vector() # indexed starting at 0, since it's a Python list h = [] - for j in range(0, d + 2): + for j in range(d + 2): s = 0 for i in range(-1, j): s += (-1)**(j-i-1) * binomial(d-i, j-i-1) * f[i+1] diff --git a/src/sage/topology/simplicial_complex_examples.py b/src/sage/topology/simplicial_complex_examples.py index 97958848bb0..99b8202777b 100644 --- a/src/sage/topology/simplicial_complex_examples.py +++ b/src/sage/topology/simplicial_complex_examples.py @@ -839,17 +839,13 @@ def RealProjectiveSpace(n): name='Minimal triangulation of RP^4') if n >= 5: # Use the construction given by Datta in Example 3.21. - V = set(range(0, n+2)) + V = set(range(n + 2)) S = Sphere(n).barycentric_subdivision() X = S.facets() facets = set() for f in X: - new = [] - for v in f: - if 0 in v: - new.append(tuple(V.difference(v))) - else: - new.append(v) + new = [tuple(V.difference(v)) if 0 in V else v + for v in f] facets.add(tuple(new)) return UniqueSimplicialComplex(list(facets), name='Triangulation of RP^{}'.format(n)) From 257e3d9193cdd0aed1f9b73d7f0f0fc0457afa20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 10 Jan 2025 08:26:27 +0100 Subject: [PATCH 2/2] undo change --- src/sage/topology/simplicial_complex_examples.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/sage/topology/simplicial_complex_examples.py b/src/sage/topology/simplicial_complex_examples.py index 99b8202777b..97958848bb0 100644 --- a/src/sage/topology/simplicial_complex_examples.py +++ b/src/sage/topology/simplicial_complex_examples.py @@ -839,13 +839,17 @@ def RealProjectiveSpace(n): name='Minimal triangulation of RP^4') if n >= 5: # Use the construction given by Datta in Example 3.21. - V = set(range(n + 2)) + V = set(range(0, n+2)) S = Sphere(n).barycentric_subdivision() X = S.facets() facets = set() for f in X: - new = [tuple(V.difference(v)) if 0 in V else v - for v in f] + new = [] + for v in f: + if 0 in v: + new.append(tuple(V.difference(v))) + else: + new.append(v) facets.add(tuple(new)) return UniqueSimplicialComplex(list(facets), name='Triangulation of RP^{}'.format(n))