Skip to content

Conversation

@i-aki-y
Copy link
Contributor

@i-aki-y i-aki-y commented Feb 24, 2022

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 replacing list1 + list2 with list(set(list1).union(list2)).

Any other comments?

No.

"sqeuclidean",
"yule",
]
brute=list(
Copy link
Member

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).

Suggested change
brute=list(
brute=sorted(

Copy link
Contributor Author

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.

Copy link
Contributor Author

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!

Copy link
Member

@jeremiedbb jeremiedbb left a 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

@jeremiedbb jeremiedbb added the Quick Review For PRs that are quick to review label Feb 24, 2022
Copy link
Member

@thomasjpfan thomasjpfan left a 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

"yule",
]
brute=sorted(
set(PAIRWISE_DISTANCE_FUNCTIONS.keys()).union(
Copy link
Member

Choose a reason for hiding this comment

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

Small nit:

Suggested change
set(PAIRWISE_DISTANCE_FUNCTIONS.keys()).union(
set(PAIRWISE_DISTANCE_FUNCTIONS).union(

(Iterating through a dictionary uses the keys by default)

Copy link
Contributor Author

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.

@thomasjpfan thomasjpfan changed the title [MRG] Ensure that sklearn.neighbors.VALID_METRICS["brute"] has no duplicate MNT Ensure that sklearn.neighbors.VALID_METRICS["brute"] has no duplicate Feb 24, 2022
@thomasjpfan thomasjpfan changed the title MNT Ensure that sklearn.neighbors.VALID_METRICS["brute"] has no duplicate MNT Removes duplicates in neighbors.VALID_METRICS["brute"] Feb 24, 2022
@thomasjpfan thomasjpfan merged commit da682de into scikit-learn:main Feb 24, 2022
thomasjpfan pushed a commit to thomasjpfan/scikit-learn that referenced this pull request Feb 26, 2022
…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>
thomasjpfan pushed a commit to thomasjpfan/scikit-learn that referenced this pull request Mar 1, 2022
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sklearn.neighbors.VALID_METRICS['brute'] has duplicate keyword: "cosine".

3 participants