Skip to content
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

replace wrongly placed sig_on/off pair with sig_check #36422

Merged
merged 2 commits into from
Oct 14, 2023

Conversation

dimpase
Copy link
Member

@dimpase dimpase commented Oct 8, 2023

fixes the bug noted in mpmath/mpmath#723
The problem comes from the sig_on/off pair guarding non-Cython statements; we replace it by sig_check()

sage: from mpmath import *
sage: mp.dps=16
sage: zeta(-0.01 + 1000j)
---------------------------------------------------------------------------
SystemError                               Traceback (most recent call last)
Cell In [3], line 1
----> 1 zeta(-RealNumber('0.01') + ComplexNumber(0, '1000'))

File /usr/lib/python3.11/site-packages/mpmath/functions/zeta.py:580, in zeta(ctx, s, a, derivative, method, **kwargs)
    578 if ctx.re(s) > 2*ctx.prec and a == 1 and not derivative:
    579     return ctx.one + ctx.power(2, -s)
--> 580 return +ctx._hurwitz(s, a, d, **kwargs)

File /usr/lib/python3.11/site-packages/mpmath/functions/zeta.py:595, in _hurwitz(ctx, s, a, d, **kwargs)
    593     print("zeta: Attempting reflection formula")
    594 try:
--> 595     return _hurwitz_reflection(ctx, s, a, d, atype)
    596 except NotImplementedError:
    597     pass

File /usr/lib/python3.11/site-packages/mpmath/functions/zeta.py:654, in _hurwitz_reflection(ctx, s, a, d, atype)
    652 p += shift*q
    653 assert 1 <= p <= q
--> 654 g = ctx.fsum(ctx.cospi(t/2-2*k*b)*ctx._hurwitz(t,(k,q)) \
    655     for k in range(1,q+1))
    656 g *= 2*ctx.gamma(t)/(2*ctx.pi*q)**t
    657 v += g

File /mnt/opt/Sage/sage-dev/src/sage/libs/mpmath/ext_main.pyx:767, in sage.libs.mpmath.ext_main.Context.fsum()
    765 workopts.rounding = ROUND_D
    766 unknown = global_context.zero
--> 767 sig_on()
    768 try:  # Way down, there is a ``finally`` with sig_off()
    769     MPF_init(&sre)

SystemError: calling remove_from_pari_stack() inside sig_on()

@kwankyu
Copy link
Collaborator

kwankyu commented Oct 9, 2023

Otherwise, lgtm.

fixes the bug noted in mpmath/mpmath#723

sage: from mpmath import *
sage: mp.dps=16
sage: zeta(-0.01 + 1000j)
---------------------------------------------------------------------------
SystemError                               Traceback (most recent call last)
Cell In [3], line 1
----> 1 zeta(-RealNumber('0.01') + ComplexNumber(0, '1000'))

File /usr/lib/python3.11/site-packages/mpmath/functions/zeta.py:580, in zeta(ctx, s, a, derivative, method, **kwargs)
    578 if ctx.re(s) > 2*ctx.prec and a == 1 and not derivative:
    579     return ctx.one + ctx.power(2, -s)
--> 580 return +ctx._hurwitz(s, a, d, **kwargs)

File /usr/lib/python3.11/site-packages/mpmath/functions/zeta.py:595, in _hurwitz(ctx, s, a, d, **kwargs)
    593     print("zeta: Attempting reflection formula")
    594 try:
--> 595     return _hurwitz_reflection(ctx, s, a, d, atype)
    596 except NotImplementedError:
    597     pass

File /usr/lib/python3.11/site-packages/mpmath/functions/zeta.py:654, in _hurwitz_reflection(ctx, s, a, d, atype)
    652 p += shift*q
    653 assert 1 <= p <= q
--> 654 g = ctx.fsum(ctx.cospi(t/2-2*k*b)*ctx._hurwitz(t,(k,q)) \
    655     for k in range(1,q+1))
    656 g *= 2*ctx.gamma(t)/(2*ctx.pi*q)**t
    657 v += g

File /mnt/opt/Sage/sage-dev/src/sage/libs/mpmath/ext_main.pyx:767, in sage.libs.mpmath.ext_main.Context.fsum()
    765 workopts.rounding = ROUND_D
    766 unknown = global_context.zero
--> 767 sig_on()
    768 try:  # Way down, there is a ``finally`` with sig_off()
    769     MPF_init(&sre)

SystemError: calling remove_from_pari_stack() inside sig_on()
Copy link
Collaborator

@kwankyu kwankyu left a comment

Choose a reason for hiding this comment

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

Thanks.

@github-actions
Copy link

github-actions bot commented Oct 9, 2023

Documentation preview for this PR (built with commit 86cc741; changes) is ready! 🎉

@vbraun vbraun merged commit 45019c3 into sagemath:develop Oct 14, 2023
@mkoeppe mkoeppe added this to the sage-10.2 milestone Oct 14, 2023
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.

4 participants