Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict HDBSCAN metric options to L2 #5415 #5492

Merged
merged 9 commits into from
Aug 1, 2023

Conversation

Rvch7
Copy link
Contributor

@Rvch7 Rvch7 commented Jul 6, 2023

This PR restricts HDBSCAN metric option to only L2. if any other metric is used it gives error message "'metric' [given metric] not supported(only 'l2' or 'euclidean' is supported)"

@Rvch7 Rvch7 requested a review from a team as a code owner July 6, 2023 00:03
@rapids-bot
Copy link

rapids-bot bot commented Jul 6, 2023

Pull requests from external contributors require approval from a rapidsai organization member with write permissions or greater before CI can begin.

@github-actions github-actions bot added the Cython / Python Cython or Python issue label Jul 6, 2023
@csadorf csadorf linked an issue Jul 6, 2023 that may be closed by this pull request
@csadorf csadorf added the improvement Improvement / enhancement to an existing function label Jul 6, 2023
@csadorf
Copy link
Contributor

csadorf commented Jul 7, 2023

/ok to test

@csadorf csadorf added the non-breaking Non-breaking change label Jul 7, 2023
Copy link
Contributor

@csadorf csadorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the contribution! Can you add a trivial unit test that explicitly tests this behavior to the test_hdbscan.py module? The tests should cover the supported arguments for metric and at least one that is not supported. In this way we can ensure consistency in the future.

@Rvch7
Copy link
Contributor Author

Rvch7 commented Jul 8, 2023

@csadorf is it okay to write two unit tests one with pass condition and one with fail cases or same function with xfail mark from pytest?

@csadorf
Copy link
Contributor

csadorf commented Jul 10, 2023

@csadorf is it okay to write two unit tests one with pass condition and one with fail cases or same function with xfail mark from pytest?

The xfail mark is typically used to indicate that a unit test is temporarily expected to fail, not to test failure behavior. In this case I'd prefer a single parametrized unit test in combination with pytest.raises(). The parameters would be a tuple of the metric argument and a Boolean that indicates the expected pass/fail behavior. You can use the parameters to indicate the pass/fail expectation. Please let me know if you need more guidance. Thanks a lot!

python/cuml/tests/test_hdbscan.py Outdated Show resolved Hide resolved
@csadorf
Copy link
Contributor

csadorf commented Jul 10, 2023

/ok to test

@csadorf
Copy link
Contributor

csadorf commented Jul 12, 2023

@Rvch7 Do you think you will have time to address my comments as well as the linter issues? Would love to see this included in the next release.

Please see our CONTRIBUTING guide on how to use pre-commit hooks to avoid linter issues.

@Rvch7
Copy link
Contributor Author

Rvch7 commented Jul 12, 2023

@csadorf I will work on it tonight but I have some thinking to do with what you said about unit test as I am new to that. would u mind giving an example(pseudo code) of

a Boolean that indicates the expected pass/fail behavior. You can use the parameters to indicate the pass/fail expectation.

if not I will figure it out eventually.

@csadorf
Copy link
Contributor

csadorf commented Jul 12, 2023

@csadorf I will work on it tonight but I have some thinking to do with what you said about unit test as I am new to that. would u mind giving an example(pseudo code) of

a Boolean that indicates the expected pass/fail behavior. You can use the parameters to indicate the pass/fail expectation.

Sure:

@pytest.mark.parametrize("param,expected_to_fail", [("abc", True), ("xyz, False)])
def test(param, expected_to_fail):
    if expected_to_fail:
        with pytest.raises(Error):
            some_func(param)
    else:
        some_func(param)

Also have a look at this test that demonstrates how to use pytest.raises in this context .

@Rvch7
Copy link
Contributor Author

Rvch7 commented Jul 13, 2023

Thank you for your help @csadorf, sometimes easy things look hard at the beginning. Let me know about these changes, and also please assign me any issue you may find appropriate for me.

@dantegd
Copy link
Member

dantegd commented Jul 13, 2023

/ok to test

Copy link
Contributor

@csadorf csadorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for addressing my change requests. Just a few more minor requests and then this should be ready to merge.

python/cuml/tests/test_hdbscan.py Outdated Show resolved Hide resolved
python/cuml/tests/test_hdbscan.py Outdated Show resolved Hide resolved
python/cuml/tests/test_hdbscan.py Outdated Show resolved Hide resolved
python/cuml/cluster/hdbscan/hdbscan.pyx Outdated Show resolved Hide resolved
python/cuml/tests/test_hdbscan.py Outdated Show resolved Hide resolved
python/cuml/tests/test_hdbscan.py Outdated Show resolved Hide resolved
@csadorf
Copy link
Contributor

csadorf commented Jul 13, 2023

/ok to test

Copy link
Contributor

@csadorf csadorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@csadorf
Copy link
Contributor

csadorf commented Jul 17, 2023

/ok to test

@csadorf
Copy link
Contributor

csadorf commented Jul 31, 2023

/ok to test

@csadorf
Copy link
Contributor

csadorf commented Jul 31, 2023

/merge

@bdice
Copy link
Contributor

bdice commented Aug 1, 2023

Rerunning CI now that #5536 is merged.

@bdice
Copy link
Contributor

bdice commented Aug 1, 2023

/ok to test

@rapids-bot rapids-bot bot merged commit 5a3309d into rapidsai:branch-23.08 Aug 1, 2023
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cython / Python Cython or Python issue improvement Improvement / enhancement to an existing function non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Restrict HDBSCAN metric options to L2
4 participants