Skip to content

Fix make sure enabling array_api_dispatch=True does not break any estimator on NumPy inputs#32846

Merged
OmarManzoor merged 15 commits intoscikit-learn:mainfrom
ogrisel:array-api-dispatch-should-not-break-estimators-on-numpy-inputs
Jan 6, 2026
Merged

Fix make sure enabling array_api_dispatch=True does not break any estimator on NumPy inputs#32846
OmarManzoor merged 15 commits intoscikit-learn:mainfrom
ogrisel:array-api-dispatch-should-not-break-estimators-on-numpy-inputs

Conversation

@ogrisel
Copy link
Member

@ogrisel ogrisel commented Dec 5, 2025

This is a follow-up to #32840. This should detect most possible silent breaking in future refactoring of helper functions that are used by both in array API supporting and not supporting code in scikit-learn.

AI usage disclosure

I used AI assistance for:

  • Mostly bad code suggestions that I had to re-edit manually to get the code working correctly
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding
@ogrisel ogrisel added the CUDA CI label Dec 5, 2025
@github-actions github-actions bot removed the CUDA CI label Dec 5, 2025
@ogrisel ogrisel changed the title Fix make sure enabling array_api_dispatch=True does not break any estimator on NumPy inputs Dec 5, 2025
@ogrisel ogrisel moved this to In Progress in Array API Dec 5, 2025
@ogrisel ogrisel added the CUDA CI label Dec 5, 2025
@github-actions github-actions bot removed the CUDA CI label Dec 5, 2025
…entation in the memoryviewslices unwrap helper
@ogrisel
Copy link
Member Author

ogrisel commented Dec 8, 2025

@betatim
Copy link
Member

betatim commented Dec 9, 2025

Only just getting to this. I asked @lesteve about the release schedule and he'd like to get 1.8.0 done more or less "now". I think it would be nice to have this PR in, but it will take more than five minutes to review. For me it is ok to send 1.8.0 off without this merged.

I can understand that at some point you need to decide "the 1.8 boat has left, you are too late". Even though it makes me sad to ship it with a bug that we know about. Maybe having a small bug is ok (there are probably more that we haven't yet found) - we will find out if someone tried array API support because they'll report an issue ;)

Copy link
Contributor

@OmarManzoor OmarManzoor left a comment

Choose a reason for hiding this comment

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

Thank you for the PR @ogrisel

@ogrisel
Copy link
Member Author

ogrisel commented Dec 9, 2025

@betatim I think the release-critical bugfixes have already all been merged. This one can indeed wait and this is why I did not milestone it. We can take our time to review carefully, no hurry.

ogrisel and others added 2 commits December 9, 2025 15:37
Co-authored-by: Omar Salman <omar.salman2007@gmail.com>
@ogrisel ogrisel added the CUDA CI label Dec 9, 2025
@github-actions github-actions bot removed the CUDA CI label Dec 9, 2025
@OmarManzoor
Copy link
Contributor

@ogrisel There is a CI failure which seems unrelated to this PR but still seems like something erroneous

Copy link
Contributor

@OmarManzoor OmarManzoor left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you @ogrisel

@ogrisel
Copy link
Member Author

ogrisel commented Dec 10, 2025

There is a CI failure which seems unrelated to this PR but still seems like something erroneous

Indeed, there is a missing rng seed. Let me open a dedicated PR.

@adrinjalali adrinjalali added this to Labs Dec 11, 2025
@adrinjalali adrinjalali moved this to Todo in Labs Dec 11, 2025
@adrinjalali adrinjalali moved this from Todo to In progress in Labs Dec 11, 2025
Copy link
Member

@lucyleeow lucyleeow 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 for the other fixes here. Nits only

Comment on lines 1078 to 1079
When expect_only_array_outputs is False, the check accepts non-array
outputs from estimator methods (e.g., sparse data structures). This is
Copy link
Member

Choose a reason for hiding this comment

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

Could you expand on this? I was confused just reading this, but https://github.com/scikit-learn/scikit-learn/pull/32846/changes#r2602981393 cleared it up for me.

Copy link
Member Author

Choose a reason for hiding this comment

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

I pushed 969f06a as an attempt to clarify this.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! Feel free to merge when you're ready!

ogrisel and others added 2 commits December 24, 2025 10:38
Co-authored-by: Lucy Liu <jliu176@gmail.com>
Co-authored-by: Loïc Estève <loic.esteve@ymail.com>
Co-authored-by: Lucy Liu <jliu176@gmail.com>
@github-actions github-actions bot added the CI:Linter failure The linter CI is failing on this PR label Dec 24, 2025
@github-actions github-actions bot removed the CI:Linter failure The linter CI is failing on this PR label Dec 24, 2025
@OmarManzoor
Copy link
Contributor

@ogrisel Should we merge this?

Copy link
Member

@betatim betatim left a comment

Choose a reason for hiding this comment

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

One tweak to a comment, for me it made it easier to understand. Otherwise LGTM, let's merge

@OmarManzoor OmarManzoor enabled auto-merge (squash) January 6, 2026 13:42
@OmarManzoor OmarManzoor merged commit 938cd97 into scikit-learn:main Jan 6, 2026
36 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in Labs Jan 6, 2026
@github-project-automation github-project-automation bot moved this from In Progress to Done in Array API Jan 6, 2026
@ogrisel ogrisel deleted the array-api-dispatch-should-not-break-estimators-on-numpy-inputs branch January 7, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

6 participants