Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[MRG + 1] Too few arguments in formatting call #9298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sklearn/ensemble/bagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,8 @@ def decision_function(self, X):

if self.n_features_ != X.shape[1]:
raise ValueError("Number of features of the model must "
"match the input. Model n_features is {1} and "
"input n_features is {2} "
"match the input. Model n_features is {0} and "
"input n_features is {1} "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this means it was not covered by any test. Can you update existing test to catch this pb?

thx

Copy link
Contributor Author

@SebastinSanty SebastinSanty Jul 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'll check in with tests

"".format(self.n_features_, X.shape[1]))

# Parallel loop
Expand Down
8 changes: 8 additions & 0 deletions sklearn/ensemble/tests/test_bagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from sklearn.utils.testing import assert_false
from sklearn.utils.testing import assert_warns
from sklearn.utils.testing import assert_warns_message
from sklearn.utils.testing import assert_raise_message

from sklearn.dummy import DummyClassifier, DummyRegressor
from sklearn.model_selection import GridSearchCV, ParameterGrid
Expand Down Expand Up @@ -449,6 +450,13 @@ def test_parallel_classification():
decisions2 = ensemble.decision_function(X_test)
assert_array_almost_equal(decisions1, decisions2)

X_err = np.hstack((X_test, np.zeros((X_test.shape[0], 1))))
assert_raise_message(ValueError, "Number of features of the model "
"must match the input. Model n_features is {0} "
"and input n_features is {1} "
"".format(X_test.shape[1], X_err.shape[1]),
ensemble.decision_function, X_err)

ensemble = BaggingClassifier(SVC(decision_function_shape='ovr'),
n_jobs=1,
random_state=0).fit(X_train, y_train)
Expand Down
2 changes: 1 addition & 1 deletion sklearn/multiclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def fit(self, X, y):
"""
X, y = check_X_y(X, y)
if self.code_size <= 0:
raise ValueError("code_size should be greater than 0, got {1}"
raise ValueError("code_size should be greater than 0, got {0}"
"".format(self.code_size))

_check_estimator(self.estimator)
Expand Down
3 changes: 3 additions & 0 deletions sklearn/tests/test_multiclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,9 @@ def test_ecoc_float_y():

ovo = OutputCodeClassifier(LinearSVC())
assert_raise_message(ValueError, "Unknown label type", ovo.fit, X, y)
ovo = OutputCodeClassifier(LinearSVC(), code_size=-1)
assert_raise_message(ValueError, "code_size should be greater than 0,"
" got -1", ovo.fit, X, y)


def test_pairwise_indices():
Expand Down