Skip to content

Commit 481f7fe

Browse files
NelleVGaelVaroquaux
authored andcommitted
PEP8 fixes on hierarchical.py
1 parent 638d590 commit 481f7fe

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

sklearn/cluster/hierarchical.py

+13-14
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from . import _hierarchical
2525
from ._feature_agglomeration import AgglomerationTransform
2626
from .fast_dict import IntFloatDict, average_merge, max_merge,\
27-
WeightedEdge
27+
WeightedEdge
2828

2929

3030
###############################################################################
@@ -295,21 +295,21 @@ def linkage_tree(X, connectivity=None, n_components=None, copy=True,
295295
X = np.reshape(X, (-1, 1))
296296
n_samples, n_features = X.shape
297297

298-
linkage_choices = {
299-
'complete': (hierarchy.complete, max_merge),
300-
'average': (hierarchy.weighted, average_merge),
301-
}
298+
linkage_choices = {'complete': (hierarchy.complete, max_merge),
299+
'average': (hierarchy.weighted, average_merge),
300+
}
302301
try:
303302
scipy_func, join_func = linkage_choices[linkage]
304303
except KeyError:
305-
raise ValueError('Unknown linkage option, linkage should be one '
304+
raise ValueError(
305+
'Unknown linkage option, linkage should be one '
306306
'of %s, but %s was given' % (linkage_choices.keys(), linkage))
307307

308308
if connectivity is None:
309309
if n_clusters is not None:
310310
warnings.warn('Early stopping is implemented only for '
311-
'structured clustering (i.e. with '
312-
'explicit connectivity.', stacklevel=2)
311+
'structured clustering (i.e. with '
312+
'explicit connectivity.', stacklevel=2)
313313
out = scipy_func(X)
314314
children_ = out[:, :2].astype(np.int)
315315
return children_, 1, n_samples, None
@@ -351,14 +351,13 @@ def linkage_tree(X, connectivity=None, n_components=None, copy=True,
351351
connectivity = connectivity.tolil()
352352
# We are storing the graph in a list of IntFloatDict
353353
for ind, (data, row) in enumerate(zip(connectivity.data,
354-
connectivity.rows)):
354+
connectivity.rows)):
355355
A[ind] = IntFloatDict(np.asarray(row, dtype=np.int32),
356-
np.asarray(data, dtype=np.float64))
356+
np.asarray(data, dtype=np.float64))
357357
# We keep only the upper triangular for the heap
358358
# Generator expressions are faster than arrays on the following
359359
[inertia.append(WeightedEdge(d, ind, r))
360-
for r, d in zip(row, data)
361-
if r < ind]
360+
for r, d in zip(row, data) if r < ind]
362361
del connectivity
363362

364363
heapify(inertia)
@@ -502,8 +501,8 @@ def fit(self, X):
502501

503502
if not self.linkage in _TREE_BUILDERS:
504503
raise ValueError("Unknown linkage type %s."
505-
"Valid options are %s" % (self.linkage,
506-
_TREE_BUILDERS.keys()))
504+
"Valid options are %s" % (self.linkage,
505+
_TREE_BUILDERS.keys()))
507506
tree_builder = _TREE_BUILDERS[self.linkage]
508507

509508
if not self.connectivity is None:

0 commit comments

Comments
 (0)