Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identify implicit use of enumerate method #518

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions invesalius/gui/default_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ def __init__(self, parent):
(_("Export data"), exporter.TaskPanel),
(_("Navigation system"), navigator.TaskPanel)]

for i in range(len(tasks)):
(name, panel) = tasks[i]
for i, item in enumerate(tasks):
(name, panel) = item
# Create panel
item = fold_panel.AddFoldPanel("%d. %s"%(i+1, name),
collapsed=True,
Expand Down
20 changes: 10 additions & 10 deletions invesalius/gui/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3827,8 +3827,8 @@ def _init_gui(self):
if sys.platform != 'win32':
combo_surface_name.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
combo_surface_name.Bind(wx.EVT_COMBOBOX, self.OnComboName)
for n in range(len(self.proj.surface_dict)):
combo_surface_name.Insert(str(self.proj.surface_dict[n].name), n)
for n, item in enumerate(self.proj.surface_dict):
combo_surface_name.Insert(str(item.name), n)

self.combo_surface_name = combo_surface_name

Expand Down Expand Up @@ -4075,8 +4075,8 @@ def ErrorEstimation(self, surface, points):
subId = mutable(0)
d = mutable(0.0)
error = []
for i in range(len(points)):
cell_locator.FindClosestPoint(points[i], c, cellId, subId, d)
for i, item in enumerate(points):
cell_locator.FindClosestPoint(item, c, cellId, subId, d)
error.append(np.sqrt(float(d)))

return np.mean(error)
Expand Down Expand Up @@ -4163,8 +4163,8 @@ def OnICP(self, evt):
sourcePoints = np.array(self.point_coord)
sourcePoints_vtk = vtkPoints()

for i in range(len(sourcePoints)):
id0 = sourcePoints_vtk.InsertNextPoint(sourcePoints[i])
for i, item in enumerate(sourcePoints):
id0 = sourcePoints_vtk.InsertNextPoint(item)

source = vtkPolyData()
source.SetPoints(sourcePoints_vtk)
Expand Down Expand Up @@ -4323,8 +4323,8 @@ def _init_gui(self):
if sys.platform != 'win32':
combo_surface_name.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
combo_surface_name.Bind(wx.EVT_COMBOBOX, self.OnComboNameScalpSurface)
for n in range(len(self.proj.surface_dict)):
combo_surface_name.Insert(str(self.proj.surface_dict[n].name), n)
for n, item in enumerate(self.proj.surface_dict):
combo_surface_name.Insert(str(item.name), n)

txt_brain_surface = wx.StaticText(self, -1, _('Select the brain surface:'))

Expand All @@ -4334,8 +4334,8 @@ def _init_gui(self):
if sys.platform != 'win32':
combo_brain_surface_name.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
combo_brain_surface_name.Bind(wx.EVT_COMBOBOX, self.OnComboNameBrainSurface)
for n in range(len(self.proj.surface_dict)):
combo_brain_surface_name.Insert(str(self.proj.surface_dict[n].name), n)
for n, item in enumerate(self.proj.surface_dict):
combo_brain_surface_name.Insert(str(item.name), n)

init_surface = 0
combo_surface_name.SetSelection(init_surface)
Expand Down
12 changes: 6 additions & 6 deletions invesalius/gui/dicom_preview_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,12 +657,12 @@ def OnPreviewClick(self, evt):
self.first_selection = dicom_id
self.last_selection = dicom_id

for i in range(len(self.files)):
for i, item in enumerate(self.files):

if i == dicom_id:
self.files[i].selected = True
item.selected = True
else:
self.files[i].selected = False
item.selected = False


my_evt = SerieEvent(myEVT_CLICK_SLICE, self.GetId())
Expand All @@ -675,11 +675,11 @@ def OnPreviewClick(self, evt):
self.selected_panel.select_on = self.selected_panel is evt.GetEventObject()

if self.first_selection != self.last_selection:
for i in range(len(self.files)):
for i, item in enumerate(self.files):
if i >= self.first_selection and i <= self.last_selection:
self.files[i].selected = True
item.selected = True
else:
self.files[i].selected = False
item.selected = False

else:
self.selected_panel.Select()
Expand Down