Skip to content

Commit 52cbdb7

Browse files
committed
Debugging phase 2
1 parent 579498a commit 52cbdb7

1 file changed

Lines changed: 35 additions & 18 deletions

File tree

tests/test_extensions/test_sklearn_extension/test_sklearn_extension.py

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,9 @@ def test_serialize_pipeline(self):
315315

316316
self.assertEqual(serialization.name, fixture_name)
317317
self.assertEqual(serialization.custom_name, fixture_short_name)
318-
TestBase.logger.info("\n\ntest_serialize_pipeline\n---------------------\n"
319-
"{}\n\n{}\n\n".format(serialization.description, fixture_description))
318+
TestBase.logger.info("\n\ntest_serialize_pipeline\n---------------------\n{}\n"
319+
"{}\n\n{}\n\n".format(sklearn.__version__, serialization.description,
320+
fixture_description))
320321
self.assertEqual(serialization.description, fixture_description)
321322
self.assertDictEqual(structure, fixture_structure)
322323

@@ -394,20 +395,35 @@ def test_serialize_pipeline_clustering(self):
394395
'scaler=sklearn.preprocessing.data.StandardScaler,' \
395396
'clusterer=sklearn.cluster.k_means_.KMeans)'
396397
fixture_short_name = 'sklearn.Pipeline(StandardScaler,KMeans)'
397-
# str obtained from self.extension._get_sklearn_description(model)
398-
fixture_description = "Pipeline of transforms with a final estimator.\n\nSequentially "\
399-
"apply a list of transforms and a final estimator.\nIntermediate "\
400-
"steps of the pipeline must be 'transforms', that is, they\nmust "\
401-
"implement fit and transform methods.\nThe final estimator only "\
402-
"needs to implement fit.\nThe transformers in the pipeline can be "\
403-
"cached using ``memory`` argument.\n\nThe purpose of the pipeline is"\
404-
" to assemble several steps that can be\ncross-validated together "\
405-
"while setting different parameters.\nFor this, it enables setting "\
406-
"parameters of the various steps using their\nnames and the "\
407-
"parameter name separated by a '__', as in the example below.\nA "\
408-
"step's estimator may be replaced entirely by setting the parameter"\
409-
"\nwith its name to another estimator, or a transformer removed "\
410-
"by setting\nit to 'passthrough' or ``None``."
398+
399+
if version.parse(sklearn.__version__) >= version.parse("0.21.0"):
400+
fixture_description = "Pipeline of transforms with a final estimator.\n\nSequentially " \
401+
"apply a list of transforms and a final estimator.\nIntermediate " \
402+
"steps of the pipeline must be 'transforms', that is, they\nmust " \
403+
"implement fit and transform methods.\nThe final estimator only " \
404+
"needs to implement fit.\nThe transformers in the pipeline can be " \
405+
"cached using ``memory`` argument.\n\nThe purpose of the pipeline is" \
406+
" to assemble several steps that can be\ncross-validated together " \
407+
"while setting different parameters.\nFor this, it enables setting " \
408+
"parameters of the various steps using their\nnames and the " \
409+
"parameter name separated by a '__', as in the example below.\nA " \
410+
"step's estimator may be replaced entirely by setting the " \
411+
"parameter\nwith its name to another estimator, or a transformer " \
412+
"removed by setting\nit to 'passthrough' or ``None``."
413+
else:
414+
fixture_description = "Pipeline of transforms with a final estimator.\n\nSequentially"\
415+
" apply a list of transforms and a final estimator.\nIntermediate"\
416+
" steps of the pipeline must be 'transforms', that is, they\nmust "\
417+
"implement fit and transform methods.\nThe final estimator only "\
418+
"needs to implement fit.\nThe transformers in the pipeline can "\
419+
"be cached using ``memory`` argument.\n\nThe purpose of the "\
420+
"pipeline is to assemble several steps that can be\n"\
421+
"cross-validated together while setting different parameters."\
422+
"\nFor this, it enables setting parameters of the various steps"\
423+
" using their\nnames and the parameter name separated by a '__',"\
424+
" as in the example below.\nA step's estimator may be replaced "\
425+
"entirely by setting the parameter\nwith its name to another "\
426+
"estimator, or a transformer removed by setting\nto None."
411427
fixture_structure = {
412428
fixture_name: [],
413429
'sklearn.preprocessing.data.StandardScaler': ['scaler'],
@@ -419,8 +435,9 @@ def test_serialize_pipeline_clustering(self):
419435

420436
self.assertEqual(serialization.name, fixture_name)
421437
self.assertEqual(serialization.custom_name, fixture_short_name)
422-
TestBase.logger.info("\n\ntest_serialize_pipeline_clustering\n---------------------\n"
423-
"{}\n\n{}\n\n".format(serialization.description, fixture_description))
438+
TestBase.logger.info("\n\ntest_serialize_pipeline_clustering\n---------------------\n{}\n"
439+
"{}\n\n{}\n\n".format(sklearn.__version__, serialization.description,
440+
fixture_description))
424441
self.assertEqual(serialization.description, fixture_description)
425442
self.assertDictEqual(structure, fixture_structure)
426443

0 commit comments

Comments
 (0)