Skip to content

TST Add array API scorer and cross_validate integration tests - #34824

Merged
OmarManzoor merged 8 commits into
scikit-learn:mainfrom
ogrisel:cursor/array-api-integration-tests-26c5
Sep 29, 2026
Merged

OmarManzoor merged 8 commits into
scikit-learn:mainfrom
ogrisel:cursor/array-api-integration-tests-26c5

Conversation

@ogrisel

@ogrisel ogrisel commented Aug 27, 2026 •

Copy link
Copy Markdown
Member

Towards: #33444.

This is an extraction from the previously stalled #32873 PR.

The purpose is to complement the existing unit tests for array API compliance (for estimators and metrics) to check that everything still works as expected when all used in conjunction (e.g. when wrapped in cross-validation pipelines that exercise the scoring infrastructure).

cursoragent and others added 3 commits August 27, 2026 09:41
Port the integration tests from scikit-learn#32873 onto current main. The library
fixes from that PR appear to already be covered by later main changes,
so this only adds the tests (with small adaptations for current helpers
and a numpy-baseline y_np fix in the regression scorer test).

Co-authored-by: Olivier Grisel <[email protected]>
Remove the standalone test added from scikit-learn#32873 and assert that an
invalid pos_label is ignored on the existing multiclass
_get_response_values coverage.

Co-authored-by: Olivier Grisel <[email protected]>
Replace the XXX in test_cross_validate_array_api_pipeline with the
policy already used by LinearClassifierMixin and the common Array API
checks: string class labels stay NumPy on CPU; integer class ids follow
X. Also compare predict outputs to the NumPy baseline.

Co-authored-by: Olivier Grisel <[email protected]>
@ogrisel

ogrisel commented Aug 27, 2026 •

Copy link
Copy Markdown
Member Author

The new tests pass on CUDA GPU.

I just started an Intel GPU run at:

https://github.com/probabl-ai/scikit-learn-intel-workflow/actions/runs/33075032400 (it's green!)

@ogrisel ogrisel added this to Labs Aug 27, 2026
@ogrisel ogrisel moved this to In progress in Labs Aug 27, 2026
@ogrisel ogrisel added the Quick Review For PRs that are quick to review label Aug 27, 2026
)
assert pos_label_invalid == "invalid"
assert predictions_invalid.shape == (X.shape[0], len(estimator.classes_))
assert_allclose(predictions_invalid, predictions)

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.

This new test case is not directly related to array API but it was discovered while originally working on the array API integration tests before the metrics function refactoring. I think it's good to keep it as a non-regression test.

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

Thank you for the PR, @ogrisel!

I just have one minor comment about the device_ variable. Otherwise, LGTM!

Also, a friendly ping to @lucyleeow and @OmarManzoor for a second review.

(
RidgeClassifier(solver="svd"),
"accuracy",
), # TODO: add "roc_auc" when supported

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.

👍

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.

Ping me to address that TODO if #33200 gets merged first. Otherwise we can do a follow-up PR.

@virchan virchan added the Waiting for Second Reviewer First reviewer is done, need a second one! label Aug 28, 2026
Comment thread sklearn/utils/tests/test_array_api.py Resolved
@ogrisel

ogrisel commented Aug 28, 2026

Copy link
Copy Markdown
Member Author

@betatim feedback addressed and the updated tests pass locally.
@virchan thanks for the review!

@ogrisel ogrisel moved this from In progress to PR waiting for reviews in Labs Aug 31, 2026
@ogrisel

ogrisel commented Sep 28, 2026

Copy link
Copy Markdown
Member Author

Gentle ping @betatim @virchan.

Also @StefanieSenger @OmarManzoor.

@OmarManzoor OmarManzoor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thank you @ogrisel

@OmarManzoor
OmarManzoor merged commit c9021ac into scikit-learn:main Sep 29, 2026
37 checks passed
@lorentzenchr

Copy link
Copy Markdown
Member

#34854 removed the import of partial in test_array_api.py. This guess this PR did not sync/merge with main. So it introduced a CI regression: The tests fail because partial is not imported.

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

Labels

Array API module:metrics module:utils No Changelog Needed Quick Review For PRs that are quick to review Waiting for Second Reviewer First reviewer is done, need a second one!

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants