-
-
Notifications
You must be signed in to change notification settings - Fork 26.4k
MNT Removes duplicates in neighbors.VALID_METRICS["brute"] #22602
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
MNT Removes duplicates in neighbors.VALID_METRICS["brute"] #22602
Conversation
sklearn/neighbors/_base.py
Outdated
| "sqeuclidean", | ||
| "yule", | ||
| ] | ||
| brute=list( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the failures in the CI come from the parametrization over parameters that come from a set. According to pytest-dev/pytest-xdist#598, we should use sorted(set) instead of list(set).
| brute=list( | |
| brute=sorted( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeremiedbb Thank you for your prompt comment!
I was just about to investigate the CI errors.
I will try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeremiedbb Ah. you have already fixed it. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @i-aki-y
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @i-aki-y !
I left a minor comment, otherwise LGTM
sklearn/neighbors/_base.py
Outdated
| "yule", | ||
| ] | ||
| brute=sorted( | ||
| set(PAIRWISE_DISTANCE_FUNCTIONS.keys()).union( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit:
| set(PAIRWISE_DISTANCE_FUNCTIONS.keys()).union( | |
| set(PAIRWISE_DISTANCE_FUNCTIONS).union( |
(Iterating through a dictionary uses the keys by default)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thomasjpfan Thank you for your review. I fixed it.
…rn#22602) Co-authored-by: akiyuki ishikawa <aki.y.ishikwa@gmail.com> Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com>
…rn#22602) Co-authored-by: akiyuki ishikawa <aki.y.ishikwa@gmail.com> Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com>
Reference Issues/PRs
Fixes #22584
What does this implement/fix? Explain your changes.
This PR ensures that the constant list:
sklearn.neighbors.VALID_METRICS["brute"]has no duplicate.Since the
VALID_METRICS["brute"]is defined as a concatenation of different lists, the resulting list can unintentionally contain duplicate values. The PR continue to ensures the resulting list is unique by replacinglist1 + list2withlist(set(list1).union(list2)).Any other comments?
No.