From e8d385f7690a081f8e67d83860c6c0333382e694 Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Wed, 2 Oct 2024 16:51:50 +0100 Subject: [PATCH 1/2] Revert "[CI, testing] add SVM C and nu parameter check prevents seg fault sklearn < 1.2 (#1930)" This reverts commit 04dbc5e1a412ac76f3578f76508df87e46487910. --- sklearnex/svm/nusvc.py | 13 ++----------- sklearnex/svm/nusvr.py | 13 ++----------- sklearnex/svm/svc.py | 13 ++----------- sklearnex/svm/svr.py | 13 ++----------- 4 files changed, 8 insertions(+), 44 deletions(-) diff --git a/sklearnex/svm/nusvc.py b/sklearnex/svm/nusvc.py index 73ade387e2..132b838c8b 100644 --- a/sklearnex/svm/nusvc.py +++ b/sklearnex/svm/nusvc.py @@ -88,17 +88,8 @@ def __init__( def fit(self, X, y, sample_weight=None): if sklearn_check_version("1.2"): self._validate_params() - elif self.nu <= 0 or self.nu > 1: - # else if added to correct issues with - # sklearn tests: - # svm/tests/test_sparse.py::test_error - # svm/tests/test_svm.py::test_bad_input - # for sklearn versions < 1.2 (i.e. without - # validate_params parameter checking) - # Without this, a segmentation fault with - # Windows fatal exception: access violation - # occurs - raise ValueError("nu <= 0 or nu > 1") + if sklearn_check_version("1.0"): + self._check_feature_names(X, reset=True) dispatch( self, "fit", diff --git a/sklearnex/svm/nusvr.py b/sklearnex/svm/nusvr.py index 1ddd5e24f4..a8cf49bfa1 100644 --- a/sklearnex/svm/nusvr.py +++ b/sklearnex/svm/nusvr.py @@ -71,17 +71,8 @@ def __init__( def fit(self, X, y, sample_weight=None): if sklearn_check_version("1.2"): self._validate_params() - elif self.nu <= 0 or self.nu > 1: - # else if added to correct issues with - # sklearn tests: - # svm/tests/test_sparse.py::test_error - # svm/tests/test_svm.py::test_bad_input - # for sklearn versions < 1.2 (i.e. without - # validate_params parameter checking) - # Without this, a segmentation fault with - # Windows fatal exception: access violation - # occurs - raise ValueError("nu <= 0 or nu > 1") + if sklearn_check_version("1.0"): + self._check_feature_names(X, reset=True) dispatch( self, "fit", diff --git a/sklearnex/svm/svc.py b/sklearnex/svm/svc.py index a64aad8e9d..62344c2403 100644 --- a/sklearnex/svm/svc.py +++ b/sklearnex/svm/svc.py @@ -90,17 +90,8 @@ def __init__( def fit(self, X, y, sample_weight=None): if sklearn_check_version("1.2"): self._validate_params() - elif self.C <= 0: - # else if added to correct issues with - # sklearn tests: - # svm/tests/test_sparse.py::test_error - # svm/tests/test_svm.py::test_bad_input - # for sklearn versions < 1.2 (i.e. without - # validate_params parameter checking) - # Without this, a segmentation fault with - # Windows fatal exception: access violation - # occurs - raise ValueError("C <= 0") + if sklearn_check_version("1.0"): + self._check_feature_names(X, reset=True) dispatch( self, "fit", diff --git a/sklearnex/svm/svr.py b/sklearnex/svm/svr.py index cd038a082a..cb2502812b 100644 --- a/sklearnex/svm/svr.py +++ b/sklearnex/svm/svr.py @@ -71,17 +71,8 @@ def __init__( def fit(self, X, y, sample_weight=None): if sklearn_check_version("1.2"): self._validate_params() - elif self.C <= 0: - # else if added to correct issues with - # sklearn tests: - # svm/tests/test_sparse.py::test_error - # svm/tests/test_svm.py::test_bad_input - # for sklearn versions < 1.2 (i.e. without - # validate_params parameter checking) - # Without this, a segmentation fault with - # Windows fatal exception: access violation - # occurs - raise ValueError("C <= 0") + if sklearn_check_version("1.0"): + self._check_feature_names(X, reset=True) dispatch( self, "fit", From 9f8727cf7835e23eadc31ba8885ce75d2343857d Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Mon, 7 Oct 2024 11:53:50 +0100 Subject: [PATCH 2/2] Revert "CI: deselect failing NuSVC tests (#1929)" This reverts commit a2f4f5d25736d7d48eb11a613fc44dd8b17f2962. --- deselected_tests.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/deselected_tests.yaml b/deselected_tests.yaml index d96ae6adb7..58966ded27 100755 --- a/deselected_tests.yaml +++ b/deselected_tests.yaml @@ -153,8 +153,6 @@ deselected_tests: # scikit-learn expects an exception for sparse matrices with 64-bit integer indices, # scikit-learn-intelex works correctly with 64-bit integer indices - tests/test_common.py::test_estimators[NuSVC()-check_estimator_sparse_data] - - tests/test_common.py::test_estimators[NuSVC()-check_estimator_sparse_array] - - tests/test_common.py::test_estimators[NuSVC()-check_estimator_sparse_matrix] - utils/tests/test_estimator_checks.py::test_xfail_ignored_in_check_estimator # SVC._dual_coef_ is changing after fitting, but the result of prediction is still the same