8000 MNT Clean-up deprecations for 1.7: utils.__init__ (#31105) · scikit-learn/scikit-learn@0cf0968 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0cf0968

Browse files
authored
MNT Clean-up deprecations for 1.7: utils.__init__ (#31105)
1 parent 17d919e commit 0cf0968

File tree

5 files changed

+4
-135
lines changed

5 files changed

+4
-135
lines changed

build_tools/linting.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,15 @@ else
8989
fi
9090

9191
# Check for joblib.delayed and joblib.Parallel imports
92-
# TODO(1.7): remove ":!sklearn/utils/_joblib.py"
9392
echo -e "### Checking for joblib imports ###\n"
9493
joblib_status=0
95-
joblib_delayed_import="$(git grep -l -A 10 -E "joblib import.+delayed" -- "*.py" ":!sklearn/utils/_joblib.py" ":!sklearn/utils/parallel.py")"
94+
joblib_delayed_import="$(git grep -l -A 10 -E "joblib import.+delayed" -- "*.py" ":!sklearn/utils/parallel.py")"
9695
if [ ! -z "$joblib_delayed_import" ]; then
9796
echo "Use from sklearn.utils.parallel import delayed instead of joblib delayed. The following files contains imports to joblib.delayed:"
9897
echo "$joblib_delayed_import"
9998
joblib_status=1
10099
fi
101-
joblib_Parallel_import="$(git grep -l -A 10 -E "joblib import.+Parallel" -- "*.py" ":!sklearn/utils/_joblib.py" ":!sklearn/utils/parallel.py")"
100+
joblib_Parallel_import="$(git grep -l -A 10 -E "joblib import.+Parallel" -- "*.py" ":!sklearn/utils/parallel.py")"
102101
if [ ! -z "$joblib_Parallel_import" ]; then
103102
echo "Use from sklearn.utils.parallel import Parallel instead of joblib Parallel. The following files contains imports to joblib.Parallel:"
104103
echo "$joblib_Parallel_import"

doc/api_reference.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,9 +1349,4 @@ def _get_submodule(module_name, submodule_name):
13491349
}
13501350
"""
13511351

1352-
DEPRECATED_API_REFERENCE = {
1353-
"1.7": [
1354-
"utils.parallel_backend",
1355-
"utils.register_parallel_backend",
1356-
]
1357-
} # type: ignore
1352+
DEPRECATED_API_REFERENCE = {} # type: ignore

sklearn/utils/__init__.py

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,8 @@
33
# Authors: The scikit-learn developers
44
# SPDX-License-Identifier: BSD-3-Clause
55

6-
import platform
7-
import warnings
8-
from collections.abc import Sequence
9-
10-
import numpy as np
11-
126
from ..exceptions import DataConversionWarning
13-
from . import _joblib, metadata_routing
7+
from . import metadata_routing
148
from ._bunch import Bunch
159
from ._chunking import gen_batches, gen_even_slices
1610
from ._estimator_html_repr import estimator_html_repr
@@ -53,17 +47,6 @@
5347
indexable,
5448
)
5549

56-
# TODO(1.7): remove parallel_backend and register_parallel_backend
57-
msg = "deprecated in 1.5 to be removed in 1.7. Use joblib.{} instead."
58-
register_parallel_backend = deprecated(msg)(_joblib.register_parallel_backend)
59-
60-
61-
# if a class, deprecated will change the object in _joblib module so we need to subclass
62-
@deprecated(msg)
63-
class parallel_backend(_joblib.parallel_backend):
64-
pass
65-
66-
6750
__all__ = [
6851
"Bunch",
6952
"ClassifierTags",
@@ -93,46 +76,8 @@ class parallel_backend(_joblib.parallel_backend):
9376
"indexable",
9477
"metadata_routing",
9578
"murmurhash3_32",
96-
"parallel_backend",
97-
"register_parallel_backend",
9879
"resample",
9980
"safe_mask",
10081
"safe_sqr",
10182
"shuffle",
10283
]
103-
104-
105-
# TODO(1.7): remove
106-
def __getattr__(name):
107-
if name == "IS_PYPY":
108-
warnings.warn(
109-
"IS_PYPY is deprecated and will be removed in 1.7.",
110-
FutureWarning,
111-
)
112-
return platform.python_implementation() == "PyPy"
113-
raise AttributeError(f"module {__name__} has no attribute {name}")
114-
115-
116-
# TODO(1.7): remove tosequence
117-
@deprecated("tosequence was deprecated in 1.5 and will be removed in 1.7")
118-
def tosequence(x):
119-
"""Cast iterable x to a Sequence, avoiding a copy if possible.
120-
121-
Parameters
122-
----------
123-
x : iterable
124-
The iterable to be converted.
125-
126-
Returns
127-
-------
128-
x : Sequence
129-
If `x` is a NumPy array, it returns it as a `ndarray`. If `x`
130-
is a `Sequence`, `x` is returned as-is. If `x` is from any other
131-
type, `x` is returned casted as a list.
132-
"""
133-
if isinstance(x, np.ndarray):
134-
return np.asarray(x)
135-
elif isinstance(x, Sequence):
136-
return x
137-
else:
138-
return list(x)

sklearn/utils/_joblib.py

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

sklearn/utils/tests/test_utils.py

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

0 commit comments

Comments
 (0)
0