Fix: Array-API - avoid failing for numpy fit + predict with sparse or array-like X#34144
Merged
Conversation
Contributor
|
Thanks for looking into it. But this would still error out in the cases where the attribute being checked is sparse. For example: import os
os.environ["SCIPY_ARRAY_API"] = "1"
import numpy as np
rng = np.random.default_rng(seed=123)
X = rng.random(size=(20, 3))
y = rng.integers(2, size=X.shape[0])
from sklearn import set_config
set_config(array_api_dispatch=True)
from sklearn.linear_model import LogisticRegression
model = LogisticRegression().fit(X,y)
model.sparsify()
model.predict(X) |
Contributor
Author
|
Indeed, good catch thanks. Edit: Fixed. |
AnneBeyer
reviewed
May 29, 2026
AnneBeyer
reviewed
May 29, 2026
ogrisel
approved these changes
May 29, 2026
Member
|
@cakedev0 We also need a changelog entry for this fix. |
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Anne Beyer <anne.beyer@mailbox.org>
AnneBeyer
approved these changes
May 29, 2026
OmarManzoor
approved these changes
Jun 1, 2026
Contributor
OmarManzoor
left a comment
There was a problem hiding this comment.
A really minor error message content suggestion only. Otherwise LGTM.
Thank you @cakedev0
Co-authored-by: Omar Salman <omar.salman@arbisoft.com>
cakedev0
commented
Jun 1, 2026
auto-merge was automatically disabled
June 1, 2026 08:16
Head branch was pushed to by a user without write access
jeremiedbb
pushed a commit
that referenced
this pull request
Jun 2, 2026
… array-like X (#34144) Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Anne Beyer <anne.beyer@mailbox.org> Co-authored-by: Omar Salman <omar.salman@arbisoft.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference Issues/PRs
Fixes #34132
What does this implement/fix? Explain your changes.
check_same_namespaceto allow the cases:xpis numpy, X is not an array]xpis NOT numpy, X is not an array], for which the current message might be quite hard to understand.AI usage disclosure
I used AI assistance for: