From 6c185e096999764692238ec73908c0b841121d83 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Wed, 13 Nov 2024 05:19:36 -0800 Subject: [PATCH 1/7] chore: make get_hyperparameters() a static method --- sklearnex/_utils.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sklearnex/_utils.py b/sklearnex/_utils.py index 83fada1824..17db373b8e 100755 --- a/sklearnex/_utils.py +++ b/sklearnex/_utils.py @@ -106,14 +106,17 @@ def register_hyperparameters(hyperparameters_map): Adds `get_hyperparameters` method to class. """ - def wrap_class(estimator_class): - def get_hyperparameters(self, op): + def decorator(cls): + """Add `get_hyperparameters()` static method""" + + @staticmethod + def get_hyperparameters(op): return hyperparameters_map[op] - estimator_class.get_hyperparameters = get_hyperparameters - return estimator_class + cls.get_hyperparameters = get_hyperparameters + return cls - return wrap_class + return decorator # This abstract class is meant to generate a clickable doc link for classses From 0b0ff19aabba52ced77e85a345881314d20faefa Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Wed, 13 Nov 2024 05:24:28 -0800 Subject: [PATCH 2/7] chore: remove unused import --- sklearnex/_utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sklearnex/_utils.py b/sklearnex/_utils.py index 17db373b8e..324f021fea 100755 --- a/sklearnex/_utils.py +++ b/sklearnex/_utils.py @@ -16,7 +16,6 @@ import logging import os -import sys import warnings from abc import ABC From 58d84e835d716dcb4f7509f7634b6b72c4ff10d2 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Wed, 13 Nov 2024 05:59:22 -0800 Subject: [PATCH 3/7] feat: Add a StaticOnlyMethod that issues an Error/Warning when called on instance --- onedal/common/tests/test_hyperparameters.py | 16 +++++++ onedal/common/tests/test_staticonlymethod.py | 42 +++++++++++++++++ sklearnex/_utils.py | 46 ++++++++++++++++++- sklearnex/ensemble/tests/test_forest.py | 7 ++- .../tests/test_incremental_linear.py | 9 ++-- sklearnex/linear_model/tests/test_linear.py | 9 ++-- .../covariance/tests/test_covariance.py | 5 +- .../tests/test_incremental_linear_spmd.py | 17 ++++--- 8 files changed, 124 insertions(+), 27 deletions(-) create mode 100644 onedal/common/tests/test_hyperparameters.py create mode 100644 onedal/common/tests/test_staticonlymethod.py diff --git a/onedal/common/tests/test_hyperparameters.py b/onedal/common/tests/test_hyperparameters.py new file mode 100644 index 0000000000..d21f40f2ff --- /dev/null +++ b/onedal/common/tests/test_hyperparameters.py @@ -0,0 +1,16 @@ +import pytest +from sklearnex._utils import register_hyperparameters + + +def test_register_hyperparameters(): + hyperparameters_map = {"op": "hyperparameters"} + + @register_hyperparameters(hyperparameters_map) + class Test: + pass + + # assert the correct value is returned + assert Test.get_hyperparameters("op") == "hyperparameters" + # assert a warning is issued when trying to modify the hyperparameters per instance + with pytest.warns(Warning): + Test().get_hyperparameters("op") diff --git a/onedal/common/tests/test_staticonlymethod.py b/onedal/common/tests/test_staticonlymethod.py new file mode 100644 index 0000000000..52f72ab726 --- /dev/null +++ b/onedal/common/tests/test_staticonlymethod.py @@ -0,0 +1,42 @@ +import pytest +from sklearnex._utils import StaticOnlyMethod + + +def test_staticonlymethod_default_args(): + class Test: + @StaticOnlyMethod + def test_static_method(): + pass + + with pytest.raises(AttributeError): + Test().test_static_method() + + assert Test.test_static_method() is None + + +def test_staticonlymethod_custom_exception(): + """Can raise a custom exception when called on an instance.""" + + class Test: + @StaticOnlyMethod(instance_call_behavior=ValueError("Custom error")) + def test_static_method(): + pass + + with pytest.raises(ValueError): + Test().test_static_method() + + assert Test.test_static_method() is None + + +def test_staticonlymethod_custom_warning(): + """Can raise a custom warning when called on an instance.""" + + class Test: + @StaticOnlyMethod(instance_call_behavior=Warning("Custom warning")) + def test_static_method(): + pass + + with pytest.warns(Warning): + Test().test_static_method() + + assert Test.test_static_method() is None diff --git a/sklearnex/_utils.py b/sklearnex/_utils.py index 324f021fea..7ca91ace15 100755 --- a/sklearnex/_utils.py +++ b/sklearnex/_utils.py @@ -25,6 +25,46 @@ from daal4py.sklearn._utils import daal_check_version +class StaticOnlyMethod: + """Descriptor for static methods only. Raises an exception if called on an instance. + + Parameters + ---------- + func : callable + The function to be decorated. + instance_call_behavior : None or Exception or Warning, default=None + The behavior when the method is called on an instance. + If None, AttributeError is raised. + If an Exception or Warning, it is raised or warned respectively. + """ + + def __init__(self, func=None, instance_call_behavior=None): + self.func = func + if instance_call_behavior is None: + self.on_instance_call = AttributeError( + "This method can only be called on the class, not on an instance." + ) + elif isinstance(instance_call_behavior, (Exception, Warning)): + self.on_instance_call = instance_call_behavior + else: + raise ValueError( + f"Invalid input - expected None or an Exception, got {instance_call_behavior}" + ) + + def __call__(self, func): + self.func = func + return self + + def __get__(self, instance, _): + if instance is not None: + if isinstance(self.on_instance_call, Warning): + warnings.warn(self.on_instance_call) + else: + raise self.on_instance_call + + return self.func + + class PatchingConditionsChain(daal4py_PatchingConditionsChain): def get_status(self): return self.patching_is_enabled @@ -108,7 +148,11 @@ def register_hyperparameters(hyperparameters_map): def decorator(cls): """Add `get_hyperparameters()` static method""" - @staticmethod + @StaticOnlyMethod( + instance_call_behavior=Warning( + "Hyperparameters are static variables and can not be modified per instance." + ) + ) def get_hyperparameters(op): return hyperparameters_map[op] diff --git a/sklearnex/ensemble/tests/test_forest.py b/sklearnex/ensemble/tests/test_forest.py index ac0a2aa768..f2253519bb 100644 --- a/sklearnex/ensemble/tests/test_forest.py +++ b/sklearnex/ensemble/tests/test_forest.py @@ -15,15 +15,14 @@ # =============================================================================== import pytest -from numpy.testing import assert_allclose -from sklearn.datasets import make_classification, make_regression - from daal4py.sklearn._utils import daal_check_version +from numpy.testing import assert_allclose from onedal.tests.utils._dataframes_support import ( _as_numpy, _convert_to_dataframe, get_dataframes_and_queues, ) +from sklearn.datasets import make_classification, make_regression hparam_values = [ (None, None, None, None), @@ -51,7 +50,7 @@ def test_sklearnex_import_rf_classifier(dataframe, queue, block, trees, rows, sc X = _convert_to_dataframe(X, sycl_queue=queue, target_df=dataframe) y = _convert_to_dataframe(y, sycl_queue=queue, target_df=dataframe) rf = RandomForestClassifier(max_depth=2, random_state=0).fit(X, y) - hparams = rf.get_hyperparameters("infer") + hparams = RandomForestClassifier.get_hyperparameters("infer") if hparams and block is not None: hparams.block_size = block hparams.min_trees_for_threading = trees diff --git a/sklearnex/linear_model/tests/test_incremental_linear.py b/sklearnex/linear_model/tests/test_incremental_linear.py index d4a96b8994..7c1b77dd47 100644 --- a/sklearnex/linear_model/tests/test_incremental_linear.py +++ b/sklearnex/linear_model/tests/test_incremental_linear.py @@ -17,7 +17,6 @@ import numpy as np import pytest from numpy.testing import assert_allclose - from onedal.tests.utils._dataframes_support import ( _as_numpy, _convert_to_dataframe, @@ -41,7 +40,7 @@ def test_sklearnex_fit_on_gold_data(dataframe, queue, fit_intercept, macro_block inclin = IncrementalLinearRegression(fit_intercept=fit_intercept) if macro_block is not None: - hparams = inclin.get_hyperparameters("fit") + hparams = IncrementalLinearRegression.get_hyperparameters("fit") hparams.cpu_macro_block = macro_block hparams.gpu_macro_block = macro_block inclin.fit(X_df, y_df) @@ -72,7 +71,7 @@ def test_sklearnex_partial_fit_on_gold_data( inclin = IncrementalLinearRegression() if macro_block is not None: - hparams = inclin.get_hyperparameters("fit") + hparams = IncrementalLinearRegression.get_hyperparameters("fit") hparams.cpu_macro_block = macro_block hparams.gpu_macro_block = macro_block for i in range(2): @@ -113,7 +112,7 @@ def test_sklearnex_partial_fit_multitarget_on_gold_data( inclin = IncrementalLinearRegression() if macro_block is not None: - hparams = inclin.get_hyperparameters("fit") + hparams = IncrementalLinearRegression.get_hyperparameters("fit") hparams.cpu_macro_block = macro_block hparams.gpu_macro_block = macro_block for i in range(2): @@ -176,7 +175,7 @@ def test_sklearnex_partial_fit_on_random_data( inclin = IncrementalLinearRegression(fit_intercept=fit_intercept) if macro_block is not None: - hparams = inclin.get_hyperparameters("fit") + hparams = IncrementalLinearRegression.get_hyperparameters("fit") hparams.cpu_macro_block = macro_block hparams.gpu_macro_block = macro_block for i in range(num_blocks): diff --git a/sklearnex/linear_model/tests/test_linear.py b/sklearnex/linear_model/tests/test_linear.py index f50bc6e0c6..0b213c5a94 100644 --- a/sklearnex/linear_model/tests/test_linear.py +++ b/sklearnex/linear_model/tests/test_linear.py @@ -16,20 +16,19 @@ import numpy as np import pytest -from numpy.testing import assert_allclose -from scipy.linalg import lstsq -from sklearn.datasets import make_regression - from daal4py.sklearn._utils import daal_check_version from daal4py.sklearn.linear_model.tests.test_ridge import ( _test_multivariate_ridge_alpha_shape, _test_multivariate_ridge_coefficients, ) +from numpy.testing import assert_allclose from onedal.tests.utils._dataframes_support import ( _as_numpy, _convert_to_dataframe, get_dataframes_and_queues, ) +from scipy.linalg import lstsq +from sklearn.datasets import make_regression from sklearnex.tests.utils import _IS_INTEL @@ -61,7 +60,7 @@ def test_sklearnex_import_linear( linreg = LinearRegression() if daal_check_version((2024, "P", 0)) and macro_block is not None: - hparams = linreg.get_hyperparameters("fit") + hparams = LinearRegression.get_hyperparameters("fit") hparams.cpu_macro_block = macro_block hparams.gpu_macro_block = macro_block diff --git a/sklearnex/preview/covariance/tests/test_covariance.py b/sklearnex/preview/covariance/tests/test_covariance.py index ad76b28ebb..3e7d7ae29f 100644 --- a/sklearnex/preview/covariance/tests/test_covariance.py +++ b/sklearnex/preview/covariance/tests/test_covariance.py @@ -16,9 +16,8 @@ import numpy as np import pytest -from numpy.testing import assert_allclose - from daal4py.sklearn._utils import daal_check_version +from numpy.testing import assert_allclose from onedal.tests.utils._dataframes_support import ( _convert_to_dataframe, get_dataframes_and_queues, @@ -36,7 +35,7 @@ def test_sklearnex_import_covariance(dataframe, queue, macro_block, assume_cente X = _convert_to_dataframe(X, sycl_queue=queue, target_df=dataframe) empcov = EmpiricalCovariance(assume_centered=assume_centered) if daal_check_version((2024, "P", 0)) and macro_block is not None: - hparams = empcov.get_hyperparameters("fit") + hparams = EmpiricalCovariance.get_hyperparameters("fit") hparams.cpu_macro_block = macro_block result = empcov.fit(X) diff --git a/sklearnex/spmd/linear_model/tests/test_incremental_linear_spmd.py b/sklearnex/spmd/linear_model/tests/test_incremental_linear_spmd.py index 4db9975754..cc79b5788e 100644 --- a/sklearnex/spmd/linear_model/tests/test_incremental_linear_spmd.py +++ b/sklearnex/spmd/linear_model/tests/test_incremental_linear_spmd.py @@ -17,7 +17,6 @@ import numpy as np import pytest from numpy.testing import assert_allclose - from onedal.tests.utils._dataframes_support import ( _as_numpy, _convert_to_dataframe, @@ -86,11 +85,11 @@ def test_incremental_linear_regression_fit_spmd_gold( inclin = IncrementalLinearRegression(fit_intercept=fit_intercept) if macro_block is not None: - hparams = inclin.get_hyperparameters("fit") + hparams = IncrementalLinearRegression.get_hyperparameters("fit") hparams.cpu_macro_block = macro_block hparams.gpu_macro_block = macro_block - hparams_spmd = inclin_spmd.get_hyperparameters("fit") + hparams_spmd = IncrementalLinearRegression_SPMD.get_hyperparameters("fit") hparams_spmd.cpu_macro_block = macro_block hparams_spmd.gpu_macro_block = macro_block @@ -159,11 +158,11 @@ def test_incremental_linear_regression_partial_fit_spmd_gold( inclin = IncrementalLinearRegression(fit_intercept=fit_intercept) if macro_block is not None: - hparams = inclin.get_hyperparameters("fit") + hparams = IncrementalLinearRegression.get_hyperparameters("fit") hparams.cpu_macro_block = macro_block hparams.gpu_macro_block = macro_block - hparams_spmd = inclin_spmd.get_hyperparameters("fit") + hparams_spmd = IncrementalLinearRegression_SPMD.get_hyperparameters("fit") hparams_spmd.cpu_macro_block = macro_block hparams_spmd.gpu_macro_block = macro_block @@ -225,11 +224,11 @@ def test_incremental_linear_regression_fit_spmd_random( inclin = IncrementalLinearRegression(fit_intercept=fit_intercept) if macro_block is not None: - hparams = inclin.get_hyperparameters("fit") + hparams = IncrementalLinearRegression.get_hyperparameters("fit") hparams.cpu_macro_block = macro_block hparams.gpu_macro_block = macro_block - hparams_spmd = inclin_spmd.get_hyperparameters("fit") + hparams_spmd = IncrementalLinearRegression_SPMD.get_hyperparameters("fit") hparams_spmd.cpu_macro_block = macro_block hparams_spmd.gpu_macro_block = macro_block @@ -298,11 +297,11 @@ def test_incremental_linear_regression_partial_fit_spmd_random( inclin = IncrementalLinearRegression(fit_intercept=fit_intercept) if macro_block is not None: - hparams = inclin.get_hyperparameters("fit") + hparams = IncrementalLinearRegression.get_hyperparameters("fit") hparams.cpu_macro_block = macro_block hparams.gpu_macro_block = macro_block - hparams_spmd = inclin_spmd.get_hyperparameters("fit") + hparams_spmd = IncrementalLinearRegression_SPMD.get_hyperparameters("fit") hparams_spmd.cpu_macro_block = macro_block hparams_spmd.gpu_macro_block = macro_block From b810e4a4f64270d8dcfcd257d1e853c382ce38a7 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Wed, 13 Nov 2024 06:22:11 -0800 Subject: [PATCH 4/7] chore: refactor and simplify --- onedal/common/tests/test_staticonlymethod.py | 42 ------------------- sklearnex/_utils.py | 21 ++++++---- .../tests/test_hyperparameters.py | 9 ++++ 3 files changed, 21 insertions(+), 51 deletions(-) delete mode 100644 onedal/common/tests/test_staticonlymethod.py rename {onedal/common => sklearnex}/tests/test_hyperparameters.py (72%) diff --git a/onedal/common/tests/test_staticonlymethod.py b/onedal/common/tests/test_staticonlymethod.py deleted file mode 100644 index 52f72ab726..0000000000 --- a/onedal/common/tests/test_staticonlymethod.py +++ /dev/null @@ -1,42 +0,0 @@ -import pytest -from sklearnex._utils import StaticOnlyMethod - - -def test_staticonlymethod_default_args(): - class Test: - @StaticOnlyMethod - def test_static_method(): - pass - - with pytest.raises(AttributeError): - Test().test_static_method() - - assert Test.test_static_method() is None - - -def test_staticonlymethod_custom_exception(): - """Can raise a custom exception when called on an instance.""" - - class Test: - @StaticOnlyMethod(instance_call_behavior=ValueError("Custom error")) - def test_static_method(): - pass - - with pytest.raises(ValueError): - Test().test_static_method() - - assert Test.test_static_method() is None - - -def test_staticonlymethod_custom_warning(): - """Can raise a custom warning when called on an instance.""" - - class Test: - @StaticOnlyMethod(instance_call_behavior=Warning("Custom warning")) - def test_static_method(): - pass - - with pytest.warns(Warning): - Test().test_static_method() - - assert Test.test_static_method() is None diff --git a/sklearnex/_utils.py b/sklearnex/_utils.py index 7ca91ace15..01d94c2127 100755 --- a/sklearnex/_utils.py +++ b/sklearnex/_utils.py @@ -148,15 +148,18 @@ def register_hyperparameters(hyperparameters_map): def decorator(cls): """Add `get_hyperparameters()` static method""" - @StaticOnlyMethod( - instance_call_behavior=Warning( - "Hyperparameters are static variables and can not be modified per instance." - ) - ) - def get_hyperparameters(op): - return hyperparameters_map[op] - - cls.get_hyperparameters = get_hyperparameters + class StaticHyperparametersAccessor: + def __get__(self, instance, _): + if instance is not None: + warnings.warn( + "Hyperparameters are static variables and can not be modified per instance." + ) + return self.get_hyperparameters + + def get_hyperparameters(self, op): + return hyperparameters_map[op] + + cls.get_hyperparameters = StaticHyperparametersAccessor() return cls return decorator diff --git a/onedal/common/tests/test_hyperparameters.py b/sklearnex/tests/test_hyperparameters.py similarity index 72% rename from onedal/common/tests/test_hyperparameters.py rename to sklearnex/tests/test_hyperparameters.py index d21f40f2ff..1610f4b4a4 100644 --- a/onedal/common/tests/test_hyperparameters.py +++ b/sklearnex/tests/test_hyperparameters.py @@ -11,6 +11,15 @@ class Test: # assert the correct value is returned assert Test.get_hyperparameters("op") == "hyperparameters" + + +def test_register_hyperparameters_issues_warning(): + hyperparameters_map = {"op": "hyperparameters"} + + @register_hyperparameters(hyperparameters_map) + class Test: + pass + # assert a warning is issued when trying to modify the hyperparameters per instance with pytest.warns(Warning): Test().get_hyperparameters("op") From bc5dcf29660e61f498627f4f65cef3cc2d16adb8 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Wed, 13 Nov 2024 06:24:28 -0800 Subject: [PATCH 5/7] chore: remove unused class --- sklearnex/_utils.py | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/sklearnex/_utils.py b/sklearnex/_utils.py index 01d94c2127..fa70bb04df 100755 --- a/sklearnex/_utils.py +++ b/sklearnex/_utils.py @@ -25,46 +25,6 @@ from daal4py.sklearn._utils import daal_check_version -class StaticOnlyMethod: - """Descriptor for static methods only. Raises an exception if called on an instance. - - Parameters - ---------- - func : callable - The function to be decorated. - instance_call_behavior : None or Exception or Warning, default=None - The behavior when the method is called on an instance. - If None, AttributeError is raised. - If an Exception or Warning, it is raised or warned respectively. - """ - - def __init__(self, func=None, instance_call_behavior=None): - self.func = func - if instance_call_behavior is None: - self.on_instance_call = AttributeError( - "This method can only be called on the class, not on an instance." - ) - elif isinstance(instance_call_behavior, (Exception, Warning)): - self.on_instance_call = instance_call_behavior - else: - raise ValueError( - f"Invalid input - expected None or an Exception, got {instance_call_behavior}" - ) - - def __call__(self, func): - self.func = func - return self - - def __get__(self, instance, _): - if instance is not None: - if isinstance(self.on_instance_call, Warning): - warnings.warn(self.on_instance_call) - else: - raise self.on_instance_call - - return self.func - - class PatchingConditionsChain(daal4py_PatchingConditionsChain): def get_status(self): return self.patching_is_enabled From cbe8e2e7bbf66cfea705204b127dede4ca037605 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Thu, 14 Nov 2024 00:12:01 -0800 Subject: [PATCH 6/7] chore: add a class description --- sklearnex/_utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sklearnex/_utils.py b/sklearnex/_utils.py index fa70bb04df..651ac72654 100755 --- a/sklearnex/_utils.py +++ b/sklearnex/_utils.py @@ -109,6 +109,8 @@ def decorator(cls): """Add `get_hyperparameters()` static method""" class StaticHyperparametersAccessor: + """Like a @staticmethod, but additionally raises a Warning when called on an instance.""" + def __get__(self, instance, _): if instance is not None: warnings.warn( From 40b56e1edc6951f0d8423ebe956ab7bd144e52d7 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Thu, 14 Nov 2024 00:13:16 -0800 Subject: [PATCH 7/7] chore: isort --- sklearnex/ensemble/tests/test_forest.py | 5 +++-- sklearnex/linear_model/tests/test_incremental_linear.py | 1 + sklearnex/linear_model/tests/test_linear.py | 7 ++++--- sklearnex/preview/covariance/tests/test_covariance.py | 3 ++- .../linear_model/tests/test_incremental_linear_spmd.py | 1 + sklearnex/tests/test_hyperparameters.py | 1 + 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/sklearnex/ensemble/tests/test_forest.py b/sklearnex/ensemble/tests/test_forest.py index f2253519bb..6dee02ce6b 100644 --- a/sklearnex/ensemble/tests/test_forest.py +++ b/sklearnex/ensemble/tests/test_forest.py @@ -15,14 +15,15 @@ # =============================================================================== import pytest -from daal4py.sklearn._utils import daal_check_version from numpy.testing import assert_allclose +from sklearn.datasets import make_classification, make_regression + +from daal4py.sklearn._utils import daal_check_version from onedal.tests.utils._dataframes_support import ( _as_numpy, _convert_to_dataframe, get_dataframes_and_queues, ) -from sklearn.datasets import make_classification, make_regression hparam_values = [ (None, None, None, None), diff --git a/sklearnex/linear_model/tests/test_incremental_linear.py b/sklearnex/linear_model/tests/test_incremental_linear.py index 7c1b77dd47..af25373ef6 100644 --- a/sklearnex/linear_model/tests/test_incremental_linear.py +++ b/sklearnex/linear_model/tests/test_incremental_linear.py @@ -17,6 +17,7 @@ import numpy as np import pytest from numpy.testing import assert_allclose + from onedal.tests.utils._dataframes_support import ( _as_numpy, _convert_to_dataframe, diff --git a/sklearnex/linear_model/tests/test_linear.py b/sklearnex/linear_model/tests/test_linear.py index 0b213c5a94..d1369d0edb 100644 --- a/sklearnex/linear_model/tests/test_linear.py +++ b/sklearnex/linear_model/tests/test_linear.py @@ -16,19 +16,20 @@ import numpy as np import pytest +from numpy.testing import assert_allclose +from scipy.linalg import lstsq +from sklearn.datasets import make_regression + from daal4py.sklearn._utils import daal_check_version from daal4py.sklearn.linear_model.tests.test_ridge import ( _test_multivariate_ridge_alpha_shape, _test_multivariate_ridge_coefficients, ) -from numpy.testing import assert_allclose from onedal.tests.utils._dataframes_support import ( _as_numpy, _convert_to_dataframe, get_dataframes_and_queues, ) -from scipy.linalg import lstsq -from sklearn.datasets import make_regression from sklearnex.tests.utils import _IS_INTEL diff --git a/sklearnex/preview/covariance/tests/test_covariance.py b/sklearnex/preview/covariance/tests/test_covariance.py index 3e7d7ae29f..71eb9235c3 100644 --- a/sklearnex/preview/covariance/tests/test_covariance.py +++ b/sklearnex/preview/covariance/tests/test_covariance.py @@ -16,8 +16,9 @@ import numpy as np import pytest -from daal4py.sklearn._utils import daal_check_version from numpy.testing import assert_allclose + +from daal4py.sklearn._utils import daal_check_version from onedal.tests.utils._dataframes_support import ( _convert_to_dataframe, get_dataframes_and_queues, diff --git a/sklearnex/spmd/linear_model/tests/test_incremental_linear_spmd.py b/sklearnex/spmd/linear_model/tests/test_incremental_linear_spmd.py index cc79b5788e..3228b52c54 100644 --- a/sklearnex/spmd/linear_model/tests/test_incremental_linear_spmd.py +++ b/sklearnex/spmd/linear_model/tests/test_incremental_linear_spmd.py @@ -17,6 +17,7 @@ import numpy as np import pytest from numpy.testing import assert_allclose + from onedal.tests.utils._dataframes_support import ( _as_numpy, _convert_to_dataframe, diff --git a/sklearnex/tests/test_hyperparameters.py b/sklearnex/tests/test_hyperparameters.py index 1610f4b4a4..837da20e77 100644 --- a/sklearnex/tests/test_hyperparameters.py +++ b/sklearnex/tests/test_hyperparameters.py @@ -1,4 +1,5 @@ import pytest + from sklearnex._utils import register_hyperparameters