From d8b061f5bd97c4d164a55713fceaeadfbb407533 Mon Sep 17 00:00:00 2001 From: microsheep Date: Tue, 19 Feb 2019 11:25:27 +0800 Subject: [PATCH] add test for parallelisation --- imblearn/combine/tests/test_smote_enn.py | 16 ++++++++++++++++ imblearn/combine/tests/test_smote_tomek.py | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/imblearn/combine/tests/test_smote_enn.py b/imblearn/combine/tests/test_smote_enn.py index a40b77579..ce1f98db2 100644 --- a/imblearn/combine/tests/test_smote_enn.py +++ b/imblearn/combine/tests/test_smote_enn.py @@ -98,6 +98,22 @@ def test_validate_estimator_default(): assert_array_equal(y_resampled, y_gt) +def test_parallelisation(): + # Check if default job count is 1 + smt = SMOTEENN(random_state=RND_SEED) + smt._validate_estimator() + assert smt.n_jobs == 1 + assert smt.smote_.n_jobs == 1 + assert smt.enn_.n_jobs == 1 + + # Check if job count is set + smt = SMOTEENN(random_state=RND_SEED, n_jobs=8) + smt._validate_estimator() + assert smt.n_jobs == 8 + assert smt.smote_.n_jobs == 8 + assert smt.enn_.n_jobs == 8 + + @pytest.mark.parametrize( "smote_params, err_msg", [({'smote': 'rnd'}, "smote needs to be a SMOTE"), diff --git a/imblearn/combine/tests/test_smote_tomek.py b/imblearn/combine/tests/test_smote_tomek.py index b2c2ad999..3a58754bc 100644 --- a/imblearn/combine/tests/test_smote_tomek.py +++ b/imblearn/combine/tests/test_smote_tomek.py @@ -104,6 +104,22 @@ def test_validate_estimator_default(): assert_array_equal(y_resampled, y_gt) +def test_parallelisation(): + # Check if default job count is 1 + smt = SMOTETomek(random_state=RND_SEED) + smt._validate_estimator() + assert smt.n_jobs == 1 + assert smt.smote_.n_jobs == 1 + assert smt.tomek_.n_jobs == 1 + + # Check if job count is set + smt = SMOTETomek(random_state=RND_SEED, n_jobs=8) + smt._validate_estimator() + assert smt.n_jobs == 8 + assert smt.smote_.n_jobs == 8 + assert smt.tomek_.n_jobs == 8 + + @pytest.mark.parametrize( "smote_params, err_msg", [({'smote': 'rnd'}, "smote needs to be a SMOTE"),