Skip to content

Commit

Permalink
Address PytestReturnNotNoneWarning in cuml tests (#5819)
Browse files Browse the repository at this point in the history
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: #5819
  • Loading branch information
mroeschke authored Apr 13, 2024
1 parent 8fa078b commit 6a08a60
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 1 addition & 3 deletions python/cuml/tests/test_api.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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()
Expand Down
13 changes: 9 additions & 4 deletions python/cuml/tests/test_nearest_neighbors.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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)
Expand All @@ -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():
Expand Down

0 comments on commit 6a08a60

Please sign in to comment.