sagemath/sage

sage.doctest: Eliminate hard dependency on RealIntervalField

Closed this issue · 13 comments

Follow up on #29922.
The doctester uses RealIntervalField for doctests involving numerical tolerances. This is an obstacle to doctesting modularized subset distributions because RealIntervalField depends on a compiled library (MPFI).

We should eliminate this by rewriting it in a more elementary way.

As of this ticket, we just issue a warning if RealIntervalField is not available.

CC: @kliem @sagetrac-tmonteil

Component: doctest framework

Author: Matthias Koeppe

Branch/Commit: db154ec

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/32585

New commits:

13eed83src/sage/doctest/parsing.py: Do not fail if RealIntervalField cannot be imported, just warn

Description changed:

--- 
+++ 
@@ -1,5 +1,7 @@
 Follow up on #29922. 
-The doctester uses `RealIntervalField` for doctests involving numerical tolerances. This is an obstacle to doctesting modularized subset distributions.
+The doctester uses `RealIntervalField` for doctests involving numerical tolerances. This is an obstacle to doctesting modularized subset distributions because `RealIntervalField` depends on a compiled library (MPFI).
 
 We should eliminate this by rewriting it in a more elementary way.
 
+As of this ticket, we just issue a warning if `RealIntervalField` is not available.
+

Commit: 13eed83

Author: Matthias Koeppe

Reviewer: Travis Scrimshaw

comment:4

LGTM.

comment:5

Thank you!

comment:6

Something isn't quite right with this workaround yet. Getting a TypeError in doctesting framework when testing in #32432 sage/geometry/polyhedron/library.py", line 677, in sage.geometry.polyhedron.library.Polytopes.simplex

 File "/Users/mkoeppe/s/sage/sage-rebasing/worktree-gcc11/pkgs/sagemath-polyhedra/.tox/python/lib/python3.9/site-packages/sage/doctest/parsing.py", line 1121, in <listcomp>
    want_intervals = [self.add_tolerance(v, want) for v in want_values]
  File "/Users/mkoeppe/s/sage/sage-rebasing/worktree-gcc11/pkgs/sagemath-polyhedra/.tox/python/lib/python3.9/site-packages/sage/doctest/parsing.py", line 977, in add_tolerance
    return wantval + RIFtol(want.abs_tol) * RIFtol(-1,1)
TypeError: can't multiply sequence by non-int of type 'float'

Changed commit from 13eed83 to db154ec

Branch pushed to git repo; I updated commit sha1. New commits:

db154ecsage.doctest.parsing.RIFtol: Fixup when RealIntervalField not available
comment:11

Thanks.