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

Commit

Permalink
src/sage/doctest/parsing.py: Do not fail if RealIntervalField cannot …
Browse files Browse the repository at this point in the history
…be imported, just warn
  • Loading branch information
Matthias Koeppe committed Oct 3, 2021
1 parent 52915b6 commit 13eed83
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/sage/doctest/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,19 @@ def RIFtol(*args):
"""
global _RIFtol
if _RIFtol is None:
# We need to import from sage.all to avoid circular imports.
from sage.all import RealIntervalField
_RIFtol = RealIntervalField(1044)
try:
# We need to import from sage.all to avoid circular imports.
from sage.all import RealIntervalField
except ImportError:
from warnings import warn
warn("RealIntervalField not available, ignoring all tolerance specifications in doctests")
def fake_RIFtol(*args):
if len(args) == 2:
return (args[0] + args[1]) / 2
return args[0]
_RIFtol = fake_RIFtol
else:
_RIFtol = RealIntervalField(1044)
return _RIFtol(*args)

# This is the correct pattern to match ISO/IEC 6429 ANSI escape sequences:
Expand Down

0 comments on commit 13eed83

Please sign in to comment.