Skip to content

Commit 68068ed

Browse files
author
Release Manager
committed
gh-40429: Remove unnecessary range start <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> Autofix with `ruff check . --select PIE808 --fix`. There are probably > 10k occurrences without the range start and 42 with 0 as the range start, so it's already favored to remove the range start for consistency ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #40429 Reported by: Trinh Quoc Anh Reviewer(s): Martin Rubey
2 parents 4a0950d + 9b6eeb8 commit 68068ed

File tree

23 files changed

+42
-42
lines changed

23 files changed

+42
-42
lines changed

src/sage/crypto/mq/sr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2289,13 +2289,13 @@ def lin_matrix(self, length=None):
22892289
lin = matrix(self.base_ring(), length*e, length*e)
22902290
if e == 4:
22912291
l = [k.from_integer(x) for x in (5, 1, 12, 5)]
2292-
for k in range( 0, length ):
2292+
for k in range(length):
22932293
for i in range(4):
22942294
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)]
2298-
for k in range( 0, length ):
2298+
for k in range(length):
22992299
for i in range(8):
23002300
for j in range(8):
23012301
lin[k*8+j, k*8+i] = l[(i-j) % 8] ** (2**j)

src/sage/graphs/generators/families.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3608,7 +3608,7 @@ def WindmillGraph(k, n):
36083608
slide = 1/sin(sector/4)
36093609

36103610
pos_dict = {}
3611-
for i in range(0, k):
3611+
for i in range(k):
36123612
x = float(cos(i*pi/(k-2)))
36133613
y = float(sin(i*pi/(k-2))) + slide
36143614
pos_dict[i] = (x, y)

src/sage/graphs/generic_graph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11859,7 +11859,7 @@ def random_vertex(self, **kwds):
1185911859
raise ValueError("cannot get a random vertex from the empty graph")
1186011860
from sage.misc.prandom import randint
1186111861
it = self.vertex_iterator(**kwds)
11862-
for i in range(0, randint(0, self.order() - 1)):
11862+
for i in range(randint(0, self.order() - 1)):
1186311863
next(it)
1186411864
return next(it)
1186511865

@@ -11941,7 +11941,7 @@ def random_edge(self, **kwds):
1194111941

1194211942
from sage.misc.prandom import randint
1194311943
it = self.edge_iterator(**kwds)
11944-
for i in range(0, randint(0, self.size() - 1)):
11944+
for i in range(randint(0, self.size() - 1)):
1194511945
next(it)
1194611946
return next(it)
1194711947

src/sage/groups/perm_gps/permgroup_named.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,10 +1026,10 @@ def __init__(self, n):
10261026
# Representation of x
10271027
# Four-cycles that will conjugate the generator a properly
10281028
x = [(i+1, (-i) % halfr + halfr + 1, (fourthr+i) % halfr + 1, (-fourthr-i) % halfr + halfr + 1)
1029-
for i in range(0, fourthr)]
1029+
for i in range(fourthr)]
10301030
# With an odd part, transpositions will conjugate the m-cycle to create inverse
10311031
if m > 1:
1032-
x += [(r+i+1, r+m-i) for i in range(0, (m-1)//2)]
1032+
x += [(r+i+1, r+m-i) for i in range((m-1)//2)]
10331033

10341034
PermutationGroup_generic.__init__(self, gens=[a, x])
10351035

src/sage/homology/chain_complex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ def _homology_generators_snf(self, d_in, d_out, d_out_rank):
13611361
(N, P, Q) = d_in_induced.smith_form()
13621362
all_divs = [0]*N.nrows()
13631363
non_triv = 0
1364-
for i in range(0, N.nrows()):
1364+
for i in range(N.nrows()):
13651365
if i >= N.ncols():
13661366
break
13671367
all_divs[i] = N[i][i]

src/sage/interacts/library.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ def trapezoid_integration(
12301230
))
12311231
elif output_form == 'table':
12321232
s = [['$i$', '$x_i$', '$f(x_i)$', '$m$', r'$m\cdot f(x_i)$']]
1233-
for i in range(0,n+1):
1233+
for i in range(n+1):
12341234
if i == 0 or i == n:
12351235
j = 1
12361236
else:
@@ -1343,7 +1343,7 @@ def parabola(a, b, c):
13431343
if output_form == 'traditional':
13441344
sum_formula_html = r"\frac{d}{3} \cdot \left[ f(x_0) + %s + f(x_{%s})\right]" % (
13451345
' + '.join(r"%s \cdot f(x_{%s})" % (i % 2 * (-2) + 4, i + 1)
1346-
for i in range(0,n-1)),
1346+
for i in range(n-1)),
13471347
n
13481348
)
13491349

src/sage/manifolds/differentiable/examples/symplectic_space.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def __init__(
155155
self._symplectic_form = SymplecticFormParal(
156156
self, symplectic_name, symplectic_latex_name
157157
)
158-
for i in range(0, dim_half):
158+
for i in range(dim_half):
159159
q_index = 2 * i + 1
160160
self._symplectic_form.set_comp()[q_index, q_index + 1] = -1
161161

src/sage/manifolds/differentiable/symplectic_form.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ def volume_form(self, contra: int = 0) -> TensorField:
535535
self._vol_form = vol_form
536536

537537
result = self._vol_form
538-
for k in range(0, contra):
538+
for k in range(contra):
539539
result = result.up(self, k)
540540
if contra > 1:
541541
# restoring the antisymmetry after the up operation:

src/sage/matroids/database_collections.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def AllMatroids(n, r=None, type='all'):
179179
raise ValueError("The rank needs to be specified for type '%s'" % type)
180180

181181
if r is None:
182-
rng = range(0, n + 1)
182+
rng = range(n + 1)
183183
else:
184184
rng = range(r, r + 1)
185185

src/sage/matroids/database_matroids.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,8 +2401,8 @@ def Psi(r, groundset=None):
24012401
24022402
[Oxl2011]_, p. 664.
24032403
"""
2404-
A = [f'a{i}' for i in range(0, r)]
2405-
B = [f'b{i}' for i in range(0, r)]
2404+
A = [f'a{i}' for i in range(r)]
2405+
B = [f'b{i}' for i in range(r)]
24062406
E = A + B
24072407

24082408
def generate_binary_strings(bit_count):
@@ -2419,7 +2419,7 @@ def genbin(n, bs=""):
24192419
return binary_strings
24202420

24212421
NSC = [] # nonspanning circuits
2422-
for i in range(0, r):
2422+
for i in range(r):
24232423
for k in range(1, r - 2):
24242424
I0 = [f'a{i}', f'b{i}']
24252425
IK = [f'a{(i + k) % r}', f'b{(i + k) % r}']

0 commit comments

Comments
 (0)