From 59494f7e851523cc9038b3e06258148885a6ae34 Mon Sep 17 00:00:00 2001 From: zero323 Date: Wed, 24 May 2017 11:52:22 +0200 Subject: [PATCH 1/3] Fix incorrect test --- python/pyspark/ml/tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/pyspark/ml/tests.py b/python/pyspark/ml/tests.py index 51a3e8efe8b4..701651073c9e 100755 --- a/python/pyspark/ml/tests.py +++ b/python/pyspark/ml/tests.py @@ -807,10 +807,10 @@ def test_logistic_regression(self): except OSError: pass - def logistic_regression_check_thresholds(self): + def test_logistic_regression_check_thresholds(self): self.assertIsInstance( LogisticRegression(threshold=0.5, thresholds=[0.5, 0.5]), - LogisticRegressionModel + LogisticRegression ) self.assertRaisesRegexp( From b780da2fc30f91fbe386a81c59975245c0f0f058 Mon Sep 17 00:00:00 2001 From: zero323 Date: Wed, 24 May 2017 12:02:36 +0200 Subject: [PATCH 2/3] Move test to ParamTests --- python/pyspark/ml/tests.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/python/pyspark/ml/tests.py b/python/pyspark/ml/tests.py index 701651073c9e..7098d130ddfb 100755 --- a/python/pyspark/ml/tests.py +++ b/python/pyspark/ml/tests.py @@ -404,6 +404,18 @@ def test_copy_param_extras(self): self.assertEqual(tp._paramMap, copied_no_extra) self.assertEqual(tp._defaultParamMap, tp_copy._defaultParamMap) + def test_logistic_regression_check_thresholds(self): + self.assertIsInstance( + LogisticRegression(threshold=0.5, thresholds=[0.5, 0.5]), + LogisticRegression + ) + + self.assertRaisesRegex( + ValueError, + "Logistic Regression getThreshold found inconsistent.*$", + LogisticRegression, threshold=0.42, thresholds=[0.5, 0.5] + ) + class EvaluatorTests(SparkSessionTestCase): @@ -807,18 +819,6 @@ def test_logistic_regression(self): except OSError: pass - def test_logistic_regression_check_thresholds(self): - self.assertIsInstance( - LogisticRegression(threshold=0.5, thresholds=[0.5, 0.5]), - LogisticRegression - ) - - self.assertRaisesRegexp( - ValueError, - "Logistic Regression getThreshold found inconsistent.*$", - LogisticRegression, threshold=0.42, thresholds=[0.5, 0.5] - ) - def _compare_params(self, m1, m2, param): """ Compare 2 ML Params instances for the given param, and assert both have the same param value From 04ad0f20e6580e42eb0974a9a4de58820eaf1316 Mon Sep 17 00:00:00 2001 From: zero323 Date: Wed, 24 May 2017 13:08:54 +0200 Subject: [PATCH 3/3] Use assertRaisesRegexp for 2.7 compatibility --- python/pyspark/ml/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/pyspark/ml/tests.py b/python/pyspark/ml/tests.py index 7098d130ddfb..1c308308a02a 100755 --- a/python/pyspark/ml/tests.py +++ b/python/pyspark/ml/tests.py @@ -410,7 +410,7 @@ def test_logistic_regression_check_thresholds(self): LogisticRegression ) - self.assertRaisesRegex( + self.assertRaisesRegexp( ValueError, "Logistic Regression getThreshold found inconsistent.*$", LogisticRegression, threshold=0.42, thresholds=[0.5, 0.5]