8000 TST Clean up the cross_validation and grid_search tests. · raghavrv/scikit-learn@5d172b0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5d172b0

Browse files
committed
TST Clean up the cross_validation and grid_search tests.
1 parent 0b69a09 commit 5d172b0

File tree

2 files changed

+10
-33
lines changed

2 files changed

+10
-33
lines changed

sklearn/tests/test_cross_validation.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from scipy import stats
88

99
from sklearn.utils.testing import assert_true
10-
from sklearn.utils.testing import assert_false
1110
from sklearn.utils.testing import assert_equal
1211
from sklearn.utils.testing import assert_almost_equal
1312
from sklearn.utils.testing import assert_raises
@@ -896,26 +895,6 @@ def test_shufflesplit_reproducible():
896895
assert_array_equal(list(a for a, b in ss), list(a for a, b in ss))
897896

898897

899-
def test_safe_split_with_precomputed_kernel():
900-
clf = SVC()
901-
clfp = SVC(kernel="precomputed")
902-
903-
iris = load_iris()
904-
X, y = iris.data, iris.target
905-
K = np.dot(X, X.T)
906-
907-
cv = cval.ShuffleSplit(X.shape[0], test_size=0.25, random_state=0)
908-
tr, te = list(cv)[0]
909-
910-
X_tr, y_tr = cval._safe_split(clf, X, y, tr)
911-
K_tr, y_tr2 = cval._safe_split(clfp, K, y, tr)
912-
assert_array_almost_equal(K_tr, np.dot(X_tr, X_tr.T))
913-
914-
X_te, y_te = cval._safe_split(clf, X, y, te, tr)
915-
K_te, y_te2 = cval._safe_split(clfp, K, y, te, tr)
916-
assert_array_almost_equal(K_te, np.dot(X_te, X_tr.T))
917-
918-
919898
def test_cross_val_score_allow_nans():
920899
# Check that cross_val_score allows input data with NaNs
921900
X = np.arange(200, dtype=np.float64).reshape(10, -1)
@@ -1092,12 +1071,3 @@ def test_sparse_fit_params():
10921071
fit_params = {'sparse_sample_weight': coo_matrix(np.eye(X.shape[0]))}
10931072
a = cval.cross_val_score(clf, X, y, fit_params=fit_params)
10941073
assert_array_equal(a, np.ones(3))
1095-
1096-
1097-
def test_check_is_partition():
1098-
p = np.arange(100)
1099-
assert_true(cval._check_is_partition(p, 100))
1100-
assert_false(cval._check_is_partition(np.delete(p, 23), 100))
1101-
1102-
p[0] = 23
1103-
assert_false(cval._check_is_partition(p, 100))

sklearn/tests/test_grid_search.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
from sklearn.datasets import make_blobs
3535
from sklearn.datasets import make_multilabel_classification
3636
from sklearn.grid_search import (GridSearchCV, RandomizedSearchCV,
37-
ParameterGrid, ParameterSampler,
38-
ChangedBehaviorWarning)
37+
ParameterGrid, ParameterSampler)
3938
from sklearn.svm import LinearSVC, SVC
4039
from sklearn.tree import DecisionTreeRegressor
4140
from sklearn.tree import DecisionTreeClassifier
@@ -44,9 +43,17 @@
4443
from sklearn.metrics import f1_score
4544
from sklearn.metrics import make_scorer
4645
from sklearn.metrics import roc_auc_score
47-
from sklearn.cross_validation import KFold, StratifiedKFold, FitFailedWarning
46+
from sklearn.cross_validation import KFold, StratifiedKFold
4847
from sklearn.preprocessing import Imputer
4948
from sklearn.pipeline import Pipeline
49+
try:
50+
# We should be able to import these Warnings from the old files too.
51+
from sklearn.grid_search import ChangedBehaviorWarning
52+
from sklearn.cross_validation import FitFailedWarning
53+
except ImportError:
54+
raise AssertionError("The import of ChangedBehaviorWarning and/or "
55+
"FitFailedWarning from the old files, was not "
56+
"successful.")
5057

5158

5259
# Neither of the following two estimators inherit from BaseEstimator,

0 commit comments

Comments
 (0)
0