Repository navigation
FIX HDBSCAN TypeError in traverse_upwards when cluster_selection_epsilon >= merge distance (#35473) - #35499
Open
prashik24 wants to merge 5 commits into
Open
FIX HDBSCAN TypeError in traverse_upwards when cluster_selection_epsilon >= merge distance (#35473)#35499prashik24 wants to merge 5 commits into
prashik24 wants to merge 5 commits into
Conversation
…lon >= merge distance (scikit-learn#35473)
|
Thank you for opening your first pull request to scikit-learn! 🎉 To help get your contribution reviewed, please make sure that:
|
betatim
reviewed
Nov 24, 2026
Author
|
Thanks for the review and suggestions, @betatim! I have updated:
All CI checks are green |
betatim
approved these changes
Nov 27, 2026
This branch has not been deployed
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
Fixes #35473
What does this implement/fix? Explain your changes.
In
sklearn/cluster/_hdbscan/_tree.pyx,traverse_upwardsassigned 1-D array slices (cluster_tree[cluster_tree['child'] == leaf]['parent']andcluster_tree[cluster_tree['child'] == parent]['value']) directly to typed C scalars (cnp.intp_tandcnp.float64_t).In NumPy >= 2.4, converting a non-zero-dimensional array to a scalar raises
TypeError: only 0-dimensional arrays can be converted to Python scalars, causingHDBSCAN.fit_predictto crash whenevercluster_selection_epsilon >= top-level merge distance.This PR explicitly extracts the scalar element with
[0](matchingepsilon_search), preventing theTypeError.Any other comments?
test_hdbscan_cluster_selection_epsilon_largeinsklearn/cluster/tests/test_hdbscan.pytesting botheomandleafwithallow_single_clustertrue and false.