provide compatibility with numpy 2.0#38250
Conversation
|
Documentation preview for this PR (built with commit 515d20e; changes) is ready! 🎉 |
|
Codecov complains about the lines |
|
I'm still getting a test failure: |
|
that's one I don't quite know how to fix. |
|
Why is this even tested? I would understand if it was a numpy test, but a sage test? |
|
Nitpicking, the string "# to ensure numpy 2.0 compatibility" is applied inconsistently. I suggest for it to be attached to the "if" statement line. I guess it will be clear if an |
it's not really a test, it's more like part of a guide. Useful, but testing all its output isn't so important. I added |
|
WFM now |
I hope you're fine with undoing all that once numpy 2 becomes standard, see #38275 |
thanks! |
Well, I did not say to remove it altogether. But I absolutely know what you are saying. In time those compatibility hacks will go. |
|
it was just a trivial rebase |
|
Note: I've tested this PR using numpy 1.26 and using numpy 2.0 and it works fine on both cases. See void-linux/void-packages#49571 (comment). |
|
I come across this while working on #39152. I think while Other options I can think of:
|
You are probably right. With a caveat: sage-the-distro is still on numpy 1.26.3 afaict. A better way would be to make sagelib depend on numpy at least 2.0, switch everything to the new format, and let distros (sage-the-distro and others) update-or-perish. See #39192 (comment). |
|
not really (?) it's possible to make sage compatible with both 1.26 and 2.0 by writing doctests to be compatible, and a few other things. of course the (only) disadvantage of that approach is maintenance overhead. |
sagemathgh-39242: Make tests compatible with numpy 2.1 Related to sagemath#38250 . In numpy 2.1 it returns a `Token` object which gets printed out. This assigns it to `_`. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39242 Reported by: user202729 Reviewer(s): Tobias Diez, user202729
sagemathgh-39242: Make tests compatible with numpy 2.1 Related to sagemath#38250 . In numpy 2.1 it returns a `Token` object which gets printed out. This assigns it to `_`. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39242 Reported by: user202729 Reviewer(s): Tobias Diez, user202729
sagemathgh-39242: Make tests compatible with numpy 2.1 Related to sagemath#38250 . In numpy 2.1 it returns a `Token` object which gets printed out. This assigns it to `_`. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39242 Reported by: user202729 Reviewer(s): Tobias Diez, user202729
This will fix #38242
Basically, most of the problems are with numpy switching to a different way to display its data,
showing type. We either use a compatibility version, or add ellipses in doctests.
📝 Checklist
⌛ Dependencies