Skip to content

ENH: make __setitem__ raise on a device mismatch#209

Merged
ev-br merged 1 commit into
data-apis:mainfrom
ev-br:setitem_device
Jul 9, 2026
Merged

ENH: make __setitem__ raise on a device mismatch#209
ev-br merged 1 commit into
data-apis:mainfrom
ev-br:setitem_device

Conversation

@ev-br

@ev-br ev-br commented May 9, 2026

Copy link
Copy Markdown
Member

closes gh-207

@ev-br ev-br added this to the 2.6 milestone May 9, 2026
@ogrisel

ogrisel commented May 15, 2026

Copy link
Copy Markdown

LGTM: I checked that the current scikit-learn test suite passes against that branch of array-api-strict.

I also checked that changing scikit-learn code to allocate a result array with xp.empty without setting the expected device= kwarg make the tests fail early, when calling __setitem__ time, as expected.

@ev-br

ev-br commented May 29, 2026

Copy link
Copy Markdown
Member Author

data-apis/array-api#1005 is I believe the spec update to make this spec-compliant.

@ev-br

ev-br commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

data-apis/array-api#1005 has been merged, so this PR is unblocked. Formally, the spec update will only be effective in the next release, which, if it's release history is any guide, can be expected in early 2027.

While the remit of array-api-strict is to scrupulously follow the official, published spec to the letter, delaying this PR by at least half year feels impractical and unhelpful for the ongoing adoption effort. So let's let make a pragmatic move and land this now.
Thanks Olivier for the review.

@ev-br ev-br merged commit 875e4c7 into data-apis:main Jul 9, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Raise on implicit device transfer in __setitem__

2 participants