Repository navigation
Conversation
PCA was checking for array API enabled or not to gate access to solvers in PCA. Instead we should check if the input is not array-like, which is a more precise way to gate this.
betatim
commented
Jun 10, 2026
| # Dispatch disabled: any array-like is coerced to NumPy and always works. | ||
| # Force the config explicitly so the test is robust to the ambient config | ||
| # (e.g. when the whole suite is run with array_api_dispatch enabled). | ||
| with config_context(array_api_dispatch=False): |
Member
Author
There was a problem hiding this comment.
We should remove this, maybe use an assert instead. Having this is unusual/inconsistent with how our other test are written.
betatim
commented
Jun 10, 2026
| return None | ||
| # np.ascontiguousarray avoids negative/0 strides (e.g. from the | ||
| # arpack output reversals) that some namespaces cannot consume. | ||
| return xp.asarray(np.ascontiguousarray(array), device=input_device) |
Member
Author
There was a problem hiding this comment.
Maybe this should use move_to instead of making a new function.
I have to admit I didn't quiz Opus enough to understand why exactly we need the ascontiguousarray)
betatim
commented
Jun 11, 2026
| and _is_arraylike(X) | ||
| and not _is_xp_namespace(xp, "array_api_strict") | ||
| ): | ||
| return self._fit_with_numpy_fallback(X, xp) |
Member
Author
There was a problem hiding this comment.
We should pass via validate_data before starting to fit. So calling _fit_with_numpy_fallback here is too early.
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.
PCA was checking for array API enabled or not to gate access to solvers in PCA. Instead we should check if the input is not array-like, which is a more precise way to gate this.
The invariants that should be true are:
The change in the
test_pca_mle_array_api_compliancetest is a fix forfloat32. The check now makes sure that the "left over" components are all compatible with being noise. Even if the two runs can't agree on how many components there are.I think we can clean up the code a bit more, but I'm starting the PR now to see if we can agree on the invariants and the behaviour. This is already the third iteration of this fix, each time thinking that "this time I got it right". This is why I now opened the PR to see if others agree on the invariants
AI usage disclosure
I used AI assistance for: