Skip to content

abs tol unable to handle non-real numerical noise #36631

@dimpase

Description

@dimpase

E.g.

--- a/src/sage/doctest/parsing.py
+++ b/src/sage/doctest/parsing.py
@@ -1461,7 +1461,7 @@ class SageOutputChecker(doctest.OutputChecker):
             ...
             RuntimeError
             sage: 1  # abs tol 2
-            -0.5
+            -0.5+0.0001*I
             sage: print("0.9999")    # rel tol 1e-4
             1.0
             sage: print("1.00001")   # abs tol 1e-5

gives

sage -t --warn-long 20.5 --random-seed=37938279076849498617774420336933883040 src/sage/doctest/parsing.py
**********************************************************************
File "src/sage/doctest/parsing.py", line 1463, in sage.doctest.parsing.SageOutputChecker.check_output
Failed example:
    1  # abs tol 2
Expected:
    -0.5+0.0001*I
Got:
    1
**********************************************************************
1 item had failures:
   1 of  55 in sage.doctest.parsing.SageOutputChecker.check_output
    [322 tests, 1 failure, 0.17 s]
----------------------------------------------------------------------
sage -t --warn-long 20.5 --random-seed=37938279076849498617774420336933883040 src/sage/doctest/parsing.py  # 1 doctest failed

Indeed, RIF is used as data to check tolerances, no wonder things go wrong here.
By right, one needs a complex abs tol and rel tol.

Originally posted by @dimpase in #36509 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions