From d6e58b98c580ca29aa985a94852912b06c220c75 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Fri, 22 Mar 2024 13:47:43 -0700 Subject: [PATCH 1/2] Address PytestReturnNotNoneWarning in cuml tests --- python/cuml/tests/test_api.py | 4 +--- python/cuml/tests/test_nearest_neighbors.py | 13 +++++++++---- python/pyproject.toml | 10 +++++++++- python/pytest.ini | 20 -------------------- 4 files changed, 19 insertions(+), 28 deletions(-) delete mode 100644 python/pytest.ini diff --git a/python/cuml/tests/test_api.py b/python/cuml/tests/test_api.py index 8d13499171..74adbd177d 100644 --- a/python/cuml/tests/test_api.py +++ b/python/cuml/tests/test_api.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2020-2023, NVIDIA CORPORATION. +# Copyright (c) 2020-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -158,8 +158,6 @@ def test_get_tags(model): else: assert isinstance(model_tags[tag], tag_type) - return True - def test_dynamic_tags_and_composition(): static_tags = dummy_class_with_tags._get_tags() diff --git a/python/cuml/tests/test_nearest_neighbors.py b/python/cuml/tests/test_nearest_neighbors.py index 2ad3898c7d..9f5764a7e9 100644 --- a/python/cuml/tests/test_nearest_neighbors.py +++ b/python/cuml/tests/test_nearest_neighbors.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2019-2023, NVIDIA CORPORATION. +# Copyright (c) 2019-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -299,7 +299,7 @@ def test_ivfpq_pred( if metric in cuml.neighbors.VALID_METRICS[algo] ], ) -def test_ann_distances_metrics(algo, metric): +def test_ann_distances_metrics(algo, metric, request): X, y = make_blobs(n_samples=500, centers=2, n_features=128, random_state=0) cu_knn = cuKNN(algorithm=algo, metric=metric) @@ -316,8 +316,13 @@ def test_ann_distances_metrics(algo, metric): sk_dist, sk_ind = sk_knn.kneighbors( X, n_neighbors=10, return_distance=True ) - - return array_equal(sk_dist, cu_dist) + request.applymarker( + pytest.mark.xfail( + not (algo == "brute" and metric in ("cosine", "correlation")), + reason=f"arrays not equal with {algo=} and {metric=}", + ) + ) + assert bool(array_equal(sk_dist, cu_dist)) def test_return_dists(): diff --git a/python/pyproject.toml b/python/pyproject.toml index 5a699f3b8f..8d41c2fd72 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -35,10 +35,18 @@ markers = [ "no_bad_cuml_array_check: Test that should not check for bad CumlArray uses", ] -testpaths = "cuml/tests" +testpaths = [ + "cuml/tests", + "cuml/tests/dask", + "cuml/tests/experimental", + "cuml/tests/explainer", + "cuml/tests/stemmer_tests", + "cuml/tests", +] filterwarnings = [ "error::FutureWarning:cuml[.*]", # Catch uses of deprecated positional args in testing + "error::pytest.PytestReturnNotNoneWarning", "error:::cudf", "ignore:[^.]*ABCs[^.]*:DeprecationWarning:patsy[.*]", "ignore:(.*)alias(.*):DeprecationWarning:hdbscan[.*]", diff --git a/python/pytest.ini b/python/pytest.ini deleted file mode 100644 index 1946ee58f2..0000000000 --- a/python/pytest.ini +++ /dev/null @@ -1,20 +0,0 @@ -[pytest] -markers = - unit: Quickest tests focused on accuracy and correctness - quality: More intense tests than unit with increased runtimes - stress: Longest running tests focused on stressing hardware compute resources - mg: Multi-GPU tests - memleak: Test that checks for memory leaks - no_bad_cuml_array_check: Test that should not check for bad CumlArray uses - -testpaths = - cuml/tests - cuml/tests/dask - cuml/tests/experimental - cuml/tests/explainer - cuml/tests/stemmer_tests - -filterwarnings = - error::FutureWarning:cuml[.*] # Catch uses of deprecated positional args in testing - ignore:[^.]*ABCs[^.]*:DeprecationWarning:patsy[.*] - ignore:(.*)alias(.*):DeprecationWarning:hdbscan[.*] From 0c06325ce54b8ec10764627bcf699946ad2b4f63 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Tue, 26 Mar 2024 17:10:10 -0700 Subject: [PATCH 2/2] Undo config file changes --- python/pyproject.toml | 10 +--------- python/pytest.ini | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 python/pytest.ini diff --git a/python/pyproject.toml b/python/pyproject.toml index 8d41c2fd72..5a699f3b8f 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -35,18 +35,10 @@ markers = [ "no_bad_cuml_array_check: Test that should not check for bad CumlArray uses", ] -testpaths = [ - "cuml/tests", - "cuml/tests/dask", - "cuml/tests/experimental", - "cuml/tests/explainer", - "cuml/tests/stemmer_tests", - "cuml/tests", -] +testpaths = "cuml/tests" filterwarnings = [ "error::FutureWarning:cuml[.*]", # Catch uses of deprecated positional args in testing - "error::pytest.PytestReturnNotNoneWarning", "error:::cudf", "ignore:[^.]*ABCs[^.]*:DeprecationWarning:patsy[.*]", "ignore:(.*)alias(.*):DeprecationWarning:hdbscan[.*]", diff --git a/python/pytest.ini b/python/pytest.ini new file mode 100644 index 0000000000..1946ee58f2 --- /dev/null +++ b/python/pytest.ini @@ -0,0 +1,20 @@ +[pytest] +markers = + unit: Quickest tests focused on accuracy and correctness + quality: More intense tests than unit with increased runtimes + stress: Longest running tests focused on stressing hardware compute resources + mg: Multi-GPU tests + memleak: Test that checks for memory leaks + no_bad_cuml_array_check: Test that should not check for bad CumlArray uses + +testpaths = + cuml/tests + cuml/tests/dask + cuml/tests/experimental + cuml/tests/explainer + cuml/tests/stemmer_tests + +filterwarnings = + error::FutureWarning:cuml[.*] # Catch uses of deprecated positional args in testing + ignore:[^.]*ABCs[^.]*:DeprecationWarning:patsy[.*] + ignore:(.*)alias(.*):DeprecationWarning:hdbscan[.*]