Skip to content

Commit

Permalink
_is_[real_]numerical: Fall back to using CDF/RDF if ComplexField, Rea…
Browse files Browse the repository at this point in the history
…lField cannot be imported
  • Loading branch information
Matthias Koeppe committed Oct 26, 2021
1 parent 056b8d4 commit bf0ed1d
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/sage/structure/parent.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2812,9 +2812,16 @@ cdef class Parent(sage.structure.category_object.CategoryObject):
sage: [R._is_numerical() for R in [RIF, RBF, CIF, CBF]]
[False, False, False, False]
"""
from sage.rings.complex_mpfr import ComplexField
from sage.rings.real_mpfr import mpfr_prec_min
return ComplexField(mpfr_prec_min()).has_coerce_map_from(self)
try:
from sage.rings.complex_mpfr import ComplexField
from sage.rings.real_mpfr import mpfr_prec_min
except ImportError:
pass
else:
return ComplexField(mpfr_prec_min()).has_coerce_map_from(self)

from sage.rings.real_double import CDF
return CDF.has_coerce_map_from(self)

@cached_method
def _is_real_numerical(self):
Expand All @@ -2833,8 +2840,15 @@ cdef class Parent(sage.structure.category_object.CategoryObject):
sage: [R._is_real_numerical() for R in [RIF, RBF, CIF, CBF]]
[False, False, False, False]
"""
from sage.rings.real_mpfr import RealField, mpfr_prec_min
return RealField(mpfr_prec_min()).has_coerce_map_from(self)
try:
from sage.rings.real_mpfr import RealField, mpfr_prec_min
except ImportError:
pass
else:
return RealField(mpfr_prec_min()).has_coerce_map_from(self)

from sage.rings.real_double import RDF
return RDF.has_coerce_map_from(self)

############################################################################
# Set base class --
Expand Down

0 comments on commit bf0ed1d

Please sign in to comment.