Skip to content

Commit 43bf02d

Browse files
committed
Version handling and warning log
1 parent 9b5d382 commit 43bf02d

2 files changed

Lines changed: 32 additions & 16 deletions

File tree

openml/extensions/sklearn/extension.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ def match_format(s):
513513
s = "{}...".format(s[:char_lim - 3])
514514
return s.strip()
515515
except ValueError:
516-
logging.info("'Read more' not found in descriptions. "
516+
logging.warning("'Read more' not found in descriptions. "
517517
"Trying to trim till 'Parameters' if available in docstring.")
518518
pass
519519
try:
@@ -522,7 +522,7 @@ def match_format(s):
522522
index = s.index(match_format(pattern))
523523
except ValueError:
524524
# returning full docstring
525-
logging.info("'Parameters' not found in docstring. Omitting docstring trimming.")
525+
logging.warning("'Parameters' not found in docstring. Omitting docstring trimming.")
526526
index = len(s)
527527
s = s[:index]
528528
# trimming docstring to be within char_lim

tests/test_extensions/test_sklearn_extension/test_sklearn_extension.py

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from collections import OrderedDict
99
from unittest import mock
1010
import warnings
11+
from packaging import version
1112

1213
import numpy as np
1314
import scipy.optimize
@@ -274,20 +275,35 @@ def test_serialize_pipeline(self):
274275
'scaler=sklearn.preprocessing.data.StandardScaler,' \
275276
'dummy=sklearn.dummy.DummyClassifier)'
276277
fixture_short_name = 'sklearn.Pipeline(StandardScaler,DummyClassifier)'
277-
# str obtained from self.extension._get_sklearn_description(model)
278-
fixture_description = "Pipeline of transforms with a final estimator.\n\nSequentially " \
279-
"apply a list of transforms and a final estimator.\nIntermediate "\
280-
"steps of the pipeline must be 'transforms', that is, they\nmust "\
281-
"implement fit and transform methods.\nThe final estimator only "\
282-
"needs to implement fit.\nThe transformers in the pipeline can be "\
283-
"cached using ``memory`` argument.\n\nThe purpose of the pipeline is"\
284-
" to assemble several steps that can be\ncross-validated together "\
285-
"while setting different parameters.\nFor this, it enables setting "\
286-
"parameters of the various steps using their\nnames and the "\
287-
"parameter name separated by a '__', as in the example below.\nA "\
288-
"step's estimator may be replaced entirely by setting the "\
289-
"parameter\nwith its name to another estimator, or a transformer "\
290-
"removed by setting\nit to 'passthrough' or ``None``."
278+
279+
if version.parse(sklearn.__version__) >= version.parse("0.21.0"):
280+
fixture_description = "Pipeline of transforms with a final estimator.\n\nSequentially " \
281+
"apply a list of transforms and a final estimator.\nIntermediate " \
282+
"steps of the pipeline must be 'transforms', that is, they\nmust " \
283+
"implement fit and transform methods.\nThe final estimator only " \
284+
"needs to implement fit.\nThe transformers in the pipeline can be " \
285+
"cached using ``memory`` argument.\n\nThe purpose of the pipeline is" \
286+
" to assemble several steps that can be\ncross-validated together " \
287+
"while setting different parameters.\nFor this, it enables setting " \
288+
"parameters of the various steps using their\nnames and the " \
289+
"parameter name separated by a '__', as in the example below.\nA " \
290+
"step's estimator may be replaced entirely by setting the " \
291+
"parameter\nwith its name to another estimator, or a transformer " \
292+
"removed by setting\nit to 'passthrough' or ``None``."
293+
else:
294+
fixture_description = "Pipeline of transforms with a final estimator.\n\nSequentially"\
295+
" apply a list of transforms and a final estimator.\nIntermediate"\
296+
" steps of the pipeline must be 'transforms', that is, they\nmust "\
297+
"implement fit and transform methods.\nThe final estimator only "\
298+
"needs to implement fit.\nThe transformers in the pipeline can "\
299+
"be cached using ``memory`` argument.\n\nThe purpose of the "\
300+
"pipeline is to assemble several steps that can be\n"\
301+
"cross-validated together while setting different parameters."\
302+
"\nFor this, it enables setting parameters of the various steps"\
303+
" using their\nnames and the parameter name separated by a '__',"\
304+
" as in the example below.\nA step's estimator may be replaced "\
305+
"entirely by setting the parameter\nwith its name to another "\
306+
"estimator, or a transformer removed by setting\nto None."
291307
fixture_structure = {
292308
fixture_name: [],
293309
'sklearn.preprocessing.data.StandardScaler': ['scaler'],

0 commit comments

Comments
 (0)