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

Fix test failures due to global mpmath state #38776

Merged
merged 4 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/sage/functions/orthogonal_polys.py
Original file line number Diff line number Diff line change
Expand Up @@ -2343,10 +2343,10 @@ class Func_ultraspherical(GinacFunction):
sage: # needs mpmath
sage: from mpmath import gegenbauer as gegenbauer_mp
sage: from mpmath import mp
sage: mp.pretty = True; mp.dps=25
sage: gegenbauer_mp(-7,0.5,0.3)
sage: print(gegenbauer_mp(-7,0.5,0.3))
0.1291811875
sage: gegenbauer_mp(2+3j, -0.75, -1000j)
sage: with mp.workdps(25):
....: print(gegenbauer_mp(2+3j, -0.75, -1000j))
(-5038991.358609026523401901 + 9414549.285447104177860806j)

TESTS:
Expand Down
30 changes: 15 additions & 15 deletions src/sage/libs/mpmath/ext_main.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -983,19 +983,18 @@ cdef class Context:
TESTS::

sage: from mpmath import mp
sage: mp.pretty = True
sage: (x, T) = mp._convert_param(3)
sage: (x, type(x).__name__, T)
(3, 'int', 'Z')
sage: (x, T) = mp._convert_param(2.5)
sage: (x, type(x).__name__, T)
(mpq(5,2), 'mpq', 'Q')
sage: (x, T) = mp._convert_param(2.3)
sage: (x, type(x).__name__, T)
(2.3, 'mpf', 'R')
sage: (str(x), type(x).__name__, T)
('2.3', 'mpf', 'R')
sage: (x, T) = mp._convert_param(2+3j)
sage: (x, type(x).__name__, T)
((2.0 + 3.0j), 'mpc', 'C')
(mpc(real='2.0', imag='3.0'), 'mpc', 'C')
sage: mp.pretty = False
"""
cdef MPF v
Expand Down Expand Up @@ -1056,15 +1055,14 @@ cdef class Context:
TESTS::

sage: from mpmath import *
sage: mp.pretty = True
sage: mag(10), mag(10.0), mag(mpf(10)), int(ceil(log(10,2)))
(4, 4, 4, 4)
sage: mag(10j), mag(10+10j)
(4, 5)
sage: mag(0.01), int(ceil(log(0.01,2)))
(-6, -6)
sage: mag(0), mag(inf), mag(-inf), mag(nan)
(-inf, +inf, +inf, nan)
(mpf('-inf'), mpf('+inf'), mpf('+inf'), mpf('nan'))

::

Expand Down Expand Up @@ -2203,12 +2201,13 @@ cdef class constant(mpf_base):
Represent ``self`` as a string. With mp.pretty=False, the
representation differs from that of an ordinary mpf::

sage: from mpmath import mp, pi
sage: mp.pretty = True
sage: repr(pi)
sage: from mpmath import mp
sage: mp2 = mp.clone()
sage: mp2.pretty = True
sage: repr(mp2.pi)
'3.14159265358979'
sage: mp.pretty = False
sage: repr(pi)
sage: mp2.pretty = False
sage: repr(mp2.pi)
'<pi: 3.14159~>'
"""
if global_context.pretty:
Expand Down Expand Up @@ -2374,11 +2373,12 @@ cdef class mpc(mpnumber):
TESTS::

sage: from mpmath import mp
sage: mp.pretty = True
sage: repr(mp.mpc(2,3))
sage: mp2 = mp.clone()
sage: mp2.pretty = True
sage: repr(mp2.mpc(2,3))
'(2.0 + 3.0j)'
sage: mp.pretty = False
sage: repr(mp.mpc(2,3))
sage: mp2.pretty = False
sage: repr(mp2.mpc(2,3))
"mpc(real='2.0', imag='3.0')"
"""
if global_context.pretty:
Expand Down
Loading