Skip to content

Commit b168755

Browse files
committed
simplify many range(0,n) to range(n)
1 parent 1be0a58 commit b168755

File tree

23 files changed

+60
-61
lines changed

23 files changed

+60
-61
lines changed

src/sage/calculus/desolvers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ def desolve_laplace(de, dvar, ics=None, ivar=None):
741741
# maxima("de:"+de._repr_()+"=0;")
742742
# if ics is not None:
743743
# d = len(ics)
744-
# for i in range(0,d-1):
744+
# for i in range(d-1):
745745
# ic = "atvalue(diff("+vars[1]+"("+vars[0]+"),"+str(vars[0])+","+str(i)+"),"+str(vars[0])+"="+str(ics[0])+","+str(ics[1+i])+")"
746746
# maxima(ic)
747747
#

src/sage/coding/grs_code.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@ def _polynomial_vanishing_at_alphas(self, PolRing):
15251525
"""
15261526
G = PolRing.one()
15271527
x = PolRing.gen()
1528-
for i in range(0, self.code().length()):
1528+
for i in range(self.code().length()):
15291529
G = G*(x-self.code().evaluation_points()[i])
15301530
return G
15311531

@@ -1612,11 +1612,10 @@ def _decode_to_code_and_message(self, r):
16121612
if n == C.dimension() or r in C:
16131613
return r, self.connected_encoder().unencode_nocheck(r)
16141614

1615-
points = [(alphas[i], r[i]/col_mults[i]) for i in
1616-
range(0, n)]
1615+
points = [(alphas[i], r[i]/col_mults[i]) for i in range(n)]
16171616
R = PolRing.lagrange_polynomial(points)
16181617

1619-
(Q1, Q0) = self._partial_xgcd(G, R, PolRing)
1618+
Q1, Q0 = self._partial_xgcd(G, R, PolRing)
16201619

16211620
h, rem = Q1.quo_rem(Q0)
16221621
if not rem.is_zero():

src/sage/coding/guruswami_sudan/gs_decoder.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -849,15 +849,15 @@ def decode_to_code(self, r):
849849
s = self.multiplicity()
850850
l = self.list_size()
851851
tau = self.decoding_radius()
852-
## SETUP INTERPOLATION PROBLEM
852+
# SETUP INTERPOLATION PROBLEM
853853
wy = k-1
854-
points = [(alphas[i], r[i]/colmults[i]) for i in range(0,len(alphas))]
855-
## SOLVE INTERPOLATION
854+
points = [(alphas[i], r[i]/colmults[i]) for i in range(len(alphas))]
855+
# SOLVE INTERPOLATION
856856
try:
857857
Q = self.interpolation_algorithm()(points, tau, (s,l), wy)
858858
except TypeError:
859859
raise ValueError("The provided interpolation algorithm has a wrong signature. See the documentation of `codes.decoders.GRSGuruswamiSudanDecoder.interpolation_algorithm()` for details")
860-
## EXAMINE THE FACTORS AND CONVERT TO CODEWORDS
860+
# EXAMINE THE FACTORS AND CONVERT TO CODEWORDS
861861
try:
862862
polynomials = self.rootfinding_algorithm()(Q, maxd=wy)
863863
except TypeError:

src/sage/coding/guruswami_sudan/interpolation.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,14 +342,15 @@ def lee_osullivan_module(points, parameters, wy):
342342
PF = F['x']
343343
x = PF.gens()[0]
344344
R = PF.lagrange_polynomial(points)
345-
G = prod(x - points[i][0] for i in range(0, len(points)))
345+
G = prod(x - points[i][0] for i in range(len(points)))
346346
PFy = PF['y']
347347
y = PFy.gens()[0]
348-
ybasis = [(y-R)**i * G**(s-i) for i in range(0, s+1)] \
349-
+ [y**(i-s) * (y-R)**s for i in range(s+1, l+1)]
348+
ybasis = [(y-R)**i * G**(s-i) for i in range(s + 1)] \
349+
+ [y**(i-s) * (y-R)**s for i in range(s + 1, l + 1)]
350350

351351
def pad(lst):
352352
return lst + [0]*(l+1-len(lst))
353+
353354
modbasis = [pad(yb.coefficients(sparse=False)) for yb in ybasis]
354355
return matrix(PF, modbasis)
355356

src/sage/crypto/mq/sr.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,8 +2248,8 @@ def shift_rows_matrix(self):
22482248
bs = r*c*e
22492249
shift_rows = matrix(k, bs, bs)
22502250
I = MatrixSpace(k, e, e)(1)
2251-
for x in range(0, c):
2252-
for y in range(0, r):
2251+
for x in range(c):
2252+
for y in range(r):
22532253
_r = ((x*r)+y) * e
22542254
_c = (((x*r)+((r+1)*y)) * e) % bs
22552255
self._insert_matrix_into_matrix(shift_rows, I, _r, _c)
@@ -2290,14 +2290,14 @@ def lin_matrix(self, length=None):
22902290
if e == 4:
22912291
l = [k.from_integer(x) for x in (5, 1, 12, 5)]
22922292
for k in range( 0, length ):
2293-
for i in range(0, 4):
2294-
for j in range(0, 4):
2293+
for i in range(4):
2294+
for j in range(4):
22952295
lin[k*4+j, k*4+i] = l[(i-j) % 4] ** (2**j)
22962296
elif e == 8:
22972297
l = [k.from_integer(x) for x in (5, 9, 249, 37, 244, 1, 181, 143)]
22982298
for k in range( 0, length ):
2299-
for i in range(0, 8):
2300-
for j in range(0, 8):
2299+
for i in range(8):
2300+
for j in range(8):
23012301
lin[k*8+j, k*8+i] = l[(i-j) % 8] ** (2**j)
23022302

23032303
return lin
@@ -2651,8 +2651,8 @@ def shift_rows_matrix(self):
26512651
k = self.k
26522652
bs = r*c
26532653
shift_rows = matrix(k, r*c, r*c)
2654-
for x in range(0, c):
2655-
for y in range(0, r):
2654+
for x in range(c):
2655+
for y in range(r):
26562656
_r = ((x*r)+y)
26572657
_c = ((x*r)+((r+1)*y)) % bs
26582658
shift_rows[_r, _c] = 1

src/sage/data_structures/stream.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3247,7 +3247,7 @@ def __init__(self, series, shift, minimal_valuation):
32473247
true order at initialization::
32483248
32493249
sage: f = Stream_function(fun, True, 0)
3250-
sage: [f[i] for i in range(0, 10)]
3250+
sage: [f[i] for i in range(10)]
32513251
[0, 1, 1, 0, 1, 0, 0, 0, 1, 0]
32523252
sage: f._cache
32533253
{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):
32573257
sage: s._approximate_order
32583258
3
32593259
sage: f = Stream_function(fun, False, 0)
3260-
sage: [f[i] for i in range(0, 10)]
3260+
sage: [f[i] for i in range(10)]
32613261
[0, 1, 1, 0, 1, 0, 0, 0, 1, 0]
32623262
sage: f._cache
32633263
[1, 1, 0, 1, 0, 0, 0, 1, 0]
@@ -3432,7 +3432,7 @@ def is_nonzero(self):
34323432
sage: from sage.data_structures.stream import Stream_function, Stream_truncated
34333433
sage: def fun(n): return 1 if ZZ(n).is_power_of(2) else 0
34343434
sage: f = Stream_function(fun, False, 0)
3435-
sage: [f[i] for i in range(0, 4)]
3435+
sage: [f[i] for i in range(4)]
34363436
[0, 1, 1, 0]
34373437
sage: f._cache
34383438
[1, 1, 0]
@@ -3445,7 +3445,7 @@ def is_nonzero(self):
34453445
True
34463446
34473447
sage: f = Stream_function(fun, True, 0)
3448-
sage: [f[i] for i in range(0, 4)]
3448+
sage: [f[i] for i in range(4)]
34493449
[0, 1, 1, 0]
34503450
sage: f._cache
34513451
{1: 1, 2: 1, 3: 0}

src/sage/dynamics/arithmetic_dynamics/affine_ds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ def multiplier(self, P, n, check=True):
800800
l = identity_matrix(FractionField(self.codomain().base_ring()), N, N)
801801
Q = P
802802
J = self.jacobian()
803-
for i in range(0, n):
803+
for i in range(n):
804804
R = self(Q)
805805
l = J(tuple(Q)) * l # chain rule matrix multiplication
806806
Q = R

src/sage/dynamics/arithmetic_dynamics/endPN_minimal_model.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,13 @@ def bCheck(c, v, p, b):
6666
sage: bCheck(11664*b^2 + 70227*b + 76059, 15/2, 3, b)
6767
-1
6868
"""
69-
val = (v+1).floor()
69+
val = (v + 1).floor()
7070
deg = c.degree()
7171
coeffs = c.coefficients(sparse=False)
7272
lcoeff = coeffs[deg]
7373
coeffs.remove(lcoeff)
74-
check1 = [(coeffs[i].valuation(p) - lcoeff.valuation(p))/(deg - i) for i in range(0,len(coeffs)) if coeffs[i] != 0]
74+
check1 = [(coeffs[i].valuation(p) - lcoeff.valuation(p))/(deg - i)
75+
for i in range(len(coeffs)) if coeffs[i] != 0]
7576
check2 = (val - lcoeff.valuation(p))/deg
7677
check1.append(check2)
7778
bval = min(check1)

src/sage/dynamics/arithmetic_dynamics/wehlerK3.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ def sigmaX(self, P, **kwds):
12001200
e = min(maxexp)
12011201

12021202
#Fix L and Q
1203-
for i in range(0,2):
1203+
for i in range(2):
12041204
while T[i].subs({w1:t1}) == 0:
12051205
T[i] = T[i]/t
12061206
T[i] = T[i].subs({w1:t1})
@@ -1435,7 +1435,8 @@ def sigmaY(self, P, **kwds):
14351435
-phi(self.Hpoly(0, 1, 2))]
14361436
maxexp = []
14371437

1438-
#Find highest exponent that we can divide out by to get a nonzero answer
1438+
# Find highest exponent that we can divide out by to get a
1439+
# nonzero answer
14391440
for i in range(2, len(T)):
14401441
e = 0
14411442
while (T[i]/t**e).subs({w1:t1}) == 0:
@@ -1444,7 +1445,7 @@ def sigmaY(self, P, **kwds):
14441445

14451446
e = min(maxexp)
14461447

1447-
for i in range(0, 2):
1448+
for i in range(2):
14481449
while T[i].subs({w1:t1}) == 0:
14491450
T[i] = T[i]/t
14501451
T[i] = T[i].subs({w1:t1})

src/sage/geometry/hyperplane_arrangement/library.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,8 @@ def Ish(self, n, K=QQ, names=None):
502502
A = H(*hyperplanes)
503503
x = polygen(QQ, 'x')
504504
charpoly = x * sum([(-1)**k * stirling_number2(n, n-k) *
505-
prod([(x - 1 - j) for j in range(k, n-1)]) for k in range(0, n)])
505+
prod([(x - 1 - j) for j in range(k, n-1)])
506+
for k in range(n)])
506507
A.characteristic_polynomial.set_cache(charpoly)
507508
return A
508509

0 commit comments

Comments
 (0)