Skip to content

MNT carry out deprecation for default change of "copy" in HDBSCAN - #35262

Merged
lesteve merged 4 commits into
scikit-learn:mainfrom
FrancoisPgm:dep1.10_hdbscan
Nov 3, 2026
Merged

lesteve merged 4 commits into
scikit-learn:mainfrom
FrancoisPgm:dep1.10_hdbscan

Conversation

@FrancoisPgm

Copy link
Copy Markdown
Member

Reference Issues/PRs

Towards #35252

What does this implement/fix? Explain your changes.

Change the default of copy from False to True in HDBSCAN.

Introduce yourself

AI usage disclosure

I used AI assistance for:

  • Code review

Any other comments?

@AnneBeyer AnneBeyer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @FrancoisPgm!
Two small things Claude flagged:

@FrancoisPgm

Copy link
Copy Markdown
Member Author

This filter can also be removed now

Thanks, I (and Cursor too :O) somehow missed it.

It also noted that there is not test path for the default value. I think it would make sense to remove copy=True here as well

I initially left all the copy=True since the last fit_predict uses copy=False, and I thought keeping explicit values would improve the readability of the test.
But after checking more in details, in both cases the ValueError is raised before the copy happens, so setting the value for copy is irrelevant for the two pytest.raises. It is only necessary in the first fit_predict not to break the assert_allclose(D, D_original).
So for simplicity I think we can just use the default everywhere (state of the current commit). But no strong opinion here.

@lesteve lesteve left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

@AnneBeyer feel free to double-check whether you are happy with the changes. If you are happy, ping me and I can merge this one!

Comment thread sklearn/cluster/tests/test_hdbscan.py Outdated
@@ -590,16 +590,3 @@ def test_hdbscan_cosine_metric_invalid_algorithm(invalid_algo):
hdbscan = HDBSCAN(metric="cosine", algorithm=invalid_algo, copy=False)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If I'm being pedantic, we could also remove the parameter here and in the other 33 cases (Claude's count), as the parameter was only added to silence the warning from the deprecation and is never actually relevant to the test.

Suggested change
hdbscan = HDBSCAN(metric="cosine", algorithm=invalid_algo, copy=False)
hdbscan = HDBSCAN(metric="cosine", algorithm=invalid_algo)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't detect any pedantry here, it's true that all the copy=False were added in #31973 to silence the warning, so no point in keeping them here, I'll remove them.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

While removing all the copy=False, I realized no test was testing copy, so I added one. WDYT @AnneBeyer ?

@AnneBeyer AnneBeyer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See my last comment for one small potential improvement, but I'm fine with merging it as is as well.

@lesteve

lesteve commented Nov 3, 2026

Copy link
Copy Markdown
Member

Let's merge this to get one item less in the 1.10 milestone.

Remaining follow-up tweaks can be done later, since they are only about testing, unless I missed something.

@lesteve
lesteve merged commit f014881 into scikit-learn:main Nov 3, 2026
38 checks passed
@lesteve

lesteve commented Nov 3, 2026

Copy link
Copy Markdown
Member

Thanks @FrancoisPgm and @AnneBeyer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants