Skip to content

Commit 1e37a3a

Browse files
committed
Refactor for readability and flake compliance.
1 parent a8e92fc commit 1e37a3a

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

openml/extensions/sklearn/extension.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,21 +1001,18 @@ def _can_measure_wallclocktime(self, model: Any) -> bool:
10011001
Returns:
10021002
--------
10031003
bool:
1004-
True if none n_jobs parameters is set ot -1, False otherwise
1004+
True if no n_jobs parameters is set to -1, False otherwise
10051005
"""
10061006
if not (
10071007
isinstance(model, sklearn.base.BaseEstimator) or self.is_hpo_class(model)
10081008
):
10091009
raise ValueError('model should be BaseEstimator or BaseSearchCV')
10101010

1011-
# check the parameters for n_jobs
1012-
# note that clause 1 will return True also when there is no occurrence
1013-
# of n_jobs (the negate will make this fn return false). For that
1014-
# reason, we need to add clause 2 that returns True if n_jobs does not
1015-
# exist in the flow
1016-
clause1 = not SklearnExtension._check_parameter_value_recursive(model.get_params(), 'n_jobs', [-1])
1017-
clause2 = SklearnExtension._check_parameter_value_recursive(model.get_params(), 'n_jobs', None)
1018-
return clause1 or clause2
1011+
n_jobs_not_specified = \
1012+
SklearnExtension._check_parameter_value_recursive(model.get_params(), 'n_jobs', None)
1013+
n_jobs_is_minus_one = \
1014+
SklearnExtension._check_parameter_value_recursive(model.get_params(), 'n_jobs', [-1])
1015+
return n_jobs_not_specified or not n_jobs_is_minus_one
10191016

10201017
################################################################################################
10211018
# Methods for performing runs with extension modules

0 commit comments

Comments
 (0)