Skip to content

Commit

Permalink
BUG fix whitespace in error messages
Browse files Browse the repository at this point in the history
Partial fix for scikit-learn#2380.

Signed-off-by: Lars Buitinck <[email protected]>
  • Loading branch information
dsullivan7 authored and larsmans committed Aug 26, 2013
1 parent e3583da commit 2eddb1a
Show file tree
Hide file tree
Showing 25 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions benchmarks/bench_random_projections.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def print_row(clf_type, time_fit, time_transform):
op.add_option("--n-components",
dest="n_components", default="auto",
help="Size of the random subspace."
"('auto' or int > 0)")
" ('auto' or int > 0)")

op.add_option("--ratio-nonzeros",
dest="ratio_nonzeros", default=10 ** -3, type=float,
Expand All @@ -119,7 +119,7 @@ def print_row(clf_type, time_fit, time_transform):
op.add_option("--density",
dest="density", default=1 / 3,
help="Density used by the sparse random projection."
"('auto' or float (0.0, 1.0]")
" ('auto' or float (0.0, 1.0]")

op.add_option("--eps",
dest="eps", default=0.5, type=float,
Expand Down
2 changes: 1 addition & 1 deletion doc/sphinxext/gen_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def __init__(self, doc_url, searchindex='searchindex.js',
if os.name.lower() == 'nt' and not doc_url.startswith('http://'):
if not relative:
raise ValueError('You have to use relative=True for the local'
'package on a Windows system.')
' package on a Windows system.')
self._is_windows = True
else:
self._is_windows = False
Expand Down
2 changes: 1 addition & 1 deletion examples/document_clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
help="Use a hashing feature vectorizer")
op.add_option("--n-features", type=int, default=10000,
help="Maximum number of features (dimensions)"
"to extract from text.")
" to extract from text.")
op.add_option("--verbose",
action="store_true", dest="verbose", default=False,
help="Print progress reports inside k-means algorithm.")
Expand Down
2 changes: 1 addition & 1 deletion sklearn/cluster/k_means_.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ def _mini_batch_convergence(model, iteration_idx, n_iter, tol,
if verbose:
progress_msg = (
'Minibatch iteration %d/%d:'
'mean batch inertia: %f, ewa inertia: %f ' % (
' mean batch inertia: %f, ewa inertia: %f ' % (
iteration_idx + 1, n_iter, batch_inertia,
ewa_inertia))
print(progress_msg)
Expand Down
2 changes: 1 addition & 1 deletion sklearn/covariance/graph_lasso_.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def graph_lasso(emp_cov, alpha, cov_init=None, mode='cd', tol=1e-4,
'too ill-conditioned for this solver')
else:
warnings.warn('graph_lasso: did not converge after %i iteration:'
'dual gap: %.3e' % (max_iter, d_gap),
' dual gap: %.3e' % (max_iter, d_gap),
ConvergenceWarning)
except FloatingPointError as e:
e.args = (e.args[0]
Expand Down
2 changes: 1 addition & 1 deletion sklearn/covariance/robust_covariance.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def c_step(X, n_support, remaining_iterations=30, initial_estimates=None,
# c_step procedure converged
if verbose:
print("Optimal couple (location, covariance) found before"
"ending iterations (%d left)" % (remaining_iterations))
" ending iterations (%d left)" % (remaining_iterations))
results = location, covariance, det, support, dist
elif det > previous_det:
# determinant has increased (should not happen)
Expand Down
2 changes: 1 addition & 1 deletion sklearn/cross_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def __init__(self, n, n_folds, indices):
if n_folds > self.n:
raise ValueError(
("Cannot have number of folds n_folds={0} greater"
"than the number of samples: {1}.").format(n_folds, n))
" than the number of samples: {1}.").format(n_folds, n))


class KFold(_BaseKFold):
Expand Down
2 changes: 1 addition & 1 deletion sklearn/datasets/lfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def _load_imgs(file_paths, slice_, color, resize):
from scipy.misc import imresize
except ImportError:
raise ImportError("The Python Imaging Library (PIL)"
"is required to load data from jpeg files")
" is required to load data from jpeg files")

# compute the portion of the images to load to respect the slice_ parameter
# given by the caller
Expand Down
2 changes: 1 addition & 1 deletion sklearn/datasets/samples_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def make_classification(n_samples=100, n_features=20, n_informative=2,
" features")
if 2 ** n_informative < n_classes * n_clusters_per_class:
raise ValueError("n_classes * n_clusters_per_class must"
"be smaller or equal 2 ** n_informative")
" be smaller or equal 2 ** n_informative")
if weights and len(weights) not in [n_classes, n_classes - 1]:
raise ValueError("Weights specified but incompatible with number "
"of classes.")
Expand Down
2 changes: 1 addition & 1 deletion sklearn/ensemble/gradient_boosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ def feature_importances_(self):
@property
def oob_score_(self):
warn("The oob_score_ argument is replaced by oob_improvement_"
"as of version 0.14 and will be removed in 0.16.",
" as of version 0.14 and will be removed in 0.16.",
DeprecationWarning)
try:
return self._oob_score_
Expand Down
2 changes: 1 addition & 1 deletion sklearn/externals/joblib/numpy_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def read_zfile(file_handle):
data = zlib.decompress(file_handle.read(), 15, length)
assert len(data) == length, (
"Incorrect data length while decompressing %s."
"The file could be corrupted." % file_handle)
" The file could be corrupted." % file_handle)
return data


Expand Down
2 changes: 1 addition & 1 deletion sklearn/linear_model/ridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ def fit(self, X, y, sample_weight=1.0, class_weight=None):
class_weight = self.class_weight
else:
warnings.warn("'class_weight' is now an initialization parameter."
"Using it in the 'fit' method is deprecated and "
" Using it in the 'fit' method is deprecated and "
"will be removed in 0.15.", DeprecationWarning,
stacklevel=2)

Expand Down
2 changes: 1 addition & 1 deletion sklearn/linear_model/stochastic_gradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def _fit(self, X, y, alpha, C, loss, learning_rate,

if class_weight is not None:
warnings.warn("Using 'class_weight' as a parameter to the 'fit'"
"method is deprecated and will be removed in 0.13. "
" method is deprecated and will be removed in 0.13. "
"Set it on initialization instead.",
DeprecationWarning, stacklevel=2)

Expand Down
2 changes: 1 addition & 1 deletion sklearn/manifold/mds.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def fit_transform(self, X, init=None, y=None):
"""
if X.shape[0] == X.shape[1] and self.dissimilarity != "precomputed":
warnings.warn("The MDS API has changed. ``fit`` now constructs an"
"dissimilarity matrix from data. To use a custom "
" dissimilarity matrix from data. To use a custom "
"dissimilarity matrix, set "
"``dissimilarity=precomputed``.")

Expand Down
4 changes: 2 additions & 2 deletions sklearn/metrics/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ def zero_one_loss(y_true, y_pred, normalize=True):

@deprecated("Function 'zero_one' has been renamed to "
"'zero_one_loss' and will be removed in release 0.15."
"Default behavior is changed from 'normalize=False' to "
" Default behavior is changed from 'normalize=False' to "
"'normalize=True'")
def zero_one(y_true, y_pred, normalize=False):
"""Zero-One classification loss
Expand Down Expand Up @@ -1494,7 +1494,7 @@ def precision_recall_fscore_support(y_true, y_pred, beta=1.0, labels=None,
else:
raise ValueError("Example-based precision, recall, fscore is "
"not meaningful outside of multilabel"
"classification. Use accuracy_score instead.")
" classification. Use accuracy_score instead.")

warning_msg = ""
if np.any(size_pred == 0):
Expand Down
4 changes: 2 additions & 2 deletions sklearn/metrics/scorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ def _deprecate_loss_and_score_funcs(
if loss_func is not None:
warn("Passing a loss function is "
"deprecated and will be removed in 0.15. "
"Either use strings or score objects."
"Either use strings or score objects. "
"The relevant new parameter is called ''scoring''. ",
category=DeprecationWarning, stacklevel=2)
scorer = make_scorer(loss_func, greater_is_better=False)
if score_func is not None:
warn("Passing function as ``score_func`` is "
"deprecated and will be removed in 0.15. "
"Either use strings or score objects."
"Either use strings or score objects. "
"The relevant new parameter is called ''scoring''.",
category=DeprecationWarning, stacklevel=2)
if loss_func is None or score_overrides_loss:
Expand Down
2 changes: 1 addition & 1 deletion sklearn/metrics/tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ def test_multioutput_regression_invariance_to_dimension_shuffling():
perm = rng.permutation(n_dims)
assert_almost_equal(metric(y_true[:, perm], y_pred[:, perm]),
error,
err_msg="%s is not dimension shuffling"
err_msg="%s is not dimension shuffling "
"invariant" % name)


Expand Down
2 changes: 1 addition & 1 deletion sklearn/mixture/gmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ def _validate_covars(covars, covariance_type, n_components):
"positive-definite")
elif covariance_type == 'diag':
if len(covars.shape) != 2:
raise ValueError("'diag' covars must have shape"
raise ValueError("'diag' covars must have shape "
"(n_components, n_dim)")
elif np.any(covars <= 0):
raise ValueError("'diag' covars must be non-negative")
Expand Down
4 changes: 2 additions & 2 deletions sklearn/neighbors/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,8 @@ def fit(self, X, y):

if y.ndim == 1 or y.ndim == 2 and y.shape[1] == 1:
if y.ndim != 1:
warnings.warn("A column-vector y was passed when a 1d array"
"was expected. Please change the shape of y to"
warnings.warn("A column-vector y was passed when a 1d array "
"was expected. Please change the shape of y to "
"(n_samples, ), for example using ravel().",
DataConversionWarning, stacklevel=2)

Expand Down
2 changes: 1 addition & 1 deletion sklearn/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(self, steps):
if (not (hasattr(t, "fit") or hasattr(t, "fit_transform")) or not
hasattr(t, "transform")):
raise TypeError("All intermediate steps a the chain should "
"be transforms and implement fit and transform"
"be transforms and implement fit and transform "
"'%s' (type %s) doesn't)" % (t, type(t)))

if not hasattr(estimator, "fit"):
Expand Down
2 changes: 1 addition & 1 deletion sklearn/preprocessing/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def label_binarize(y, classes, multilabel=False, neg_label=0, pos_label=1):

if multilabel:
if not y_is_multilabel:
raise ValueError("y should be a list of label lists/tuples,"
raise ValueError("y should be a list of label lists/tuples, "
"got %r" % (y,))

# inverse map: label => column index
Expand Down
2 changes: 1 addition & 1 deletion sklearn/random_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def transform(self, X, y=None):
if X.shape[1] != self.components_.shape[1]:
raise ValueError(
'Impossible to perform projection:'
'X at fit stage had a different number of features.'
'X at fit stage had a different number of features. '
'(%s != %s)' % (X.shape[1], self.components_.shape[1]))

if not sp.issparse(X):
Expand Down
2 changes: 1 addition & 1 deletion sklearn/svm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def fit(self, X, y, sample_weight=None):
raise ValueError("X.shape[0] should be equal to X.shape[1]")

if sample_weight.shape[0] > 0 and sample_weight.shape[0] != X.shape[0]:
raise ValueError("sample_weight and X have incompatible shapes:"
raise ValueError("sample_weight and X have incompatible shapes: "
"%r vs %r\n"
"Note: Sparse matrices cannot be indexed w/"
"boolean masks (use `indices=True` in CV)."
Expand Down
2 changes: 1 addition & 1 deletion sklearn/utils/arpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"increase the size of the arrays DR and DI to have "
"dimension at least dimension NCV and allocate at least NCV "
"columns for Z. NOTE: Not necessary if Z and V share "
"the same space. Please notify the authors if this error"
"the same space. Please notify the authors if this error "
"occurs.",
-1: "N must be positive.",
-2: "NEV must be positive.",
Expand Down
2 changes: 1 addition & 1 deletion sklearn/utils/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def _assert_allclose(actual, desired, rtol=1e-7, atol=0,
actual, desired = np.asanyarray(actual), np.asanyarray(desired)
if np.allclose(actual, desired, rtol=rtol, atol=atol):
return
msg = ('Array not equal to tolerance rtol=%g, atol=%g:'
msg = ('Array not equal to tolerance rtol=%g, atol=%g: '
'actual %s, desired %s') % (rtol, atol, actual, desired)
raise AssertionError(msg)

Expand Down

0 comments on commit 2eddb1a

Please sign in to comment.