Skip to content

Commit b20aa02

Browse files
OwLouvain: Use double quotes consistently
1 parent ec0ac1e commit b20aa02

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

Orange/widgets/unsupervised/owlouvainclustering.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,26 @@
4040
_DEFAULT_K_NEIGHBORS = 30
4141

4242

43-
METRICS = [('Euclidean', 'l2'), ('Manhattan', 'l1')]
43+
METRICS = [("Euclidean", "l2"), ("Manhattan", "l1")]
4444

4545

4646
class OWLouvainClustering(widget.OWWidget):
47-
name = 'Louvain Clustering'
48-
description = 'Detects communities in a network of nearest neighbors.'
49-
icon = 'icons/LouvainClustering.svg'
47+
name = "Louvain Clustering"
48+
description = "Detects communities in a network of nearest neighbors."
49+
icon = "icons/LouvainClustering.svg"
5050
priority = 2110
5151

5252
want_main_area = False
5353

5454
settingsHandler = DomainContextHandler()
5555

5656
class Inputs:
57-
data = Input('Data', Table, default=True)
57+
data = Input("Data", Table, default=True)
5858

5959
if Graph is not None:
6060
class Outputs:
6161
annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Table, default=True)
62-
graph = Output('Network', Graph)
62+
graph = Output("Network", Graph)
6363
else:
6464
class Outputs:
6565
annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Table, default=True)
@@ -75,8 +75,8 @@ class Information(widget.OWWidget.Information):
7575
modified = Msg("Press commit to recompute clusters and send new data")
7676

7777
class Error(widget.OWWidget.Error):
78-
empty_dataset = Msg('No features in data')
79-
general_error = Msg('Error occured during clustering\n{}')
78+
empty_dataset = Msg("No features in data")
79+
general_error = Msg("Error occured during clustering\n{}")
8080

8181
def __init__(self):
8282
super().__init__()
@@ -98,40 +98,40 @@ def __init__(self):
9898
self.__commit_timer = QTimer(self, singleShot=True)
9999
self.__commit_timer.timeout.connect(self.commit)
100100

101-
pca_box = gui.vBox(self.controlArea, 'PCA Preprocessing')
101+
pca_box = gui.vBox(self.controlArea, "PCA Preprocessing")
102102
self.apply_pca_cbx = gui.checkBox(
103-
pca_box, self, 'apply_pca', label='Apply PCA preprocessing',
103+
pca_box, self, "apply_pca", label="Apply PCA preprocessing",
104104
callback=self._invalidate_graph,
105105
) # type: QCheckBox
106106
self.pca_components_slider = gui.hSlider(
107-
pca_box, self, 'pca_components', label='Components: ', minValue=2,
107+
pca_box, self, "pca_components", label="Components: ", minValue=2,
108108
maxValue=_MAX_PCA_COMPONENTS,
109109
callback=self._invalidate_pca_projection, tracking=False
110110
) # type: QSlider
111111

112-
graph_box = gui.vBox(self.controlArea, 'Graph parameters')
112+
graph_box = gui.vBox(self.controlArea, "Graph parameters")
113113
self.metric_combo = gui.comboBox(
114-
graph_box, self, 'metric_idx', label='Distance metric',
114+
graph_box, self, "metric_idx", label="Distance metric",
115115
items=[m[0] for m in METRICS], callback=self._invalidate_graph,
116116
orientation=Qt.Horizontal,
117117
) # type: gui.OrangeComboBox
118118
self.k_neighbors_spin = gui.spin(
119-
graph_box, self, 'k_neighbors', minv=1, maxv=_MAX_K_NEIGBOURS,
120-
label='k neighbors', controlWidth=80, alignment=Qt.AlignRight,
119+
graph_box, self, "k_neighbors", minv=1, maxv=_MAX_K_NEIGBOURS,
120+
label="k neighbors", controlWidth=80, alignment=Qt.AlignRight,
121121
callback=self._invalidate_graph,
122122
) # type: gui.SpinBoxWFocusOut
123123
self.resolution_spin = gui.hSlider(
124-
graph_box, self, 'resolution', minValue=0, maxValue=5., step=1e-1,
125-
label='Resolution', intOnly=False, labelFormat='%.1f',
124+
graph_box, self, "resolution", minValue=0, maxValue=5., step=1e-1,
125+
label="Resolution", intOnly=False, labelFormat="%.1f",
126126
callback=self._invalidate_partition, tracking=False,
127127
) # type: QSlider
128128
self.resolution_spin.parent().setToolTip(
129-
'The resolution parameter affects the number of clusters to find. '
130-
'Smaller values tend to produce more clusters and larger values '
131-
'retrieve less clusters.'
129+
"The resolution parameter affects the number of clusters to find. "
130+
"Smaller values tend to produce more clusters and larger values "
131+
"retrieve less clusters."
132132
)
133133
self.apply_button = gui.auto_commit(
134-
self.controlArea, self, 'auto_commit', 'Apply', box=None,
134+
self.controlArea, self, "auto_commit", "Apply", box=None,
135135
commit=lambda: self.commit(),
136136
callback=lambda: self._on_auto_commit_changed(),
137137
) # type: QWidget
@@ -269,7 +269,7 @@ def __set_partial_results(self, result):
269269

270270
@Slot(object)
271271
def __on_done(self, future):
272-
# type: (Future['Results']) -> None
272+
# type: (Future["Results"]) -> None
273273
assert future.done()
274274
assert self.__task is not None
275275
assert self.__task.future is future
@@ -330,7 +330,7 @@ def __cancel_task(self, wait=True):
330330
w.done.connect(state.deleteLater)
331331

332332
def __set_results(self, results):
333-
# type: ('Results') -> None
333+
# type: ("Results") -> None
334334
# NOTE: All of these have already been set by __set_partial_results,
335335
# we double check that they are aliases
336336
if results.pca_projection is not None:
@@ -359,8 +359,8 @@ def _send_data(self):
359359
new_partition = list(map(index_map.get, self.partition))
360360

361361
cluster_var = DiscreteVariable(
362-
get_unique_names(domain, 'Cluster'),
363-
values=['C%d' % (i + 1) for i, _ in enumerate(np.unique(new_partition))]
362+
get_unique_names(domain, "Cluster"),
363+
values=["C%d" % (i + 1) for i, _ in enumerate(np.unique(new_partition))]
364364
)
365365

366366
new_domain = add_columns(domain, metas=[cluster_var])
@@ -427,13 +427,13 @@ def onDeleteWidget(self):
427427
def send_report(self):
428428
pca = report.bool_str(self.apply_pca)
429429
if self.apply_pca:
430-
pca += report.plural(', {number} component{s}', self.pca_components)
430+
pca += report.plural(", {number} component{s}", self.pca_components)
431431

432432
self.report_items((
433-
('PCA preprocessing', pca),
434-
('Metric', METRICS[self.metric_idx][0]),
435-
('k neighbors', self.k_neighbors),
436-
('Resolution', self.resolution),
433+
("PCA preprocessing", pca),
434+
("Metric", METRICS[self.metric_idx][0]),
435+
("k neighbors", self.k_neighbors),
436+
("Resolution", self.resolution),
437437
))
438438

439439

@@ -614,5 +614,5 @@ def run_on_graph(graph, resolution, state):
614614
return res
615615

616616

617-
if __name__ == '__main__': # pragma: no cover
617+
if __name__ == "__main__": # pragma: no cover
618618
WidgetPreview(OWLouvainClustering).run(Table("iris"))

0 commit comments

Comments
 (0)