Skip to content

Commit 5f75acd

Browse files
authored
MNT Bump joblib version dependency to 1.0.0 (#22365)
1 parent 34f4465 commit 5f75acd

17 files changed

+29
-192
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
.. |PythonMinVersion| replace:: 3.7
3636
.. |NumPyMinVersion| replace:: 1.14.6
3737
.. |SciPyMinVersion| replace:: 1.1.0
38-
.. |JoblibMinVersion| replace:: 0.11
38+
.. |JoblibMinVersion| replace:: 1.0.0
3939
.. |ThreadpoolctlMinVersion| replace:: 2.0.0
4040
.. |MatplotlibMinVersion| replace:: 2.2.3
4141
.. |Scikit-ImageMinVersion| replace:: 0.14.5

sklearn/_build_utils/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@ def cythonize_extensions(top_path, config):
6464
with contextlib.suppress(ImportError):
6565
import joblib
6666

67-
if LooseVersion(joblib.__version__) > LooseVersion("0.13.0"):
68-
# earlier joblib versions don't account for CPU affinity
69-
# constraints, and may over-estimate the number of available
70-
# CPU particularly in CI (cf loky#114)
71-
n_jobs = joblib.cpu_count()
67+
n_jobs = joblib.cpu_count()
7268

7369
# Additional checks for Cython
7470
cython_enable_debug_directives = (

sklearn/_min_dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
NUMPY_MIN_VERSION = "1.14.6"
1818

1919
SCIPY_MIN_VERSION = "1.1.0"
20-
JOBLIB_MIN_VERSION = "0.11"
20+
JOBLIB_MIN_VERSION = "1.0.0"
2121
THREADPOOLCTL_MIN_VERSION = "2.0.0"
2222
PYTEST_MIN_VERSION = "5.0.1"
2323
CYTHON_MIN_VERSION = "0.29.24"

sklearn/ensemble/_forest.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ class calls the ``fit`` method of each sub-estimator on random samples
6565
from ..exceptions import DataConversionWarning
6666
from ._base import BaseEnsemble, _partition_estimators
6767
from ..utils.fixes import delayed
68-
from ..utils.fixes import _joblib_parallel_args
6968
from ..utils.multiclass import check_classification_targets, type_of_target
7069
from ..utils.validation import check_is_fitted, _check_sample_weight
7170
from ..utils.validation import _num_samples
@@ -249,7 +248,7 @@ def apply(self, X):
249248
results = Parallel(
250249
n_jobs=self.n_jobs,
251250
verbose=self.verbose,
252-
**_joblib_parallel_args(prefer="threads"),
251+
prefer="threads",
253252
)(delayed(tree.apply)(X, check_input=False) for tree in self.estimators_)
254253

255254
return np.array(results).T
@@ -282,7 +281,7 @@ def decision_path(self, X):
282281
indicators = Parallel(
283282
n_jobs=self.n_jobs,
284283
verbose=self.verbose,
285-
**_joblib_parallel_args(prefer="threads"),
284+
prefer="threads",
286285
)(
287286
delayed(tree.decision_path)(X, check_input=False)
288287
for tree in self.estimators_
@@ -471,7 +470,7 @@ def fit(self, X, y, sample_weight=None):
471470
trees = Parallel(
472471
n_jobs=self.n_jobs,
473472
verbose=self.verbose,
474-
**_joblib_parallel_args(prefer="threads"),
473+
prefer="threads",
475474
)(
476475
delayed(_parallel_build_trees)(
477476
t,
@@ -625,9 +624,7 @@ def feature_importances_(self):
625624
"""
626625
check_is_fitted(self)
627626

628-
all_importances = Parallel(
629-
n_jobs=self.n_jobs, **_joblib_parallel_args(prefer="threads")
630-
)(
627+
all_importances = Parallel(n_jobs=self.n_jobs, prefer="threads")(
631628
delayed(getattr)(tree, "feature_importances_")
632629
for tree in self.estimators_
633630
if tree.tree_.node_count > 1
@@ -879,11 +876,7 @@ def predict_proba(self, X):
879876
for j in np.atleast_1d(self.n_classes_)
880877
]
881878
lock = threading.Lock()
882-
Parallel(
883-
n_jobs=n_jobs,
884-
verbose=self.verbose,
885-
**_joblib_parallel_args(require="sharedmem"),
886-
)(
879+
Parallel(n_jobs=n_jobs, verbose=self.verbose, require="sharedmem")(
887880
delayed(_accumulate_prediction)(e.predict_proba, X, all_proba, lock)
888881
for e in self.estimators_
889882
)
@@ -1002,11 +995,7 @@ def predict(self, X):
1002995

1003996
# Parallel loop
1004997
lock = threading.Lock()
1005-
Parallel(
1006-
n_jobs=n_jobs,
1007-
verbose=self.verbose,
1008-
**_joblib_parallel_args(require="sharedmem"),
1009-
)(
998+
Parallel(n_jobs=n_jobs, verbose=self.verbose, require="sharedmem")(
1010999
delayed(_accumulate_prediction)(e.predict, X, [y_hat], lock)
10111000
for e in self.estimators_
10121001
)

sklearn/ensemble/_iforest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
gen_batches,
1515
get_chunk_n_rows,
1616
)
17-
from ..utils.fixes import _joblib_parallel_args
1817
from ..utils.validation import check_is_fitted, _num_samples
1918
from ..base import OutlierMixin
2019

@@ -231,7 +230,7 @@ def _parallel_args(self):
231230
# a thread-based backend rather than a process-based backend so as
232231
# to avoid suffering from communication overhead and extra memory
233232
# copies.
234-
return _joblib_parallel_args(prefer="threads")
233+
return {"prefer": "threads"}
235234

236235
def fit(self, X, y=None, sample_weight=None):
237236
"""

sklearn/linear_model/_coordinate_descent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from ..utils.validation import check_random_state
2323
from ..model_selection import check_cv
2424
from ..utils.extmath import safe_sparse_dot
25-
from ..utils.fixes import _astype_copy_false, _joblib_parallel_args
25+
from ..utils.fixes import _astype_copy_false
2626
from ..utils.validation import (
2727
_check_sample_weight,
2828
check_consistent_length,
@@ -1692,7 +1692,7 @@ def fit(self, X, y, sample_weight=None):
16921692
mse_paths = Parallel(
16931693
n_jobs=self.n_jobs,
16941694
verbose=self.verbose,
1695-
**_joblib_parallel_args(prefer="threads"),
1695+
prefer="threads",
16961696
)(jobs)
16971697
mse_paths = np.reshape(mse_paths, (n_l1_ratio, len(folds), -1))
16981698
# The mean is computed over folds.

sklearn/linear_model/_logistic.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
from ..utils.optimize import _newton_cg, _check_optimize_result
3030
from ..utils.validation import check_is_fitted, _check_sample_weight
3131
from ..utils.multiclass import check_classification_targets
32-
from ..utils.fixes import _joblib_parallel_args
3332
from ..utils.fixes import delayed
3433
from ..model_selection import check_cv
3534
from ..metrics import get_scorer
@@ -1585,11 +1584,7 @@ def fit(self, X, y, sample_weight=None):
15851584
prefer = "threads"
15861585
else:
15871586
prefer = "processes"
1588-
fold_coefs_ = Parallel(
1589-
n_jobs=self.n_jobs,
1590-
verbose=self.verbose,
1591-
**_joblib_parallel_args(prefer=prefer),
1592-
)(
1587+
fold_coefs_ = Parallel(n_jobs=self.n_jobs, verbose=self.verbose, prefer=prefer)(
15931588
path_func(
15941589
X,
15951590
y,
@@ -2150,11 +2145,7 @@ def fit(self, X, y, sample_weight=None):
21502145
else:
21512146
prefer = "processes"
21522147

2153-
fold_coefs_ = Parallel(
2154-
n_jobs=self.n_jobs,
2155-
verbose=self.verbose,
2156-
**_joblib_parallel_args(prefer=prefer),
2157-
)(
2148+
fold_coefs_ = Parallel(n_jobs=self.n_jobs, verbose=self.verbose, prefer=prefer)(
21582149
path_func(
21592150
X,
21602151
y,

sklearn/linear_model/_stochastic_gradient.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
from ._sgd_fast import Huber
3737
from ._sgd_fast import EpsilonInsensitive
3838
from ._sgd_fast import SquaredEpsilonInsensitive
39-
from ..utils.fixes import _joblib_parallel_args
4039

4140
LEARNING_RATE_TYPES = {
4241
"constant": 1,
@@ -752,9 +751,7 @@ def _fit_multiclass(self, X, y, alpha, C, learning_rate, sample_weight, max_iter
752751
random_state = check_random_state(self.random_state)
753752
seeds = random_state.randint(MAX_INT, size=len(self.classes_))
754753
result = Parallel(
755-
n_jobs=self.n_jobs,
756-
verbose=self.verbose,
757-
**_joblib_parallel_args(require="sharedmem"),
754+
n_jobs=self.n_jobs, verbose=self.verbose, require="sharedmem"
758755
)(
759756
delayed(fit_binary)(
760757
self,

sklearn/neighbors/_base.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import numpy as np
1616
from scipy.sparse import csr_matrix, issparse
17-
import joblib
1817
from joblib import Parallel, effective_n_jobs
1918

2019
from ._ball_tree import BallTree
@@ -795,13 +794,7 @@ class from an array representing our data set and ask who's
795794
"or set algorithm='brute'"
796795
% self._fit_method
797796
)
798-
old_joblib = parse_version(joblib.__version__) < parse_version("0.12")
799-
if old_joblib:
800-
# Deal with change of API in joblib
801-
parallel_kwargs = {"backend": "threading"}
802-
else:
803-
parallel_kwargs = {"prefer": "threads"}
804-
chunked_results = Parallel(n_jobs, **parallel_kwargs)(
797+
chunked_results = Parallel(n_jobs, prefer="threads")(
805798
delayed(_tree_query_parallel_helper)(
806799
self._tree, X[s], n_neighbors, return_distance
807800
)
@@ -1133,13 +1126,7 @@ class from an array representing our data set and ask who's
11331126

11341127
n_jobs = effective_n_jobs(self.n_jobs)
11351128
delayed_query = delayed(_tree_query_radius_parallel_helper)
1136-
if parse_version(joblib.__version__) < parse_version("0.12"):
1137-
# Deal with change of API in joblib
1138-
parallel_kwargs = {"backend": "threading"}
1139-
else:
1140-
parallel_kwargs = {"prefer": "threads"}
1141-
1142-
chunked_results = Parallel(n_jobs, **parallel_kwargs)(
1129+
chunked_results = Parallel(n_jobs, prefer="threads")(
11431130
delayed_query(
11441131
self._tree, X[s], radius, return_distance, sort_results=sort_results
11451132
)

sklearn/pipeline.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -326,22 +326,10 @@ def _fit(self, X, y=None, **fit_params_steps):
326326
with _print_elapsed_time("Pipeline", self._log_message(step_idx)):
327327
continue
328328

329-
if hasattr(memory, "location"):
330-
# joblib >= 0.12
331-
if memory.location is None:
332-
# we do not clone when caching is disabled to
333-
# preserve backward compatibility
334-
cloned_transformer = transformer
335-
else:
336-
cloned_transformer = clone(transformer)
337-
elif hasattr(memory, "cachedir"):
338-
# joblib < 0.11
339-
if memory.cachedir is None:
340-
# we do not clone when caching is disabled to
341-
# preserve backward compatibility
342-
cloned_transformer = transformer
343-
else:
344-
cloned_transformer = clone(transformer)
329+
if hasattr(memory, "location") and memory.location is None:
330+
# we do not clone when caching is disabled to
331+
# preserve backward compatibility
332+
cloned_transformer = transformer
345333
else:
346334
cloned_transformer = clone(transformer)
347335
# Fit or load from cache the current transformer

0 commit comments

Comments
 (0)