Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CI Fix TransformTargetRegressor metadata routing test - #34371

Merged
ogrisel merged 4 commits into
scikit-learn:mainfrom
betatim:fix-up-ttr-metadata-test
Jun 23, 2026
Merged

CI Fix TransformTargetRegressor metadata routing test#34371
ogrisel merged 4 commits into
scikit-learn:mainfrom
betatim:fix-up-ttr-metadata-test

Conversation

@betatim

@betatim betatim commented Jun 23, 2026

Copy link
Copy Markdown
Member

Reference Issues/PRs

Fix for the latest failure in #32393 (That is a mega issue that keeps running. So I am not sure if we should close it when merging this PR?)

What does this implement/fix? Explain your changes.

Instead of using np.empty() the test now uses np.ones(). On macos np.empty() seems to reliably return an array that contains only zeros, this fails a check that not all weights are zero. I think we don't care about the values of the weights, at least I hope we don't care given that we used np.empty. So using np.ones should be fine as well.

For some reason np.empty returns something that contains at least one element that isn't zero when we run the test in the normal PR CI. I guess that is "expected" because np.empty says it will return a new array without initialising the entries. Uninitialised memory -> no one knows what is/isn't in that memory. I'm not sure if free-threaded vs not free-threaded has anything to do with it?

My conclusion, if we look at the contents of an array we should probably not use np.empty.

AI usage disclosure

I used AI assistance for:

  • Research and understanding

My AI researcher thinks that #32212 and #34224 "conspired" to cause this.

cc @lucyleeow

Instead of using np.empty() which can return an array of only zeros we
use np.ones() for the weights. A completely empty array triggers a
sanity check that not all weights are zero.
@ogrisel

ogrisel commented Jun 23, 2026

Copy link
Copy Markdown
Member

I pushed an empty commit to ensure that this fix the problem on the free-threaded builds.

@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. Will mark as auto-merge.

@ogrisel
ogrisel enabled auto-merge (squash) June 23, 2026 08:44
@ogrisel

ogrisel commented Jun 23, 2026

Copy link
Copy Markdown
Member

The CD build passed. There is still a failure with the [free-threaded] build but it's unrelated and it shouldn't block the release of the nightly builds anymore.

@StefanieSenger

Copy link
Copy Markdown
Member

My conclusion, if we look at the contents of an array we should probably not use np.empty.

Interesting. I think the values an np.empty array holds depend on how that section of memory happened to be used before (which is influenced by which tests in CI had ran before). We cannot assume np.empty arrays to have certain distribution of values.
Are there more places in the tests or code where we should take care of that?

@ogrisel
ogrisel merged commit 6b7b8cb into scikit-learn:main Jun 23, 2026
36 checks passed
@betatim
betatim deleted the fix-up-ttr-metadata-test branch June 24, 2026 11:22
@betatim

betatim commented Jun 24, 2026

Copy link
Copy Markdown
Member Author

Are there more places in the tests or code where we should take care of that?

I wondered the same and asked AI to comb through our tests. The result of that is #34373 so it looks like the answer to your question is that generally we do use np.empty correctly.

@StefanieSenger

Copy link
Copy Markdown
Member

I wondered the same and asked AI to comb through our tests. The result of that is #34373 so it looks like the answer to your question is that generally we do use np.empty correctly.

That's good enough for me, since we didn't detect any other failures. Thanks.

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
jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Sep 9, 2026
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