Skip to content

Commit

Permalink
Fix doctests with flintlib 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
tornaria committed Jan 30, 2025
1 parent 7559c5c commit 6d9ac56
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 40 deletions.
49 changes: 25 additions & 24 deletions src/sage/rings/complex_arb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -790,8 +790,8 @@ class ComplexBallField(UniqueRepresentation, sage.rings.abc.ComplexBallField):
sage: (x^4 - 1/3).roots(multiplicities=False) # indirect doctest
[[-0.759835685651593 +/- ...e-16] + [+/- ...e-16]*I,
[0.759835685651593 +/- ...e-16] + [+/- ...e-16]*I,
[+/- ...e-16] + [0.759835685651593 +/- ...e-16]*I,
[+/- ...e-16] + [-0.759835685651593 +/- ...e-16]*I]
[+/- ...e-16] + [-0.759835685651593 +/- ...e-16]*I,
[+/- ...e-16] + [0.759835685651593 +/- ...e-16]*I]
sage: (x^4 - 1/3).roots(RBF, multiplicities=False)
[[-0.759835685651593 +/- ...e-16], [0.759835685651593 +/- ...e-16]]
Expand All @@ -803,8 +803,8 @@ class ComplexBallField(UniqueRepresentation, sage.rings.abc.ComplexBallField):
sage: (x^4 - 3).roots(ComplexIntervalField(100), multiplicities=False)
[-1.31607401295249246081921890180? + 0.?e-37*I,
1.31607401295249246081921890180? + 0.?e-37*I,
0.?e-37 + 1.31607401295249246081921890180?*I,
0.?e-37 - 1.31607401295249246081921890180?*I]
0.?e-37 - 1.31607401295249246081921890180?*I,
0.?e-37 + 1.31607401295249246081921890180?*I]
sage: (x^2 - i/3).roots(ComplexBallField(2), multiplicities=False)
[[+/- 0.409] + [+/- 0.409]*I, [+/- 0.409] + [+/- 0.409]*I]
Expand All @@ -817,8 +817,8 @@ class ComplexBallField(UniqueRepresentation, sage.rings.abc.ComplexBallField):
sage: ((x - 1)^2).roots(multiplicities=False, proof=False)
doctest:...
UserWarning: roots may have been lost...
[[1.00000000000 +/- ...e-12] + [+/- ...e-11]*I,
[1.0000000000 +/- ...e-12] + [+/- ...e-12]*I]
[[1.000000000... +/- ...] + [+/- ...]*I,
[1.000000000... +/- ...] + [+/- ...]*I]
sage: pol = x^7 - 2*(1000*x - 1)^2 # Mignotte polynomial
sage: pol.roots(multiplicities=False)
Expand All @@ -843,7 +843,8 @@ class ComplexBallField(UniqueRepresentation, sage.rings.abc.ComplexBallField):
sage: ((x - 1)^2 + 2^(-70)*i/3).roots(RBF, multiplicities=False)
Traceback (most recent call last):
...
ValueError: unable to determine which roots are real
ValueError: unable to isolate the roots (try using proof=False or
increasing the precision)
TESTS::
Expand Down Expand Up @@ -4199,14 +4200,14 @@ cdef class ComplexBall(RingElement):
EXAMPLES::
sage: CBF(1, 1).Ei()
[1.76462598556385 +/- ...e-15] + [2.38776985151052 +/- ...e-15]*I
sage: CBF(1, 1).Ei() # abs tol 6e-15
[1.76462598556385 +/- 6.03e-15] + [2.38776985151052 +/- 4.23e-15]*I
sage: CBF(0).Ei()
nan
nan...
TESTS:
sage: CBF(Ei(I)) # abs tol 1e-16 # needs sage.symbolic
sage: CBF(Ei(I)) # abs tol 2e-15 # needs sage.symbolic
[0.337403922900968 +/- 3.76e-16] + [2.51687939716208 +/- 2.01e-15]*I
"""
cdef ComplexBall result = self._new()
Expand All @@ -4221,14 +4222,14 @@ cdef class ComplexBall(RingElement):
EXAMPLES::
sage: CBF(1, 1).Si()
[1.10422265823558 +/- ...e-15] + [0.88245380500792 +/- ...e-15]*I
sage: CBF(1, 1).Si() # abs tol 3e-15
[1.10422265823558 +/- 2.48e-15] + [0.88245380500792 +/- 3.36e-15]*I
sage: CBF(0).Si()
0
TESTS:
sage: CBF(Si(I)) # needs sage.symbolic
sage: CBF(Si(I)) # abs tol 3e-15 # needs sage.symbolic
[1.05725087537573 +/- 2.77e-15]*I
"""
cdef ComplexBall result = self._new()
Expand All @@ -4245,14 +4246,14 @@ cdef class ComplexBall(RingElement):
EXAMPLES::
sage: CBF(1, 1).Ci()
[0.882172180555936 +/- ...e-16] + [0.287249133519956 +/- ...e-16]*I
sage: CBF(1, 1).Ci() # abs tol 5e-16
[0.882172180555936 +/- 5.89e-16] + [0.287249133519956 +/- 3.37e-16]*I
sage: CBF(0).Ci()
nan + nan*I
TESTS:
sage: CBF(Ci(I)) # abs tol 1e-17 # needs sage.symbolic
sage: CBF(Ci(I)) # abs tol 5e-16 # needs sage.symbolic
[0.837866940980208 +/- 4.72e-16] + [1.570796326794897 +/- 5.54e-16]*I
"""
cdef ComplexBall result = self._new()
Expand All @@ -4269,8 +4270,8 @@ cdef class ComplexBall(RingElement):
EXAMPLES::
sage: CBF(1, 1).Shi()
[0.88245380500792 +/- ...e-15] + [1.10422265823558 +/- ...e-15]*I
sage: CBF(1, 1).Shi() # abs tol 3e-15
[0.88245380500792 +/- 3.36e-15] + [1.10422265823558 +/- 2.48e-15]*I
sage: CBF(0).Shi()
0
Expand All @@ -4293,14 +4294,14 @@ cdef class ComplexBall(RingElement):
EXAMPLES::
sage: CBF(1, 1).Chi()
[0.882172180555936 +/- ...e-16] + [1.28354719327494 +/- ...e-15]*I
sage: CBF(1, 1).Chi() # abs tol 1e-15
[0.882172180555936 +/- 5.89e-16] + [1.28354719327494 +/- 1.01e-15]*I
sage: CBF(0).Chi()
nan + nan*I
TESTS:
sage: CBF(Chi(I)) # abs tol 1e-16 # needs sage.symbolic
sage: CBF(Chi(I)) # abs tol 5e-16 # needs sage.symbolic
[0.337403922900968 +/- 3.25e-16] + [1.570796326794897 +/- 5.54e-16]*I
"""
cdef ComplexBall result = self._new()
Expand All @@ -4319,8 +4320,8 @@ cdef class ComplexBall(RingElement):
EXAMPLES::
sage: CBF(1, 1).li()
[0.61391166922120 +/- ...e-15] + [2.05958421419258 +/- ...e-15]*I
sage: CBF(1, 1).li() # abs tol 6e-15
[0.61391166922120 +/- 6.23e-15] + [2.05958421419258 +/- 5.59e-15]*I
sage: CBF(0).li()
0
sage: CBF(0).li(offset=True)
Expand Down
14 changes: 7 additions & 7 deletions src/sage/rings/polynomial/polynomial_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8398,19 +8398,19 @@ cdef class Polynomial(CommutativePolynomial):
sage: # needs sage.libs.flint
sage: Pol.<x> = CBF[]
sage: (x^2 + 2).roots(multiplicities=False)
[[+/- ...e-19] + [-1.414213562373095 +/- ...e-17]*I,
[+/- ...e-19] + [1.414213562373095 +/- ...e-17]*I]
sage: set((x^2 + 2).roots(multiplicities=False))
{[+/- ...e-19] + [-1.414213562373095 +/- ...e-17]*I,
[+/- ...e-19] + [1.414213562373095 +/- ...e-17]*I}
sage: (x^3 - 1/2).roots(RBF, multiplicities=False)
[[0.7937005259840997 +/- ...e-17]]
sage: ((x - 1)^2).roots(multiplicities=False, proof=False)
doctest:...
UserWarning: roots may have been lost...
[[1.00000000000 +/- ...e-12] + [+/- ...e-11]*I,
[1.0000000000 +/- ...e-12] + [+/- ...e-12]*I]
[[1.000000000... +/- ...] + [+/- ...]*I,
[1.000000000... +/- ...] + [+/- ...]*I]
sage: ((x - 1)^2).roots(multiplicities=False, proof=False, warn=False)
[[1.00000000000 +/- ...e-12] + [+/- ...e-11]*I,
[1.0000000000 +/- ...e-12] + [+/- ...e-12]*I]
[[1.000000000... +/- ...] + [+/- ...]*I,
[1.000000000... +/- ...] + [+/- ...]*I]
Note that coefficients in a number field with defining polynomial
`x^2 + 1` are considered to be Gaussian rationals (with the
Expand Down
18 changes: 9 additions & 9 deletions src/sage/rings/real_arb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3531,12 +3531,12 @@ cdef class RealBall(RingElement):
EXAMPLES::
sage: RBF(1).Ei() # abs tol 5e-16
sage: RBF(1).Ei() # abs tol 5e-15
[1.89511781635594 +/- 4.94e-15]
TESTS::
sage: RBF(Ei(1)) # abs tol 5e-16 # needs sage.symbolic
sage: RBF(Ei(1)) # abs tol 5e-15 # needs sage.symbolic
[1.89511781635594 +/- 4.94e-15]
"""
cdef RealBall res = self._new()
Expand Down Expand Up @@ -3595,12 +3595,12 @@ cdef class RealBall(RingElement):
EXAMPLES::
sage: RBF(1).Shi()
sage: RBF(1).Shi() # abs tol 5e-15
[1.05725087537573 +/- 2.77e-15]
TESTS::
sage: RBF(Shi(1)) # needs sage.symbolic
sage: RBF(Shi(1)) # abs tol 5e-15 # needs sage.symbolic
[1.05725087537573 +/- 2.77e-15]
"""
cdef RealBall res = self._new()
Expand All @@ -3617,12 +3617,12 @@ cdef class RealBall(RingElement):
EXAMPLES::
sage: RBF(1).Chi() # abs tol 1e-17
sage: RBF(1).Chi() # abs tol 5e-16
[0.837866940980208 +/- 4.72e-16]
TESTS::
sage: RBF(Chi(1)) # abs tol 1e-17 # needs sage.symbolic
sage: RBF(Chi(1)) # abs tol 5e-16 # needs sage.symbolic
[0.837866940980208 +/- 4.72e-16]
"""
cdef RealBall res = self._new()
Expand All @@ -3639,14 +3639,14 @@ cdef class RealBall(RingElement):
EXAMPLES::
sage: RBF(3).li() # abs tol 1e-15
sage: RBF(3).li() # abs tol 5e-15
[2.16358859466719 +/- 4.72e-15]
TESTS::
sage: RBF(li(0)) # needs sage.symbolic
0
sage: RBF(Li(0)) # needs sage.symbolic
sage: RBF(Li(0)) # abs tol 5e-15 # needs sage.symbolic
[-1.04516378011749 +/- 4.23e-15]
"""
cdef RealBall res = self._new()
Expand All @@ -3663,7 +3663,7 @@ cdef class RealBall(RingElement):
EXAMPLES::
sage: RBF(3).Li() # abs tol 1e-15
sage: RBF(3).Li() # abs tol 5e-15
[1.11842481454970 +/- 7.61e-15]
"""
cdef RealBall res = self._new()
Expand Down

0 comments on commit 6d9ac56

Please sign in to comment.