Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
#15114 misc small fixes after removal of dangerous coercions
Browse files Browse the repository at this point in the history
  • Loading branch information
mezzarobba committed Jan 21, 2021
1 parent ba66ce3 commit 9f47f4c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/sage/arith/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5599,7 +5599,7 @@ def _key_complex_for_display(a):
ai = a.imag()
if not ai:
return (0, ar)
epsilon = 1e-10
epsilon = ar.parent()(1e-10)
if ar.abs() < epsilon:
ar_truncated = 0
elif ar.prec() < 34:
Expand Down
7 changes: 4 additions & 3 deletions src/sage/rings/complex_arb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ from sage.rings.integer cimport Integer
from sage.rings.polynomial.polynomial_complex_arb cimport Polynomial_complex_arb
from sage.rings.real_arb cimport mpfi_to_arb, arb_to_mpfi
from sage.rings.real_arb import RealBallField
from sage.rings.real_mpfi cimport RealIntervalField_class
from sage.rings.real_mpfr cimport RealField_class, RealField, RealNumber
from sage.rings.ring import Field
from sage.structure.element cimport Element, ModuleElement
Expand All @@ -187,7 +188,7 @@ from sage.structure.unique_representation import UniqueRepresentation
from sage.arith.long cimport is_small_python_int

from sage.rings.complex_mpfr import ComplexField
from sage.rings.complex_interval_field import ComplexIntervalField
from sage.rings.complex_interval_field import ComplexIntervalField, ComplexIntervalField_class
from sage.rings.integer_ring import ZZ

cdef void ComplexIntervalFieldElement_to_acb(
Expand Down Expand Up @@ -829,9 +830,9 @@ class ComplexBallField(UniqueRepresentation, Field):
cdef bint real = False
if ring is None:
ring = self
elif isinstance(ring, ComplexBallField):
elif isinstance(ring, (ComplexBallField, ComplexIntervalField_class)):
pass
elif isinstance(ring, RealBallField):
elif isinstance(ring, (RealBallField, RealIntervalField_class)):
real = True
elif ring.has_coerce_map_from(self):
pass
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/complex_interval.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ cdef class ComplexIntervalFieldElement(sage.structure.element.FieldElement):
EXAMPLES::
sage: I = CIF.gen()
sage: b = 1.5 + 2.5*I
sage: b = 3/2 + 5/2*I
sage: TestSuite(b).run()
"""
def __cinit__(self, parent, *args):
Expand Down Expand Up @@ -1677,7 +1677,7 @@ cdef class ComplexIntervalFieldElement(sage.structure.element.FieldElement):
1.570796326794897?
sage: (-i).argument()
-1.570796326794897?
sage: (RR('-0.001') - i).argument()
sage: (-1/1000 - i).argument()
-1.571796326461564?
sage: CIF(2).argument()
0
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/polynomial/complex_roots.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ def complex_roots(p, skip_squarefree=False, retval='interval', min_prec=0):
[(-14.61803398874990?..., 1), (-12.3819660112501...? + 0.?e-27*I, 1)]
sage: sorted((v[0][0].real(),v[1][0].real()))
[-14.61803398874989?, -12.3819660112501...?]
sage: v[0][0].imag() < 1e25
sage: v[0][0].imag().upper() < 1e25
True
sage: v[1][0].imag() < 1e25
sage: v[1][0].imag().upper() < 1e25
True
sage: K.<im> = QuadraticField(-1)
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/qqbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -6869,9 +6869,9 @@ def _real_refine_interval(self, interval, prec):
newton_lower = not newton_lower

if newton_lower:
interval = interval.intersection(l - pl/slope)
interval = interval.intersection(field(l) - pl/slope)
else:
interval = interval.intersection(u - pu/slope)
interval = interval.intersection(field(u) - pu/slope)
new_diam = interval.diameter()

if new_diam == 0:
Expand Down

0 comments on commit 9f47f4c

Please sign in to comment.