Skip to content

Commit 1e705f9

Browse files
OWLouvain: Make pylint happy
1 parent 311c1cd commit 1e705f9

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

Orange/clustering/louvain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
77
"""
88

9-
import networkx as nx
109
import numpy as np
10+
import networkx as nx
1111
from community import best_partition
1212
from sklearn.neighbors import NearestNeighbors
1313

Orange/widgets/unsupervised/owlouvainclustering.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
from collections import deque
22
from concurrent.futures import Future # pylint: disable=unused-import
3-
from enum import Enum
3+
from types import SimpleNamespace as namespace
4+
from typing import Optional # pylint: disable=unused-import
45

5-
import networkx as nx # pylint: disable=unused-import
66
import numpy as np
7+
import networkx as nx # pylint: disable=unused-import
78
from AnyQt.QtCore import Qt, pyqtSignal as Signal, QObject
89
from AnyQt.QtWidgets import QSlider, QCheckBox, QWidget # pylint: disable=unused-import
9-
from types import SimpleNamespace as namespace
10-
from typing import Optional # pylint: disable=unused-import
1110

1211
from Orange.clustering.louvain import table_to_knn_graph, Louvain
1312
from Orange.data import Table, DiscreteVariable
@@ -23,7 +22,7 @@
2322

2423
try:
2524
from orangecontrib.network.network import Graph
26-
except:
25+
except ImportError:
2726
Graph = None
2827

2928

@@ -71,11 +70,11 @@ def start(self):
7170
self.on_cancel.emit()
7271
return
7372

74-
def __task_progress(percentage):
75-
current_progress = idx / num_tasks
73+
def __task_progress(percentage, index=idx):
74+
current_progress = index / num_tasks
7675
# How much progress can each task contribute to the total
7776
# work to be done
78-
task_percentage = len(self.__tasks) ** -1
77+
task_percentage = 1 / len(self.__tasks)
7978
# Convert the progress done by the task into the total
8079
# progress to the task
8180
relative_progress = task_percentage * percentage
@@ -88,7 +87,7 @@ def __task_progress(percentage):
8887
task_spec.task()
8988
self.__set_progress((idx + 1) / num_tasks)
9089

91-
except Exception as e:
90+
except Exception as e: # pylint: disable=broad-except
9291
self.on_exception.emit(e)
9392
return
9493

@@ -365,7 +364,7 @@ def send_report(self):
365364

366365

367366
if __name__ == '__main__':
368-
from AnyQt.QtWidgets import QApplication
367+
from AnyQt.QtWidgets import QApplication # pylint: disable=ungrouped-imports
369368
import sys
370369

371370
app = QApplication(sys.argv)

0 commit comments

Comments
 (0)