Skip to content

Commit

Permalink
MAINT: reduce code duplication; make common skip func (#2084)
Browse files Browse the repository at this point in the history
* MAINT: reduce code duplication; make common skip func

* update disable message.

---------

Co-authored-by: Alexander Andreev <alexander.andreev@intel.com>
  • Loading branch information
samir-nasibli and Alexsandruss authored Oct 4, 2024
1 parent a2b9bf3 commit 2f73b9d
Showing 1 changed file with 15 additions and 32 deletions.
47 changes: 15 additions & 32 deletions sklearnex/tests/test_run_to_run_stability.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ def _run_test(estimator, method, datasets):
)


def _skip_neighbors(estimator, method):
if (
not _IS_INTEL
and ("Neighbors" in estimator or "LocalOutlierFactor" in estimator)
and method in ["score", "predict", "kneighbors", "kneighbors_graph"]
):
if daal_check_version((2025, "P", 200)):
pytest.fail("Re-verify failure of algorithms in oneDAL 2025.2")
pytest.skip(f"{estimator} shows instability on non-Intel(R) hardware")


@pytest.mark.parametrize("dataframe, queue", get_dataframes_and_queues("numpy,array_api"))
@pytest.mark.parametrize("estimator, method", gen_models_info(PATCHED_MODELS))
def test_standard_estimator_stability(estimator, method, dataframe, queue):
Expand All @@ -155,14 +166,7 @@ def test_standard_estimator_stability(estimator, method, dataframe, queue):
pytest.skip(f"variation observed in {estimator}.score")
if estimator in ["IncrementalEmpiricalCovariance"] and method == "mahalanobis":
pytest.skip("allowed fallback to sklearn occurs")
if (
not _IS_INTEL
and ("Neighbors" in estimator or "LocalOutlierFactor" in estimator)
and method in ["score", "predict", "kneighbors", "kneighbors_graph"]
):
if daal_check_version((2025, "P", 200)):
pytest.fail("Re-verify failure of algorithms in 2025.2 oneDAL")
pytest.skip(f"{estimator} shows instability on Non-Intel hardware")
_skip_neighbors(estimator, method)

if "NearestNeighbors" in estimator and "radius" in method:
pytest.skip(f"RadiusNeighbors estimator not implemented in sklearnex")
Expand Down Expand Up @@ -191,14 +195,7 @@ def test_special_estimator_stability(estimator, method, dataframe, queue):
pytest.skip(f"variation observed in KMeans.score")
if "NearestNeighbors" in estimator and "radius" in method:
pytest.skip(f"RadiusNeighbors estimator not implemented in sklearnex")
if (
not _IS_INTEL
and ("Neighbors" in estimator or "LocalOutlierFactor" in estimator)
and method in ["score", "predict", "kneighbors", "kneighbors_graph"]
):
if daal_check_version((2025, "P", 200)):
pytest.fail("Re-verify failure of algorithms in 2025.2 oneDAL")
pytest.skip(f"{estimator} shows instability on Non-Intel hardware")
_skip_neighbors(estimator, method)

est = SPECIAL_INSTANCES[estimator]

Expand Down Expand Up @@ -227,14 +224,7 @@ def test_sparse_estimator_stability(estimator, method, dataframe, queue):
pytest.skip(f"variation observed in KMeans.{method} in 2024.7 oneDAL")
if "NearestNeighbors" in estimator and "radius" in method:
pytest.skip(f"RadiusNeighbors estimator not implemented in sklearnex")
if (
not _IS_INTEL
and ("Neighbors" in estimator or "LocalOutlierFactor" in estimator)
and method in ["score", "predict", "kneighbors", "kneighbors_graph"]
):
if daal_check_version((2025, "P", 200)):
pytest.fail("Re-verify failure of algorithms in 2025.2 oneDAL")
pytest.skip(f"{estimator} shows instability on Non-Intel hardware")
_skip_neighbors(estimator, method)

est = SPARSE_INSTANCES[estimator]

Expand All @@ -259,14 +249,7 @@ def test_other_estimator_stability(estimator, method, dataframe, queue):
pytest.skip(f"variation observed in KMeans.score")
if "NearestNeighbors" in estimator and "radius" in method:
pytest.skip(f"RadiusNeighbors estimator not implemented in sklearnex")
if (
not _IS_INTEL
and ("Neighbors" in estimator or "LocalOutlierFactor" in estimator)
and method in ["score", "predict", "kneighbors", "kneighbors_graph"]
):
if daal_check_version((2025, "P", 200)):
pytest.fail("Re-verify failure of algorithms in 2025.2 oneDAL")
pytest.skip(f"{estimator} shows instability on Non-Intel hardware")
_skip_neighbors(estimator, method)

est = STABILITY_INSTANCES[estimator]

Expand Down

0 comments on commit 2f73b9d

Please sign in to comment.