Skip to content

TST strengthen histogram binning checks - #34343

Merged
lorentzenchr merged 4 commits into
scikit-learn:mainfrom
cakedev0:tst/hgb/stronger_bin_transf
Jun 22, 2026
Merged

lorentzenchr merged 4 commits into
scikit-learn:mainfrom
cakedev0:tst/hgb/stronger_bin_transf

Conversation

@cakedev0

@cakedev0 cakedev0 commented Jun 19, 2026 •

Copy link
Copy Markdown
Member

Reference Issues/PRs

This PR updates tests to gain total trust in changes from #34194

What does this implement/fix? Explain your changes.

  • Strengthen the random-data bin mapper test to check that binned values respect their threshold intervals.
  • Fix the idempotence test to use the larger bin count for the second mapper as t was probably intended

AI usage disclosure

I used AI assistance for updating the comment in the test.

@lorentzenchr lorentzenchr 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.

One question.

# max_bins is the number of bins for non-missing values
n_bins = max_bins + 1
mapper = _BinMapper(n_bins=n_bins, random_state=42).fit(DATA)
mapper = _BinMapper(n_bins=n_bins).fit(DATA)

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.

Why the removal of the explictit rng? Has it no effect?

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.

Let's pass subsample=n_samples + 1 to make it explicit that subsampling does not happen in this test.

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.

oops, forgot to undo this change after I checked the test was not flaky.

Suggested change
mapper = _BinMapper(n_bins=n_bins).fit(DATA)
mapper = _BinMapper(n_bins=n_bins, random_state=42, subsample=n_samples + 1).fit(DATA)

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.

Let's pass subsample=n_samples + 1 to make it explicit that subsampling does not happen in this test.

Hum why? This test does work with subsampling (and without too, but n_samples is 1M so subsampling did happen)

@ogrisel ogrisel 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 once the above review comment is addressed.

@github-actions github-actions Bot added the CI:Linter failure The linter CI is failing on this PR label Jun 22, 2026
@github-actions github-actions Bot removed the CI:Linter failure The linter CI is failing on this PR label Jun 22, 2026
@lorentzenchr
lorentzenchr merged commit b55ad21 into scikit-learn:main Jun 22, 2026
33 checks passed
@cakedev0 cakedev0 moved this to Done in Labs Jun 24, 2026
@cakedev0 cakedev0 added this to Labs Jun 24, 2026
prady0t pushed a commit to prady0t/scikit-learn that referenced this pull request Sep 2, 2026
@jeremiedbb jeremiedbb mentioned this pull request Sep 8, 2026
14 tasks done
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.

3 participants