8000 CI/FIX Enable numpy dev in [scipy-dev] build and fix Bayesian linear models for numpy 2 compat by ogrisel · Pull Request #27899 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@ogrisel
Copy link
Member
@ogrisel ogrisel commented Dec 4, 2023

While reviewing #27075, I realized that the current state of our Linux_Nightly pylatest_pip_scipy_dev does not actually test against numpy dev without us upper-bounding the version of numpy explicitly (yet):

https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=61365&view=logs&j=dfe99b15-50db-5d7b-b1e9-4105c42527cf&t=eb5122d5-ab7e-5479-a8ce-245b4d64938b&l=442

The goal of this PR is to trigger a run to:

  • check if scipy and pandas actually break at import time when running against numpy 2 dev,
  • if not, check if scikit-learn itself can import successfully and then run its own tests,
  • fix scikit-learn itself in case of small problems revealed by the test results.

@github-actions
Copy link
github-actions bot commented Dec 4, 2023

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: ed58999. Link to the linter CI: here

@ogrisel
Copy link
Member Author
ogrisel commented Dec 4, 2023

Good news. Most scikit-learn tests pass (thanks to the fixes contributed earlier by @seberg). We just need to fix a test with unexpected dtype values. I suspect the changes in dtype promotion rules: https://numpy.org/neps/nep-0050-scalar-promotion.html.

I will have a look.

Copy link
Member
@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

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

LGTM. If the fix is simply in a test, I could imagine to add it inside this PR as well.

@ogrisel
Copy link
Member Author
ogrisel commented Dec 4, 2023

LGTM. If the fix is simply in a test, I could imagine to add it inside this PR as well.

Not it's not just the test. The dtype of some fitted attribute is upcasted. I have a fix, I will push to the PR and update the title.

@ogrisel ogrisel changed the title CI: force install numpy dev in [scipy-dev] build Enable numpy dev in [scipy-dev] build and fix Bayesian linear models for numpy 2 compat Dec 4, 2023
@ogrisel ogrisel added the Bug label Dec 4, 2023
@ogrisel ogrisel added this to the 1.4 milestone Dec 4, 2023
@ogrisel
Copy link
Member Author
ogrisel commented Dec 4, 2023

I milestoned this PR 1.4 so that scikit-learn would not have any numpy 2 incompatible code in it.

@ogrisel ogrisel mentioned this pull request Dec 4, 2023
4 tasks
@glemaitre glemaitre changed the title Enable numpy dev in [scipy-dev] build and fix Bayesian linear models for numpy 2 compat FIX Enable numpy dev in [scipy-dev] build and fix Bayesian linear models for numpy 2 compat Dec 4, 2023
@glemaitre glemaitre changed the title FIX Enable numpy dev in [scipy-dev] build and fix Bayesian linear models for numpy 2 compat CI/FIX Enable numpy dev in [scipy-dev] build and fix Bayesian linear models for numpy 2 compat Dec 4, 2023
Copy link
Member
@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Member
@lesteve lesteve left a comment

Choose a reason for hiding this comment

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

LGTM

It seems like float32< 8000 /code> dtype was maintained in numpy<2 by relying on float64_scalar * float32_array => float32_array (try executing np.float64(1.) * np.ones(2, dtype=np.float32) if you want to double-check)

The code in this PR is more careful about dtype.

@lesteve
Copy link
Member
lesteve commented Dec 4, 2023

And also it seems like pandas dev wheel is the one that wants numpy<2 ...

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0