8000 MNT simple deprecations and removals for 0.21 (#12238) · scikit-learn/scikit-learn@0f94f29 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0f94f29

Browse files
authored
MNT simple deprecations and removals for 0.21 (#12238)
Part of #11992. These were all the things that seemed pretty straight-forward. It's actually a bit bulky but should still be easy to review, hopefully.
1 parent 8985a63 commit 0f94f29

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+54
-2877
lines changed

doc/modules/classes.rst

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,23 +1513,4 @@ To be removed in 0.22
15131513
:template: deprecated_function.rst
15141514

15151515
covariance.graph_lasso
1516-
datasets.fetch_mldata
1517-
1518-
1519-
To be removed in 0.21
1520-
---------------------
1521-
1522-
.. autosummary::
1523-
:toctree: generated/
1524-
:template: deprecated_class.rst
1525-
1526-
linear_model.RandomizedLasso
1527-
linear_model.RandomizedLogisticRegression
1528-
neighbors.LSHForest
1529-
1530-
.. autosummary::
1531-
:toctree: generated/
1532-
:template: deprecated_function.rst
1533-
1534-
datasets.load_mlcomp
1535-
linear_model.lasso_stability_path
1516+
datasets.fetch_mldata

sklearn/cluster/hierarchical.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,8 @@ def ward_tree(X, connectivity=None, n_clusters=None, return_distance=False):
339339

340340

341341
# single average and complete linkage
342-
def linkage_tree(X, connectivity=None, n_components='deprecated',
343-
n_clusters=None, linkage='complete', affinity="euclidean",
344-
return_distance=False):
342+
def linkage_tree(X, connectivity=None, n_clusters=None, linkage='complete',
343+
affinity="euclidean", return_distance=False):
345344
"""Linkage agglomerative clustering based on a Feature matrix.
346345
347346
The inertia matrix uses a Heapq-based representation.
@@ -362,9 +361,6 @@ def linkage_tree(X, connectivity=None, n_components='deprecated',
362361
be symmetric and only the upper triangular half is used.
363362
Default is None, i.e, the Ward algorithm is unstructured.
364363
365-
n_components : int (optional)
366-
The number of connected components in the graph.
367-
368364
n_clusters : int (optional)
369365
Stop early the construction of the tree at n_clusters. This is
370366
useful to decrease computation time if the number of clusters is
@@ -420,10 +416,6 @@ def linkage_tree(X, connectivity=None, n_components='deprecated',
420416
--------
421417
ward_tree : hierarchical clustering with ward linkage
422418
"""
423-
if n_components != 'deprecated':
424-
warnings.warn("n_components was deprecated in 0.19"
425-
"will be removed in 0.21", DeprecationWarning)
426-
427419
X = np.asarray(X)
428420
if X.ndim == 1:
429421
X = np.reshape(X, (-1, 1))

sklearn/cluster/tests/test_hierarchical.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,6 @@
3838
from sklearn.datasets import make_moons, make_circles
3939

4040

41-
def test_deprecation_of_n_components_in_linkage_tree():
42-
rng = np.random.RandomState(0)
43-
X = rng.randn(50, 100)
44-
# Test for warning of deprecation of n_components in linkage_tree
45-
children, n_nodes, n_leaves, parent = assert_warns(DeprecationWarning,
46-
linkage_tree,
47-
X.T,
48-
n_components=10)
49-
children_t, n_nodes_t, n_leaves_t, parent_t = linkage_tree(X.T)
50-
assert_array_equal(children, children_t)
51-
assert_equal(n_nodes, n_nodes_t)
52-
assert_equal(n_leaves, n_leaves_t)
53-
assert_equal(parent, parent_t)
54-
55-
5641
def test_linkage_misc():
5742
# Misc tests on linkage
5843
rng = np.random.RandomState(42)

sklearn/covariance/graph_lasso_.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -586,12 +586,6 @@ def __init__(self, alphas=4, n_refinements=4, cv='warn', tol=1e-4,
586586
self.cv = cv
587587
self.n_jobs = n_jobs
588588

589-
@property
590-
@deprecated("Attribute grid_scores was deprecated in version 0.19 and "
591-
"will be removed in 0.21. Use ``grid_scores_`` instead")
592-
def grid_scores(self):
593-
return self.grid_scores_
594-
595589
def fit(self, X, y=None):
596590
"""Fits the GraphicalLasso covariance model to X.
597591

sklearn/covariance/tests/test_graph_lasso.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
from sklearn.utils.testing import assert_array_almost_equal
1111
from sklearn.utils.testing import assert_array_less
12-
from sklearn.utils.testing import assert_warns_message
1312
from sklearn.utils.testing import ignore_warnings
1413

1514
from sklearn.covariance import (graph_lasso, GraphLasso, GraphLassoCV,
@@ -19,8 +18,6 @@
1918
from sklearn.utils import check_random_state
2019
from sklearn import datasets
2120

22-
from numpy.testing import assert_equal
23-
2421

2522
@ignore_warnings(category=DeprecationWarning)
2623
def test_graph_lasso(random_state=0):
@@ -141,25 +138,3 @@ def test_graph_lasso_cv(random_state=1):
141138

142139
# Smoke test with specified alphas
143140
GraphLassoCV(alphas=[0.8, 0.5], tol=1e-1, n_jobs=1).fit(X)
144-
145-
146-
@ignore_warnings(category=DeprecationWarning)
147-
@pytest.mark.filterwarnings('ignore: You should specify a value') # 0.22
148-
def test_deprecated_grid_scores(random_state=1):
149-
dim = 5
150-
n_samples = 6
151-
random_state = check_random_state(random_state)
152-
prec = make_sparse_spd_matrix(dim, alpha=.96,
153-
random_state=random_state)
154-
cov = linalg.inv(prec)
155-
X = random_state.multivariate_normal(np.zeros(dim), cov, size=n_samples)
156-
graph_lasso = GraphLassoCV(alphas=[0.8, 0.5], tol=1e-1, n_jobs=1)
157-
graph_lasso.fit(X)
158-
159-
depr_message = ("Attribute grid_scores was deprecated in version "
160- "0.19 and will be removed in 0.21. Use "
161-
"``grid_scores_`` instead")
162-
163-
assert_warns_message(DeprecationWarning, depr_message,
164-
lambda: graph_lasso.grid_scores)
165-
assert_equal(graph_lasso.grid_scores, graph_lasso.grid_scores_)

sklearn/covariance/tests/test_graphical_lasso.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,13 @@
88

99
from sklearn.utils.testing import assert_array_almost_equal
1010
from sklearn.utils.testing import assert_array_less
11-
from sklearn.utils.testing import assert_warns_message
1211

1312
from sklearn.covariance import (graphical_lasso, GraphicalLasso,
1413
GraphicalLassoCV, empirical_covariance)
1514
from sklearn.datasets.samples_generator import make_sparse_spd_matrix
1615
from sklearn.externals.six.moves import StringIO
1716
from sklearn.utils import check_random_state
1817
from sklearn import datasets
19-
from sklearn.utils.fixes import PY3_OR_LATER
20-
21-
from numpy.testing import assert_equal
2218

2319

2420
def test_graphical_lasso(random_state=0):
@@ -137,25 +133,3 @@ def test_graphical_lasso_cv(random_state=1):
137133

138134
# Smoke test with specified alphas
139135
GraphicalLassoCV(alphas=[0.8, 0.5], tol=1e-1, n_jobs=1).fit(X)
140-
141-
142-
@pytest.mark.filterwarnings('ignore: You should specify a value') # 0.22
143-
@pytest.mark.skipif(not PY3_OR_LATER,
144-
reason='On Python 2 DeprecationWarning is not issued for some unkown reason.')
145-
def test_deprecated_grid_scores(random_state=1):
146-
dim = 5
147-
n_samples = 6
148-
random_state = check_random_state(random_state)
149-
prec = make_sparse_spd_matrix(dim, alpha=.96,
150-
random_state=random_state)
151-
cov = linalg.inv(prec)
152-
X = random_state.multivariate_normal(np.zeros(dim), cov, size=n_samples)
153-
graphical_lasso = GraphicalLassoCV(alphas=[0.8, 0.5], tol=1e-1, n_jobs=1)
154-
graphical_lasso.fit(X)
155-
156-
depr_message = ("Attribute grid_scores was deprecated in version "
157-
"0.19 and will be removed in 0.21. Use "
158-
"``grid_scores_`` instead")
159-
160-
with pytest.warns(DeprecationWarning, match=depr_message):
161-
assert_equal(graphical_lasso.grid_scores, graphical_lasso.grid_scores_)

sklearn/datasets/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from .base import clear_data_home
1818
from .covtype import fetch_covtype
1919
from .kddcup99 import fetch_kddcup99
20-
from .mlcomp import load_mlcomp
2120
from .lfw import fetch_lfw_pairs
2221
from .lfw import fetch_lfw_people
2322
from .twenty_newsgroups import fetch_20newsgroups
@@ -75,7 +74,6 @@
7574
'load_iris',
7675
'load_breast_cancer',
7776
'load_linnerud',
78-
'load_mlcomp',
7977
'load_sample_image',
8078
'load_sample_images',
8179
'load_svmlight_file',

sklearn/datasets/mlcomp.py

Lines changed: 0 additions & 114 deletions
This file was deleted.

sklearn/decomposition/fastica_.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from ..exceptions import ConvergenceWarning
1919
from ..externals import six
2020
from ..externals.six import moves
21-
from ..externals.six import string_types
2221
from ..utils import check_array, as_float_array, check_random_state
2322
from ..utils.validation import check_is_fitted
2423
from ..utils.validation import FLOAT_DTYPES
@@ -553,29 +552,22 @@ def fit(self, X, y=None):
553552
self._fit(X, compute_sources=False)
554553
return self
555554

556-
def transform(self, X, y='deprecated', copy=True):
555+
def transform(self, X, copy=True):
557556
"""Recover the sources from X (apply the unmixing matrix).
558557
559558
Parameters
560559
----------
561560
X : array-like, shape (n_samples, n_features)
562561
Data to transform, where n_samples is the number of samples
563562
and n_features is the number of features.
564-
y : (ignored)
565-
.. deprecated:: 0.19
566-
This parameter will be removed in 0.21.
563+
567564
copy : bool (optional)
568565
If False, data passed to fit are overwritten. Defaults to True.
569566
570567
Returns
571568
-------
572569
X_new : array-like, shape (n_samples, n_components)
573570
"""
574-
if not isinstance(y, string_types) or y != 'deprecated':
575-
warnings.warn("The parameter y on transform() is "
576-
"deprecated since 0.19 and will be removed in 0.21",
577-
DeprecationWarning)
578-
579571
check_is_fitted(self, 'mixing_')
580572

581573
X = check_array(X, copy=copy, dtype=FLOAT_DTYPES)

0 commit comments

Comments
 (0)
0