From 6a08a605ca8138b440d336e1abe36e872857c198 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Fri, 12 Apr 2024 14:33:15 -1000 Subject: [PATCH] Address PytestReturnNotNoneWarning in cuml tests (#5819) Appears in the future `pytest` will raise when a test function `return`s a non `None` value. There was 2 tests that had this pattern and adjusted the tests as appropriate. Authors: - Matthew Roeschke (https://github.com/mroeschke) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/cuml/pull/5819 --- python/cuml/tests/test_api.py | 4 +--- python/cuml/tests/test_nearest_neighbors.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) 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():