[MRG] MNT use check_scalar to validate scalar in SpectralClustering#21881
Merged
jjerphan merged 7 commits intoscikit-learn:mainfrom Jan 7, 2022
Merged
Conversation
ogrisel
approved these changes
Dec 7, 2021
41 tasks
Contributor
Author
|
Hello @ogrisel ! Thank you for your review, I just updated the changelog. |
Contributor
Author
|
It looks like there's a bug causing CI to fail (may be fixed in #22049) |
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
Contributor
Author
|
Thank you for your review @jjerphan ! I just updated the code with your suggestions. |
jjerphan
approved these changes
Jan 7, 2022
Comment on lines
+115
to
+149
| @pytest.mark.parametrize( | ||
| "input, params, err_type, err_msg", | ||
| [ | ||
| (X, {"n_clusters": -1}, ValueError, "n_clusters == -1, must be >= 1"), | ||
| (X, {"n_clusters": 0}, ValueError, "n_clusters == 0, must be >= 1"), | ||
| ( | ||
| X, | ||
| {"n_clusters": 1.5}, | ||
| TypeError, | ||
| "n_clusters must be an instance of <class 'numbers.Integral'>," | ||
| " not <class 'float'>", | ||
| ), | ||
| (X, {"n_init": -1}, ValueError, "n_init == -1, must be >= 1"), | ||
| (X, {"n_init": 0}, ValueError, "n_init == 0, must be >= 1"), | ||
| ( | ||
| X, | ||
| {"n_init": 1.5}, | ||
| TypeError, | ||
| "n_init must be an instance of <class 'numbers.Integral'>," | ||
| " not <class 'float'>", | ||
| ), | ||
| (X, {"gamma": -1}, ValueError, "gamma == -1, must be >= 1"), | ||
| (X, {"gamma": 0}, ValueError, "gamma == 0, must be >= 1"), | ||
| (X, {"n_neighbors": -1}, ValueError, "n_neighbors == -1, must be >= 1"), | ||
| (X, {"n_neighbors": 0}, ValueError, "n_neighbors == 0, must be >= 1"), | ||
| ( | ||
| X, | ||
| {"eigen_tol": -1, "eigen_solver": "arpack"}, | ||
| ValueError, | ||
| "eigen_tol == -1, must be >= 0", | ||
| ), | ||
| (X, {"degree": -1}, ValueError, "degree == -1, must be >= 1"), | ||
| (X, {"degree": 0}, ValueError, "degree == 0, must be >= 1"), | ||
| ], | ||
| ) |
Member
There was a problem hiding this comment.
Thank you for this extensive test!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference Issues/PRs
Addresses #20724
#DataUmbrella
What does this implement/fix? Explain your changes.
Summary of changes to SpectralClustering:
Add tests to ensure appropriate behavior when invalid arguments are passed in.
Use the helper function check_scalar from sklearn.utils to validate the scalar parameters.
Progress:
References
Any other comments?
This is my very first contibution to an open source project, please do not hesitate to give me a feedback. Thank you!