Skip to content

Commit 961d0b6

Browse files
MAINT: apply ruff/flake8-simplify rule SIM113
SIM113 Use `enumerate()` for index variable in `for` loop
1 parent 286606c commit 961d0b6

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

numpy/_core/code_generators/generate_umath.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,10 +1376,9 @@ def make_arrays(funcdict):
13761376
funclist = []
13771377
datalist = []
13781378
siglist = []
1379-
k = 0
13801379
sub = 0
13811380

1382-
for t in uf.type_descriptions:
1381+
for k, t in enumerate(uf.type_descriptions):
13831382
cfunc_alias = t.cfunc_alias if t.cfunc_alias else name
13841383
cfunc_fname = None
13851384
if t.func_data is FullTypeDescr:
@@ -1439,8 +1438,6 @@ def make_arrays(funcdict):
14391438
for x in t.in_ + t.out:
14401439
siglist.append('NPY_%s' % (english_upper(chartoname[x]),))
14411440

1442-
k += 1
1443-
14441441
if funclist or siglist or datalist:
14451442
funcnames = ', '.join(funclist)
14461443
signames = ', '.join(siglist)

numpy/matrixlib/defmatrix.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ def _convert_from_string(data):
1818

1919
rows = data.split(';')
2020
newdata = []
21-
count = 0
22-
for row in rows:
21+
for count, row in enumerate(rows):
2322
trow = row.split(',')
2423
newrow = []
2524
for col in trow:
@@ -29,7 +28,6 @@ def _convert_from_string(data):
2928
Ncols = len(newrow)
3029
elif len(newrow) != Ncols:
3130
raise ValueError("Rows not the same size.")
32-
count += 1
3331
newdata.append(newrow)
3432
return newdata
3533

0 commit comments

Comments
 (0)