-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Fix tests for numpy 2 and array api compat #29436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix tests for numpy 2 and array api compat #29436
Conversation
I triggered a CUDA CI run here: EDIT: green! The tests pass locally with numpy 2.0.0 and array-api-strict 2.0.1. |
I marged "No changelog needed" but this is debatable as our |
Yep, I confirm this as well.
I guess I would add a changelog because the exception type does change when |
…ip_openblas_pandas
I tried to come up with a changelog entry but found it too awkward to explain: this change is in a private helper that will impact most scoring metrics (but not all) only when array API dispatch is enabled (and only for very weird input shapes). Furthermore the change is similar from a change from numpy 1 to numpy 2, so I think very few people will be impacted (upgrading existing code bases with scikit-learn using array API on code that only works with numpy 1 and has not been updated for numpy 2 yet). So I would rather not add a verbose and hard to understand changelog entry for this PR. But if you disagree I can still do it. |
Seems reasonable not to add a changelog indeed, given the complexities involved. |
Only saw the test failure after approving it. Looks like |
I will fix the warnings asap. |
…umPy's default floating point precision level
I triggered a new CUDA CI run here: EDIT: they are green. |
@lesteve shall we enable auto-merge on this? This would make it saner to help review the many pending array API PRs. |
At a quick glance the diff looks fine, two issues:
|
I will revert 021e07b to avoid the device problem. EDIT: actually this is a fixable problem, no need to revert. I suspect that the test time is related to the Python version. Let me re-pin to 3.9 for now with a comment and see of the new CI run confirms this. If this is the case we should investigate separately if we can reproduce. Maybe it's related to coverage tracing performance in recent Python versions? |
We are back to 27 min with Python 3.9... I think this is good to merge as is but we should definitely investigate the cause of the slowness with Python 3.12. |
Merging, thanks! The slow CI is weird but it does remind me something (not sure at all this was related but I can try to find it again ...) |
Thanks for the reviews. |
Found the slow CI with Python 3.12 I had in mind. At the time it was seen when moving the scipy-dev build to Python 3.12: #28383. The work-around was to move dataset download to another build so this may not be related. I guess it is easy to test your coverage idea by disabling coverage in the CI build ... |
Fixes #29396.
Update the array API tests and the
_average
private helper for compatibility with NumPy 2.0.0.