Skip to content

Commit 51d25d7

Browse files
Scowley4jnothman
authored andcommitted
Fix spacing and formatting inconsistencies (scikit-learn#13747)
1 parent 18b4f55 commit 51d25d7

27 files changed

+86
-86
lines changed

sklearn/cluster/hierarchical.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def ward_tree(X, connectivity=None, n_clusters=None, return_distance=False):
148148
Parameters
149149
----------
150150
X : array, shape (n_samples, n_features)
151-
feature matrix representing n_samples samples to be clustered
151+
feature matrix representing n_samples samples to be clustered
152152
153153
connectivity : sparse matrix (optional).
154154
connectivity matrix. Defines for each sample the neighboring samples
@@ -219,7 +219,7 @@ def ward_tree(X, connectivity=None, n_clusters=None, return_distance=False):
219219
n_samples, n_features = X.shape
220220

221221
if connectivity is None:
222-
from scipy.cluster import hierarchy # imports PIL
222+
from scipy.cluster import hierarchy # imports PIL
223223

224224
if n_clusters is not None:
225225
warnings.warn('Partial build of the tree is implemented '
@@ -433,7 +433,7 @@ def linkage_tree(X, connectivity=None, n_clusters=None, linkage='complete',
433433
'of %s, but %s was given' % (linkage_choices.keys(), linkage))
434434

435435
if connectivity is None:
436-
from scipy.cluster import hierarchy # imports PIL
436+
from scipy.cluster import hierarchy # imports PIL
437437

438438
if n_clusters is not None:
439439
warnings.warn('Partial build of the tree is implemented '
@@ -597,7 +597,7 @@ def _single_linkage(*args, **kwargs):
597597

598598

599599
###############################################################################
600-
# Functions for cutting hierarchical clustering tree
600+
# Functions for cutting hierarchical clustering tree
601601

602602
def _hc_cut(n_clusters, children, n_leaves):
603603
"""Function cutting the ward tree for a given number of clusters.

sklearn/cluster/k_means_.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ def _init_centroids(X, k, init, random_state=None, x_squared_norms=None,
706706
an int to make the randomness deterministic.
707707
See :term:`Glossary <random_state>`.
708708
709-
x_squared_norms : array, shape (n_samples,), optional
709+
x_squared_norms : array, shape (n_samples,), optional
710710
Squared euclidean norm of each data point. Pass it if you have it at
711711
hands already to avoid it being recomputed here. Default: None
712712
@@ -1419,8 +1419,8 @@ class MiniBatchKMeans(KMeans):
14191419
... [3, 2], [5, 5], [1, -1]])
14201420
>>> # manually fit on batches
14211421
>>> kmeans = MiniBatchKMeans(n_clusters=2,
1422-
... random_state=0,
1423-
... batch_size=6)
1422+
... random_state=0,
1423+
... batch_size=6)
14241424
>>> kmeans = kmeans.partial_fit(X[0:6,:])
14251425
>>> kmeans = kmeans.partial_fit(X[6:12,:])
14261426
>>> kmeans.cluster_centers_
@@ -1430,9 +1430,9 @@ class MiniBatchKMeans(KMeans):
14301430
array([0, 1], dtype=int32)
14311431
>>> # fit on the whole data
14321432
>>> kmeans = MiniBatchKMeans(n_clusters=2,
1433-
... random_state=0,
1434-
... batch_size=6,
1435-
... max_iter=10).fit(X)
1433+
... random_state=0,
1434+
... batch_size=6,
1435+
... max_iter=10).fit(X)
14361436
>>> kmeans.cluster_centers_
14371437
array([[3.95918367, 2.40816327],
14381438
[1.12195122, 1.3902439 ]])

sklearn/covariance/empirical_covariance_.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ class EmpiricalCovariance(BaseEstimator):
122122
... [.3, .4]])
123123
>>> rng = np.random.RandomState(0)
124124
>>> X = rng.multivariate_normal(mean=[0, 0],
125-
... cov=real_cov,
126-
... size=500)
125+
... cov=real_cov,
126+
... size=500)
127127
>>> cov = EmpiricalCovariance().fit(X)
128128
>>> cov.covariance_ # doctest: +ELLIPSIS
129129
array([[0.7569..., 0.2818...],

sklearn/covariance/graph_lasso_.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,10 @@ class GraphicalLasso(EmpiricalCovariance):
337337
--------
338338
>>> import numpy as np
339339
>>> from sklearn.covariance import GraphicalLasso
340-
>>> true_cov = np.array([[.8, 0., .2, 0.],
341-
... [0., .4, 0., 0.],
342-
... [.2, 0., .3, .1],
343-
... [0., 0., .1, .7]])
340+
>>> true_cov = np.array([[0.8, 0.0, 0.2, 0.0],
341+
... [0.0, 0.4, 0.0, 0.0],
342+
... [0.2, 0.0, 0.3, 0.1],
343+
... [0.0, 0.0, 0.1, 0.7]])
344344
>>> np.random.seed(0)
345345
>>> X = np.random.multivariate_normal(mean=[0, 0, 0, 0],
346346
... cov=true_cov,
@@ -592,10 +592,10 @@ class GraphicalLassoCV(GraphicalLasso):
592592
--------
593593
>>> import numpy as np
594594
>>> from sklearn.covariance import GraphicalLassoCV
595-
>>> true_cov = np.array([[.8, 0., .2, 0.],
596-
... [0., .4, 0., 0.],
597-
... [.2, 0., .3, .1],
598-
... [0., 0., .1, .7]])
595+
>>> true_cov = np.array([[0.8, 0.0, 0.2, 0.0],
596+
... [0.0, 0.4, 0.0, 0.0],
597+
... [0.2, 0.0, 0.3, 0.1],
598+
... [0.0, 0.0, 0.1, 0.7]])
599599
>>> np.random.seed(0)
600600
>>> X = np.random.multivariate_normal(mean=[0, 0, 0, 0],
601601
... cov=true_cov,

sklearn/datasets/base.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -568,12 +568,12 @@ def load_digits(n_class=10, return_X_y=False):
568568
def load_diabetes(return_X_y=False):
569569
"""Load and return the diabetes dataset (regression).
570570
571-
============== ==================
572-
Samples total 442
573-
Dimensionality 10
574-
Features real, -.2 < x < .2
575-
Targets integer 25 - 346
576-
============== ==================
571+
============== ==================
572+
Samples total 442
573+
Dimensionality 10
574+
Features real, -.2 < x < .2
575+
Targets integer 25 - 346
576+
============== ==================
577577
578578
Read more in the :ref:`User Guide <diabetes_dataset>`.
579579
@@ -621,12 +621,12 @@ def load_diabetes(return_X_y=False):
621621
def load_linnerud(return_X_y=False):
622622
"""Load and return the linnerud dataset (multivariate regression).
623623
624-
============== ============================
625-
Samples total 20
626-
Dimensionality 3 (for both data and target)
627-
Features integer
628-
Targets integer
629-
============== ============================
624+
============== ============================
625+
Samples total 20
626+
Dimensionality 3 (for both data and target)
627+
Features integer
628+
Targets integer
629+
============== ============================
630630
631631
Read more in the :ref:`User Guide <linnerrud_dataset>`.
632632
@@ -685,12 +685,12 @@ def load_linnerud(return_X_y=False):
685685
def load_boston(return_X_y=False):
686686
"""Load and return the boston house-prices dataset (regression).
687687
688-
============== ==============
689-
Samples total 506
690-
Dimensionality 13
691-
Features real, positive
692-
Targets real 5. - 50.
693-
============== ==============
688+
============== ==============
689+
Samples total 506
690+
Dimensionality 13
691+
Features real, positive
692+
Targets real 5. - 50.
693+
============== ==============
694694
695695
Read more in the :ref:`User Guide <boston_dataset>`.
696696

sklearn/datasets/california_housing.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ def fetch_california_housing(data_home=None, download_if_missing=True,
5050
return_X_y=False):
5151
"""Load the California housing dataset (regression).
5252
53-
============== ==============
54-
Samples total 20640
55-
Dimensionality 8
56-
Features real
57-
Target real 0.15 - 5.
58-
============== ==============
53+
============== ==============
54+
Samples total 20640
55+
Dimensionality 8
56+
Features real
57+
Target real 0.15 - 5.
58+
============== ==============
5959
6060
Read more in the :ref:`User Guide <california_housing_dataset>`.
6161

sklearn/datasets/svmlight_format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ def dump_svmlight_file(X, y, f, zero_based=True, comment=None, query_id=None,
435435
# if a user wants to get fancy, they'll have to decode themselves.
436436
# Avoid mention of str and unicode types for Python 3.x compat.
437437
if isinstance(comment, bytes):
438-
comment.decode("ascii") # just for the exception
438+
comment.decode("ascii") # just for the exception
439439
else:
440440
comment = comment.encode("utf-8")
441441
if b"\0" in comment:

sklearn/decomposition/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def get_covariance(self):
2727
"""Compute data covariance with the generative model.
2828
2929
``cov = components_.T * S**2 * components_ + sigma2 * eye(n_features)``
30-
where S**2 contains the explained variances, and sigma2 contains the
30+
where S**2 contains the explained variances, and sigma2 contains the
3131
noise variances.
3232
3333
Returns

sklearn/decomposition/dict_learning.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def _sparse_encode(X, dictionary, gram, cov=None, algorithm='lasso_lars',
171171
copy_Xy=copy_cov).T
172172
else:
173173
raise ValueError('Sparse coding method must be "lasso_lars" '
174-
'"lasso_cd", "lasso", "threshold" or "omp", got %s.'
174+
'"lasso_cd", "lasso", "threshold" or "omp", got %s.'
175175
% algorithm)
176176
if new_code.ndim != 2:
177177
return new_code.reshape(n_samples, n_components)

sklearn/decomposition/kernel_pca.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ def _fit_transform(self, K):
230230
# there is a link between
231231
# the eigenvectors of K=Phi(X)'Phi(X) and the ones of Phi(X)Phi(X)'
232232
# if v is an eigenvector of K
233-
# then Phi(X)v is an eigenvector of Phi(X)Phi(X)'
233+
# then Phi(X)v is an eigenvector of Phi(X)Phi(X)'
234234
# if u is an eigenvector of Phi(X)Phi(X)'
235-
# then Phi(X)'u is an eigenvector of Phi(X)Phi(X)'
235+
# then Phi(X)'u is an eigenvector of Phi(X)Phi(X)'
236236
#
237237
# At this stage our self.alphas_ (the v) have norm 1, we need to scale
238238
# them so that eigenvectors in kernel feature space (the u) have norm=1

sklearn/discriminant_analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ def _decision_function(self, X):
716716
Xm = X - self.means_[i]
717717
X2 = np.dot(Xm, R * (S ** (-0.5)))
718718
norm2.append(np.sum(X2 ** 2, 1))
719-
norm2 = np.array(norm2).T # shape = [len(X), n_classes]
719+
norm2 = np.array(norm2).T # shape = [len(X), n_classes]
720720
u = np.asarray([np.sum(np.log(s)) for s in self.scalings_])
721721
return (-0.5 * (norm2 + u) + np.log(self.priors_))
722722

sklearn/dummy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,10 +492,10 @@ def predict(self, X, return_std=False):
492492
493493
Returns
494494
-------
495-
y : array, shape = [n_samples] or [n_samples, n_outputs]
495+
y : array, shape = [n_samples] or [n_samples, n_outputs]
496496
Predicted target values for X.
497497
498-
y_std : array, shape = [n_samples] or [n_samples, n_outputs]
498+
y_std : array, shape = [n_samples] or [n_samples, n_outputs]
499499
Standard deviation of predictive distribution of query points.
500500
"""
501501
check_is_fitted(self, "constant_")

sklearn/ensemble/_gb_losses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,6 @@ def get_init_raw_predictions(self, X, estimator):
879879
'lad': LeastAbsoluteError,
880880
'huber': HuberLossFunction,
881881
'quantile': QuantileLossFunction,
882-
'deviance': None, # for both, multinomial and binomial
882+
'deviance': None, # for both, multinomial and binomial
883883
'exponential': ExponentialLoss,
884884
}

sklearn/ensemble/gradient_boosting.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,7 @@ def _staged_raw_predict(self, X):
16941694
Regression and binary classification are special cases with
16951695
``k == 1``, otherwise ``k==n_classes``.
16961696
"""
1697-
X = check_array(X, dtype=DTYPE, order="C", accept_sparse='csr')
1697+
X = check_array(X, dtype=DTYPE, order="C", accept_sparse='csr')
16981698
raw_predictions = self._raw_predict_init(X)
16991699
for i in range(self.estimators_.shape[0]):
17001700
predict_stage(self.estimators_, i, X, self.learning_rate,
@@ -2085,7 +2085,7 @@ def decision_function(self, X):
20852085
`classes_`. Regression and binary classification produce an
20862086
array of shape [n_samples].
20872087
"""
2088-
X = check_array(X, dtype=DTYPE, order="C", accept_sparse='csr')
2088+
X = check_array(X, dtype=DTYPE, order="C", accept_sparse='csr')
20892089
raw_predictions = self._raw_predict(X)
20902090
if raw_predictions.shape[1] == 1:
20912091
return raw_predictions.ravel()
@@ -2527,7 +2527,7 @@ def predict(self, X):
25272527
y : array, shape (n_samples,)
25282528
The predicted values.
25292529
"""
2530-
X = check_array(X, dtype=DTYPE, order="C", accept_sparse='csr')
2530+
X = check_array(X, dtype=DTYPE, order="C", accept_sparse='csr')
25312531
# In regression we can directly return the raw value from the trees.
25322532
return self._raw_predict(X).ravel()
25332533

sklearn/ensemble/weight_boosting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ class in ``classes_``, respectively.
685685
# The weights are all 1. for SAMME.R
686686
pred = sum(_samme_proba(estimator, n_classes, X)
687687
for estimator in self.estimators_)
688-
else: # self.algorithm == "SAMME"
688+
else: # self.algorithm == "SAMME"
689689
pred = sum((estimator.predict(X) == classes).T * w
690690
for estimator, w in zip(self.estimators_,
691691
self.estimator_weights_))
@@ -780,7 +780,7 @@ def predict_proba(self, X):
780780
# The weights are all 1. for SAMME.R
781781
proba = sum(_samme_proba(estimator, n_classes, X)
782782
for estimator in self.estimators_)
783-
else: # self.algorithm == "SAMME"
783+
else: # self.algorithm == "SAMME"
784784
proba = sum(estimator.predict_proba(X) * w
785785
for estimator, w in zip(self.estimators_,
786786
self.estimator_weights_))

sklearn/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class NotFittedError(ValueError, AttributeError):
2929
... LinearSVC().predict([[1, 2], [2, 3], [3, 4]])
3030
... except NotFittedError as e:
3131
... print(repr(e))
32-
... # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
32+
... # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
3333
NotFittedError('This LinearSVC instance is not fitted yet'...)
3434
3535
.. versionchanged:: 0.18
@@ -114,7 +114,7 @@ class FitFailedWarning(RuntimeWarning):
114114
>>> X, y = [[1, 2], [3, 4], [5, 6], [7, 8]], [0, 0, 1, 1]
115115
>>> with warnings.catch_warnings(record=True) as w:
116116
... try:
117-
... gs.fit(X, y) # This will raise a ValueError since C is < 0
117+
... gs.fit(X, y) # This will raise a ValueError since C is < 0
118118
... except ValueError:
119119
... pass
120120
... print(repr(w[-1].message))

sklearn/feature_extraction/text.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def _check_stop_list(stop):
110110
raise ValueError("not a built-in stop list: %s" % stop)
111111
elif stop is None:
112112
return None
113-
else: # assume it's a collection
113+
else: # assume it's a collection
114114
return frozenset(stop)
115115

116116

@@ -1496,7 +1496,7 @@ class TfidfVectorizer(CountVectorizer):
14961496
14971497
idf_ : array, shape (n_features)
14981498
The inverse document frequency (IDF) vector; only defined
1499-
if ``use_idf`` is True.
1499+
if ``use_idf`` is True.
15001500
15011501
stop_words_ : set
15021502
Terms that were ignored because they either:

sklearn/kernel_ridge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class KernelRidge(BaseEstimator, RegressorMixin, MultiOutputMixin):
2727
squared error loss while support vector regression uses epsilon-insensitive
2828
loss, both combined with l2 regularization. In contrast to SVR, fitting a
2929
KRR model can be done in closed-form and is typically faster for
30-
medium-sized datasets. On the other hand, the learned model is non-sparse
30+
medium-sized datasets. On the other hand, the learned model is non-sparse
3131
and thus slower than SVR, which learns a sparse model for epsilon > 0, at
3232
prediction-time.
3333

sklearn/metrics/pairwise.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,17 +1169,17 @@ def distance_metrics():
11691169
11701170
The valid distance metrics, and the function they map to, are:
11711171
1172-
============ ====================================
1173-
metric Function
1174-
============ ====================================
1175-
'cityblock' metrics.pairwise.manhattan_distances
1176-
'cosine' metrics.pairwise.cosine_distances
1177-
'euclidean' metrics.pairwise.euclidean_distances
1178-
'haversine' metrics.pairwise.haversine_distances
1179-
'l1' metrics.pairwise.manhattan_distances
1180-
'l2' metrics.pairwise.euclidean_distances
1181-
'manhattan' metrics.pairwise.manhattan_distances
1182-
============ ====================================
1172+
============ ====================================
1173+
metric Function
1174+
============ ====================================
1175+
'cityblock' metrics.pairwise.manhattan_distances
1176+
'cosine' metrics.pairwise.cosine_distances
1177+
'euclidean' metrics.pairwise.euclidean_distances
1178+
'haversine' metrics.pairwise.haversine_distances
1179+
'l1' metrics.pairwise.manhattan_distances
1180+
'l2' metrics.pairwise.euclidean_distances
1181+
'manhattan' metrics.pairwise.manhattan_distances
1182+
============ ====================================
11831183
11841184
Read more in the :ref:`User Guide <metrics>`.
11851185

sklearn/model_selection/_validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ def learning_curve(estimator, X, y, groups=None,
11181118
train_sizes=np.linspace(0.1, 1.0, 5), cv='warn',
11191119
scoring=None, exploit_incremental_learning=False,
11201120
n_jobs=None, pre_dispatch="all", verbose=0, shuffle=False,
1121-
random_state=None, error_score='raise-deprecating'):
1121+
random_state=None, error_score='raise-deprecating'):
11221122
"""Learning curve.
11231123
11241124
Determines cross-validated training and test scores for different training

sklearn/neighbors/lof.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,5 +500,5 @@ def _local_reachability_density(self, distances_X, neighbors_indices):
500500
self.n_neighbors_ - 1]
501501
reach_dist_array = np.maximum(distances_X, dist_k)
502502

503-
# 1e-10 to avoid `nan' when nb of duplicates > n_neighbors_:
503+
# 1e-10 to avoid `nan' when nb of duplicates > n_neighbors_:
504504
return 1. / (np.mean(reach_dist_array, axis=1) + 1e-10)

sklearn/neural_network/_stochastic_optimizers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Stochastic optimization methods for MLP
22
"""
33

4-
# Authors: Jiyuan Qian <jq401@nyu.edu>
4+
# Authors: Jiyuan Qian <jq401@nyu.edu>
55
# License: BSD 3 clause
66

77
import numpy as np

0 commit comments

Comments
 (0)