Skip to content

Commit 847b346

Browse files
mschaffenrothNicolasHug
authored andcommitted
MNT Remove utils.fixes.parallel_helper (scikit-learn#15232)
1 parent 58289bc commit 847b346

File tree

3 files changed

+4
-19
lines changed

3 files changed

+4
-19
lines changed

sklearn/ensemble/forest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class calls the ``fit`` method of each sub-estimator on random samples
5959
from ..utils import check_random_state, check_array, compute_sample_weight
6060
from ..exceptions import DataConversionWarning
6161
from .base import BaseEnsemble, _partition_estimators
62-
from ..utils.fixes import parallel_helper, _joblib_parallel_args
62+
from ..utils.fixes import _joblib_parallel_args
6363
from ..utils.multiclass import check_classification_targets
6464
from ..utils.validation import check_is_fitted
6565

@@ -218,7 +218,7 @@ def apply(self, X):
218218
X = self._validate_X_predict(X)
219219
results = Parallel(n_jobs=self.n_jobs, verbose=self.verbose,
220220
**_joblib_parallel_args(prefer="threads"))(
221-
delayed(parallel_helper)(tree, 'apply', X, check_input=False)
221+
delayed(tree.apply)(X, check_input=False)
222222
for tree in self.estimators_)
223223

224224
return np.array(results).T
@@ -249,7 +249,7 @@ def decision_path(self, X):
249249
X = self._validate_X_predict(X)
250250
indicators = Parallel(n_jobs=self.n_jobs, verbose=self.verbose,
251251
**_joblib_parallel_args(prefer='threads'))(
252-
delayed(parallel_helper)(tree, 'decision_path', X,
252+
delayed(tree.decision_path)(X,
253253
check_input=False)
254254
for tree in self.estimators_)
255255

sklearn/multioutput.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from .base import RegressorMixin, ClassifierMixin, is_classifier
2424
from .model_selection import cross_val_predict
2525
from .utils import check_array, check_X_y, check_random_state
26-
from .utils.fixes import parallel_helper
2726
from .utils.metaestimators import if_delegate_has_method
2827
from .utils.validation import check_is_fitted, has_fit_parameter
2928
from .utils.multiclass import check_classification_targets
@@ -193,7 +192,7 @@ def predict(self, X):
193192
X = check_array(X, accept_sparse=True)
194193

195194
y = Parallel(n_jobs=self.n_jobs)(
196-
delayed(parallel_helper)(e, 'predict', X)
195+
delayed(e.predict)(X)
197196
for e in self.estimators_)
198197

199198
return np.asarray(y).T

sklearn/utils/fixes.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -155,20 +155,6 @@ def _argmax(arr_or_matrix, axis=None):
155155
return arr_or_matrix.argmax(axis=axis)
156156

157157

158-
def parallel_helper(obj, methodname, *args, **kwargs):
159-
"""Workaround for Python 2 limitations of pickling instance methods
160-
161-
Parameters
162-
----------
163-
obj
164-
methodname
165-
*args
166-
**kwargs
167-
168-
"""
169-
return getattr(obj, methodname)(*args, **kwargs)
170-
171-
172158
if np_version < (1, 12):
173159
class MaskedArray(np.ma.MaskedArray):
174160
# Before numpy 1.12, np.ma.MaskedArray object is not picklable

0 commit comments

Comments
 (0)