-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Adapt to precision changes in pari 2.17 #166
Conversation
Since 2.17 pari stores the precision in bits instead of words. Port cypari2 to work with it: - Rename prec_bits_to_words to prec_bits_to_pari and outsource it to upstream's nbits2prec, so it works with all pari versions - Remove unused and no longer needed prec_words_to_bits and prec_words_to_dec functions - Use upstream's LOWDEFAULTPREC as default precision
there are doctest failures like this. https://github.com/sagemath/cypari2/actions/runs/11186104097/job/31100414929#step:5:322
it's probably hard to avoid differentiating between pari versions up to 2.15 and 2.17+ in this test. |
That was actally an issue with my code, this test should always return 64. |
Tests seem fine now. However, I'm seeing a weird issue that I don't understand. With this patch, in sage I get
which shows that the The issue doesn't happen without this patch (but of course lots of precision related stuff is broken). Any idea what's going on here? Why should these changes affect |
Could it be a |
Ah, found the issue.
which of course fails to properly import |
cypari2/pari_instance.pyx
Outdated
@@ -301,7 +301,7 @@ from .closure cimport _pari_init_closure | |||
|
|||
# Default precision (in PARI words) for the PARI library interface, | |||
# when no explicit precision is given and the inputs are exact. | |||
cdef long prec = prec_bits_to_words(53) | |||
cdef long prec = prec_bits_to_pari(53) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe replace this by DEFAULTPREC
where it is used (prec_bits_to_pari
only?) and get rid of the global variable?
But in fact,
Maybe it makes more sense to replace this by
(as a matter of fact: I am not sure if But I would rather not introduce the new functions |
This comment was marked as resolved.
This comment was marked as resolved.
fix doctests for pari 2.17
No, I don't get notifications for PR's. Merged now, thanks.
That's what I've been trying, but couldn't make it work. Testing your patch now. |
Thank you!
BTW, you rewrote I think keeping the default bit precision at 64 regardless of architecture is the best choice, so that doctesting is consistent. |
Everything works fine from both cypari and sage sides. Want to submit a PR for proper attribution? |
Replace prec_bits_to_pari() by upstream nbits2prec, define DEFAULT_BITPREC
Done. I think this is looking good, I will be testing on 32 bits soon (maybe also with pari 2.15). I wonder if, given that sagemath 10.4 uses |
This is needed to support sagemath < 10.5.
Indeed, sagemath 10.4 breaks with this. I made a PR to restore |
Restore prec_words_to_bits as deprecated function
This looks good to me. How do we move forward? It would be nice to have this merged with a 2.3.0 release in view? Maybe useful to prerelease a 2.3.0b1 for wider testing? |
@tornaria @antonio-rojas Unfortunately, this PR will break SnapPy inside Sage because the we use |
Note that this PR is not even merged, much less released. I don't think there's any problem with keeping (with deprecation) all the functions that were removed: Bear in mind that, depending on how you use these functions, readding them will not necessarily make your program work correctly with pari 2.17. Readding will make sure that the next version of cypari2 still works with old sagemath and snappy when using pari 2.15. Maybe these functions, in addition to raise a deprecation warning, should also return an error when used with pari 2.17? In any case, you should consider replacing the usage of these functions in snappy, otherwise it will be very difficult for you to support pari versions 2.15 and 2.17 with the same codebase. Pari macros |
The author of this PR, @antonio-rojas, is also the maintainer of cypari2 on Arch Linux, which ships with Pari 2.17. The current Arch patch overlaps with this PR and in particular removes
Great!
Noted, we'll have to look into this more. |
We need this in and a new release made so we can unblock the pari 2.17 upgrade in sage. Anything missing? |
Edit: moved this comment to sagemath/sage#38749 (comment) |
Not a blocker, maybe nice to have #165 (comment) However, it's unclear the scope, should we do just |
Is this ready to be merged? |
I think so, yes. There's the question of the |
I think so, although the question remains about whether to remove or not some functions that are no longer used in sagemath 10.5, but might be used somewhere else (snappy) We could keep those functions but they only make sense with pari 2.15. See my comment #166 (comment) Maybe @NathanDunfield can tell us if they updated snappy to not use those. |
SnapPy is still using prec_dec_to_words. We plan to change that for the
next release, but even after that not all users will have the newest
release. It would be very helpful to us (i.e. to our users) if that-
function could be left in place even though Sage is not using it.
Thanks.
- Marc
…On Mon, Jan 6, 2025 at 2:12 PM Gonzalo Tornaría ***@***.***> wrote:
Is this ready to be merged?
I think so, although the question remains about whether to remove or not
some functions that are no longer used in sagemath 10.5, but might be used
somewhere else (snappy)
We could keep those functions but they only make sense with pari 2.15. See
my comment #166 (comment)
<#166 (comment)>
Maybe @NathanDunfield <https://github.com/NathanDunfield> can tell us if
they updated snappy to not use those.
—
Reply to this email directly, view it on GitHub
<#166 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJ6CPZHMI76ECOK6X4FNSD2JLPSHAVCNFSM6AAAAABPMQEZSGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNZTHA2DCOJTGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I agree this is a waste of energy. My vote would be to move all in to pari 2.17, both in cypari and in sagemath. Distros and software that need pari 2.15 can stay with cypari 2.2.0 and sagemath 10.5. However, keeping In any case, it should be very easy to replace those as we did in sagemath, for instance:
|
Is it
Just do the change, it's very simple. This issue 3-manifolds/SnapPy#124 was opened 2 months ago.
The reason to remove it is not that sagemath is not using it. But that the The |
Since 2.17 pari stores the precision in bits instead of words. Port cypari2 to work with it:
prec_bits_to_words
toprec_bits_to_pari
and outsource it to upstream's nbits2prec, so it works with all pari versionsprec_words_to_bits
,prec_dec_to_words
andprec_words_to_dec
functionsLOWDEFAULTPREC
as default precision