Skip to content

Commit

Permalink
Use _ for unused loop controll index
Browse files Browse the repository at this point in the history
  • Loading branch information
larsevj committed Aug 29, 2024
1 parent 8c11679 commit d530d59
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 21 deletions.
4 changes: 2 additions & 2 deletions python/resdata/geometry/geometry_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,15 +385,15 @@ def connectPolylines(polyline, target_polyline):
p0 = polyline[-1]
p1 = polyline[-2]
ray = GeometryTools.lineToRay(p1, p0)
for _index, p in GeometryTools.rayPolygonIntersections(
for _, p in GeometryTools.rayPolygonIntersections(
p0, ray, target_polyline
):
d_list.append((GeometryTools.distance(p0, p), [p0, p]))

p0 = polyline[0]
p1 = polyline[1]
ray = GeometryTools.lineToRay(p1, p0)
for _index, p in GeometryTools.rayPolygonIntersections(
for _, p in GeometryTools.rayPolygonIntersections(
p0, ray, target_polyline
):
d_list.append((GeometryTools.distance(p0, p), [p0, p]))
Expand Down
2 changes: 1 addition & 1 deletion python/resdata/grid/faults/fault.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def __sort_fault_lines(self):
perm_list.sort(key=lambda x: x[1])

fault_lines = []
for index, _d in perm_list:
for index, _ in perm_list:
fault_lines.append(self.__fault_lines[index])
self.__fault_lines = fault_lines

Expand Down
2 changes: 1 addition & 1 deletion python/resdata/grid/faults/fault_segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def pop_next(self, segment):

def print_content(self):
for d in self.__segment_map.values():
for _C, S in d.iteritems():
for _, S in d.iteritems():
print(S)


Expand Down
7 changes: 2 additions & 5 deletions python/resdata/util/test/resdata_test_runner.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import os

try:
from unittest2 import TestLoader, TextTestRunner
except ImportError:
from unittest import TestLoader, TextTestRunner
from unittest import TestLoader, TextTestRunner


class ResdataTestRunner(object):
Expand All @@ -19,7 +16,7 @@ def findTestsInDirectory(path, recursive=True, pattern="test*.py"):
loader = TestLoader()
test_suite = loader.discover(path, pattern=pattern)

for root, dirnames, _filenames in os.walk(path):
for root, dirnames, _ in os.walk(path):
for directory in dirnames:
test_suite.addTests(
ResdataTestRunner.findTestsInDirectory(
Expand Down
6 changes: 3 additions & 3 deletions python/tests/geometry_tests/test_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def test_create_new(self):

self.assertNotEqual(s, small)
idx = 0
for _i in range(nx):
for _j in range(ny):
for _ in range(nx):
for _ in range(ny):
s[idx] = small[idx]
idx += 1
self.assertEqual(s, small)
Expand Down Expand Up @@ -164,7 +164,7 @@ def test_ops(self):
def test_ops2(self):
s0 = Surface(self.surface_small)
surface_list = []
for _i in range(10):
for _ in range(10):
s = s0.copy()
for j in range(len(s)):
s[j] = random.random()
Expand Down
2 changes: 1 addition & 1 deletion python/tests/rd_tests/test_faults.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def test_iter(self):
faults = FaultCollection(self.grid, self.faults1, self.faults2)
self.assertEqual(7, len(faults))
c = 0
for _f in faults:
for _ in faults:
c += 1
self.assertEqual(c, len(faults))

Expand Down
7 changes: 2 additions & 5 deletions python/tests/rd_tests/test_grid_equinor.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#!/usr/bin/env python
import math

try:
from unittest2 import skipIf
except ImportError:
from unittest import skipIf
from unittest import skipIf

from cwrap import Prototype
from cwrap import open as copen
Expand Down Expand Up @@ -251,7 +248,7 @@ def test_boundingBox(self):
def test_num_active_large_memory(self):
case = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE")
vecList = []
for _i in range(12500):
for _ in range(12500):
vec = DoubleVector()
vec[81920] = 0
vecList.append(vec)
Expand Down
4 changes: 2 additions & 2 deletions python/tests/rd_tests/test_rd_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ def test_hash(self):
all_types.add(ResDataType(rd_type, elem_size))
self.assertEqual(index + 1, len(all_types))

for _index, (rd_type, elem_size) in enumerate(test_base):
for _, (rd_type, elem_size) in enumerate(test_base):
all_types.add(ResDataType(rd_type, elem_size))

for _index, rd_type in enumerate(get_const_size_types()):
for _, rd_type in enumerate(get_const_size_types()):
all_types.add(ResDataType(rd_type))

self.assertEqual(len(test_base), len(all_types))
2 changes: 1 addition & 1 deletion python/tests/util_tests/test_thread_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_pool_unbound_fail(self):
def test_fill_pool(self):
pool = ThreadPool(4)

for _index in range(10):
for _ in range(10):
pool.addTask(self.sleepTask, 2)

pool.nonBlockingStart()
Expand Down

0 comments on commit d530d59

Please sign in to comment.